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");
}
}
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());
}
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());
}
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());
}
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());
}
Aggregations