Search in sources :

Example 1 with AclData

use of com.cloud.network.bigswitch.AclData in project cloudstack by apache.

the class BigSwitchBcfResource method executeRequest.

private Answer executeRequest(UpdateBcfRouterCommand cmd, int numRetries) {
    RouterData routerData = new RouterData(cmd.getTenantId());
    List<AclData> acls = new ArrayList<AclData>();
    acls.addAll(cmd.getAcls());
    routerData.getRouter().getAcls().addAll(acls);
    routerData.getRouter().addExternalGateway(cmd.getPublicIp());
    try {
        String hash = _bigswitchBcfApi.modifyRouter(cmd.getTenantId(), routerData);
        return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated", hash);
    } catch (BigSwitchBcfApiException e) {
        if (e.is_topologySyncRequested()) {
            cmd.setTopologySyncRequested(true);
            return new BcfAnswer(cmd, true, "tenant " + cmd.getTenantId() + " router updated but topology sync required.");
        } else {
            if (numRetries > 0) {
                return retry(cmd, --numRetries);
            } else {
                return new BcfAnswer(cmd, e);
            }
        }
    } catch (IllegalArgumentException e1) {
        return new BcfAnswer(cmd, false, "Illegal argument in BCF router update");
    }
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) AclData(com.cloud.network.bigswitch.AclData) ArrayList(java.util.ArrayList) RouterData(com.cloud.network.bigswitch.RouterData)

Example 2 with AclData

use of com.cloud.network.bigswitch.AclData in project cloudstack by apache.

the class BigSwitchBcfElement method updateBcfRouter.

private void updateBcfRouter(Network network) throws IllegalArgumentException {
    bcfUtilsInit();
    Vpc vpc = null;
    if (network.getVpcId() != null) {
        vpc = _vpcDao.acquireInLockTable(network.getVpcId());
    }
    String tenantId;
    if (vpc != null) {
        tenantId = vpc.getUuid();
        _vpcDao.releaseFromLockTable(vpc.getId());
    } else {
        tenantId = network.getUuid();
    }
    UpdateBcfRouterCommand cmd = new UpdateBcfRouterCommand(tenantId);
    List<AclData> aclList = _bcfUtils.listACLbyNetwork(network);
    for (AclData acl : aclList) {
        cmd.addAcl(acl);
    }
    if (vpc != null) {
        cmd.setPublicIp(_bcfUtils.getPublicIpByVpc(vpc));
    } else {
        cmd.setPublicIp(_bcfUtils.getPublicIpByNetwork(network));
    }
    BcfAnswer answer = _bcfUtils.sendBcfCommandWithNetworkSyncCheck(cmd, network);
    if (answer != null && !answer.getResult()) {
        throw new IllegalArgumentException("Illegal router update arguments");
    }
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) AclData(com.cloud.network.bigswitch.AclData) Vpc(com.cloud.network.vpc.Vpc) UpdateBcfRouterCommand(com.cloud.agent.api.UpdateBcfRouterCommand)

Aggregations

BcfAnswer (com.cloud.agent.api.BcfAnswer)2 AclData (com.cloud.network.bigswitch.AclData)2 UpdateBcfRouterCommand (com.cloud.agent.api.UpdateBcfRouterCommand)1 BigSwitchBcfApiException (com.cloud.network.bigswitch.BigSwitchBcfApiException)1 RouterData (com.cloud.network.bigswitch.RouterData)1 Vpc (com.cloud.network.vpc.Vpc)1 ArrayList (java.util.ArrayList)1