Search in sources :

Example 1 with UpdateBcfRouterCommand

use of com.cloud.agent.api.UpdateBcfRouterCommand 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)

Example 2 with UpdateBcfRouterCommand

use of com.cloud.agent.api.UpdateBcfRouterCommand in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testCreateSourceNatApiException.

@Test
public void testCreateSourceNatApiException() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    doThrow(new BigSwitchBcfApiException()).when(_bigswitchBcfApi).modifyRouter((String) any(), (RouterData) any());
    UpdateBcfRouterCommand cmd = new UpdateBcfRouterCommand("tenantid");
    BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
    assertFalse(ans.getResult());
    verify(_bigswitchBcfApi, times(3)).modifyRouter((String) any(), (RouterData) any());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) UpdateBcfRouterCommand(com.cloud.agent.api.UpdateBcfRouterCommand) Test(org.junit.Test)

Example 3 with UpdateBcfRouterCommand

use of com.cloud.agent.api.UpdateBcfRouterCommand in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testDeleteSourceNatRetryOnce.

@Test
public void testDeleteSourceNatRetryOnce() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    when(_bigswitchBcfApi.modifyRouter((String) any(), (RouterData) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
    UpdateBcfRouterCommand cmd = new UpdateBcfRouterCommand("tenantid");
    BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
    assertTrue(ans.getResult());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) RouterData(com.cloud.network.bigswitch.RouterData) UpdateBcfRouterCommand(com.cloud.agent.api.UpdateBcfRouterCommand) Test(org.junit.Test)

Example 4 with UpdateBcfRouterCommand

use of com.cloud.agent.api.UpdateBcfRouterCommand in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testDeleteSourceNatApiException.

@Test
public void testDeleteSourceNatApiException() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    doThrow(new BigSwitchBcfApiException()).when(_bigswitchBcfApi).modifyRouter((String) any(), (RouterData) any());
    UpdateBcfRouterCommand cmd = new UpdateBcfRouterCommand("tenantid");
    BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
    assertFalse(ans.getResult());
    verify(_bigswitchBcfApi, times(3)).modifyRouter((String) any(), (RouterData) any());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) UpdateBcfRouterCommand(com.cloud.agent.api.UpdateBcfRouterCommand) Test(org.junit.Test)

Example 5 with UpdateBcfRouterCommand

use of com.cloud.agent.api.UpdateBcfRouterCommand in project cloudstack by apache.

the class BigSwitchBcfResourceTest method testCreateSourceNatRetryOnce.

@Test
public void testCreateSourceNatRetryOnce() throws ConfigurationException, BigSwitchBcfApiException {
    _resource.configure("BigSwitchBcfResource", _parameters);
    when(_bigswitchBcfApi.modifyRouter((String) any(), (RouterData) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
    UpdateBcfRouterCommand cmd = new UpdateBcfRouterCommand("tenantid");
    BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
    assertTrue(ans.getResult());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) RouterData(com.cloud.network.bigswitch.RouterData) UpdateBcfRouterCommand(com.cloud.agent.api.UpdateBcfRouterCommand) Test(org.junit.Test)

Aggregations

BcfAnswer (com.cloud.agent.api.BcfAnswer)5 UpdateBcfRouterCommand (com.cloud.agent.api.UpdateBcfRouterCommand)5 BigSwitchBcfApiException (com.cloud.network.bigswitch.BigSwitchBcfApiException)4 Test (org.junit.Test)4 RouterData (com.cloud.network.bigswitch.RouterData)2 AclData (com.cloud.network.bigswitch.AclData)1 Vpc (com.cloud.network.vpc.Vpc)1