Search in sources :

Example 1 with DeleteBcfSegmentCommand

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

the class BigSwitchBcfGuestNetworkGuru method shutdown.

@Override
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
    NetworkVO networkObject = _networkDao.findById(profile.getId());
    if (networkObject.getBroadcastDomainType() != BroadcastDomainType.Vlan || networkObject.getBroadcastUri() == null) {
        s_logger.warn("BroadcastUri is empty or incorrect for guestnetwork " + networkObject.getDisplayText());
        return;
    }
    bcfUtilsInit();
    // tenantId stored in network domain field at creation
    String tenantId = networkObject.getNetworkDomain();
    String networkId = networkObject.getUuid();
    DeleteBcfSegmentCommand cmd = new DeleteBcfSegmentCommand(tenantId, networkId);
    _bcfUtils.sendBcfCommandWithNetworkSyncCheck(cmd, networkObject);
    super.shutdown(profile, offering);
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) DeleteBcfSegmentCommand(com.cloud.agent.api.DeleteBcfSegmentCommand)

Example 2 with DeleteBcfSegmentCommand

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

the class BigSwitchBcfResourceTest method testDeleteNetworkRetryOnce.

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

Example 3 with DeleteBcfSegmentCommand

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

the class BigSwitchBcfResourceTest method testDeleteNetworkApiException.

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

Aggregations

DeleteBcfSegmentCommand (com.cloud.agent.api.DeleteBcfSegmentCommand)3 BcfAnswer (com.cloud.agent.api.BcfAnswer)2 BigSwitchBcfApiException (com.cloud.network.bigswitch.BigSwitchBcfApiException)2 Test (org.junit.Test)2 NetworkVO (com.cloud.network.dao.NetworkVO)1 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)1