Search in sources :

Example 1 with DeleteBcfAttachmentCommand

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;
}
Also used : DeleteBcfAttachmentCommand(com.cloud.agent.api.DeleteBcfAttachmentCommand)

Example 2 with DeleteBcfAttachmentCommand

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());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) DeleteBcfAttachmentCommand(com.cloud.agent.api.DeleteBcfAttachmentCommand) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) Test(org.junit.Test)

Example 3 with DeleteBcfAttachmentCommand

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());
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) DeleteBcfAttachmentCommand(com.cloud.agent.api.DeleteBcfAttachmentCommand) BigSwitchBcfApiException(com.cloud.network.bigswitch.BigSwitchBcfApiException) Test(org.junit.Test)

Aggregations

DeleteBcfAttachmentCommand (com.cloud.agent.api.DeleteBcfAttachmentCommand)3 BcfAnswer (com.cloud.agent.api.BcfAnswer)2 BigSwitchBcfApiException (com.cloud.network.bigswitch.BigSwitchBcfApiException)2 Test (org.junit.Test)2