use of com.cloud.agent.api.DeleteBcfAttachmentCommand in project cloudstack by apache.
the class BigSwitchBcfElement method release.
@Override
public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
if (!canHandle(network, Service.Connectivity)) {
return false;
}
if (network.getBroadcastUri() == null) {
s_logger.error("Nic has no broadcast Uri");
return false;
}
bcfUtilsInit();
String networkId = network.getUuid();
String nicId = nic.getUuid();
String tenantId;
if (network.getVpcId() != null) {
tenantId = network.getNetworkDomain();
} else {
tenantId = networkId;
}
DeleteBcfAttachmentCommand cmd = new DeleteBcfAttachmentCommand(tenantId, networkId, nicId);
_bcfUtils.sendBcfCommandWithNetworkSyncCheck(cmd, network);
return true;
}
use of com.cloud.agent.api.DeleteBcfAttachmentCommand in project cloudstack by apache.
the class BigSwitchBcfResourceTest method testDeleteAttachmentRetryOnce.
@Test
public void testDeleteAttachmentRetryOnce() throws ConfigurationException, BigSwitchBcfApiException {
_resource.configure("BigSwitchBcfResource", _parameters);
when(_bigswitchBcfApi.deleteAttachment((String) any(), (String) any(), (String) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
BcfAnswer ans = (BcfAnswer) _resource.executeRequest(new DeleteBcfAttachmentCommand("networkId", "portid", "tenantid"));
assertTrue(ans.getResult());
}
use of com.cloud.agent.api.DeleteBcfAttachmentCommand in project cloudstack by apache.
the class BigSwitchBcfResourceTest method testDeleteAttachmentException.
@Test
public void testDeleteAttachmentException() throws ConfigurationException, BigSwitchBcfApiException {
_resource.configure("BigSwitchBcfResource", _parameters);
doThrow(new BigSwitchBcfApiException()).when(_bigswitchBcfApi).deleteAttachment((String) any(), (String) any(), (String) any());
BcfAnswer ans = (BcfAnswer) _resource.executeRequest(new DeleteBcfAttachmentCommand("networkId", "portid", "tenantid"));
assertFalse(ans.getResult());
verify(_bigswitchBcfApi, times(3)).deleteAttachment((String) any(), (String) any(), (String) any());
}
Aggregations