Search in sources :

Example 1 with DeleteLogicalSwitchCommand

use of com.cloud.legacymodel.communication.command.DeleteLogicalSwitchCommand in project cosmic by MissionCriticalCloud.

the class NiciraNvpGuestNetworkGuru method shutdown.

@Override
public void shutdown(final NetworkProfile profile, final NetworkOffering offering) {
    final NetworkVO networkObject = networkDao.findById(profile.getId());
    if (networkObject.getBroadcastDomainType() != BroadcastDomainType.Lswitch || networkObject.getBroadcastUri() == null) {
        s_logger.warn("BroadcastUri is empty or incorrect for guestnetwork " + networkObject.getDisplayText());
        return;
    }
    final List<NiciraNvpDeviceVO> devices = niciraNvpDao.listByPhysicalNetwork(networkObject.getPhysicalNetworkId());
    if (devices.isEmpty()) {
        s_logger.error("No NiciraNvp Controller on physical network " + networkObject.getPhysicalNetworkId());
        return;
    }
    final NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
    final HostVO niciraNvpHost = hostDao.findById(niciraNvpDevice.getHostId());
    final DeleteLogicalSwitchCommand cmd = new DeleteLogicalSwitchCommand(BroadcastDomainType.getValue(networkObject.getBroadcastUri()));
    final DeleteLogicalSwitchAnswer answer = (DeleteLogicalSwitchAnswer) agentMgr.easySend(niciraNvpHost.getId(), cmd);
    if (answer == null || !answer.getResult()) {
        s_logger.error("DeleteLogicalSwitchCommand failed");
    }
    super.shutdown(profile, offering);
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DeleteLogicalSwitchCommand(com.cloud.legacymodel.communication.command.DeleteLogicalSwitchCommand) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) DeleteLogicalSwitchAnswer(com.cloud.legacymodel.communication.answer.DeleteLogicalSwitchAnswer) HostVO(com.cloud.host.HostVO)

Example 2 with DeleteLogicalSwitchCommand

use of com.cloud.legacymodel.communication.command.DeleteLogicalSwitchCommand in project cosmic by MissionCriticalCloud.

the class NiciraNvpResourceTest method testDeleteLogicalSwitchApiException.

@Test
public void testDeleteLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    doThrow(new NiciraNvpApiException()).when(nvpApi).deleteLogicalSwitch((String) any());
    final DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
    final DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) resource.executeRequest(dlsc);
    assertFalse(dlsa.getResult());
}
Also used : DeleteLogicalSwitchCommand(com.cloud.legacymodel.communication.command.DeleteLogicalSwitchCommand) DeleteLogicalSwitchAnswer(com.cloud.legacymodel.communication.answer.DeleteLogicalSwitchAnswer) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) Test(org.junit.Test)

Example 3 with DeleteLogicalSwitchCommand

use of com.cloud.legacymodel.communication.command.DeleteLogicalSwitchCommand in project cosmic by MissionCriticalCloud.

the class NiciraNvpRequestWrapperTest method testDeleteLogicalSwitchCommandWrapper.

@Test
public void testDeleteLogicalSwitchCommandWrapper() {
    final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class);
    final String logicalSwitchUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
    final DeleteLogicalSwitchCommand command = new DeleteLogicalSwitchCommand(logicalSwitchUuid);
    when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi);
    try {
        doNothing().when(niciraNvpApi).deleteLogicalSwitch(command.getLogicalSwitchUuid());
    } catch (final NiciraNvpApiException e) {
        fail(e.getMessage());
    }
    final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, niciraNvpResource);
    assertTrue(answer.getResult());
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) DeleteLogicalSwitchCommand(com.cloud.legacymodel.communication.command.DeleteLogicalSwitchCommand) NiciraNvpApi(com.cloud.network.nicira.NiciraNvpApi) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) Test(org.junit.Test)

Example 4 with DeleteLogicalSwitchCommand

use of com.cloud.legacymodel.communication.command.DeleteLogicalSwitchCommand in project cosmic by MissionCriticalCloud.

the class NiciraNvpResourceTest method testDeleteLogicalSwitch.

@Test
public void testDeleteLogicalSwitch() throws ConfigurationException {
    resource.configure("NiciraNvpResource", parameters);
    final DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
    final DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) resource.executeRequest(dlsc);
    assertTrue(dlsa.getResult());
}
Also used : DeleteLogicalSwitchCommand(com.cloud.legacymodel.communication.command.DeleteLogicalSwitchCommand) DeleteLogicalSwitchAnswer(com.cloud.legacymodel.communication.answer.DeleteLogicalSwitchAnswer) Test(org.junit.Test)

Aggregations

DeleteLogicalSwitchCommand (com.cloud.legacymodel.communication.command.DeleteLogicalSwitchCommand)4 DeleteLogicalSwitchAnswer (com.cloud.legacymodel.communication.answer.DeleteLogicalSwitchAnswer)3 Test (org.junit.Test)3 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)2 HostVO (com.cloud.host.HostVO)1 Answer (com.cloud.legacymodel.communication.answer.Answer)1 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)1 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)1