Search in sources :

Example 1 with DeleteLogicalSwitchCommand

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

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.agent.api.DeleteLogicalSwitchCommand) DeleteLogicalSwitchAnswer(com.cloud.agent.api.DeleteLogicalSwitchAnswer) Test(org.junit.Test)

Example 2 with DeleteLogicalSwitchCommand

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

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.agent.api.DeleteLogicalSwitchCommand) DeleteLogicalSwitchAnswer(com.cloud.agent.api.DeleteLogicalSwitchAnswer) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) Test(org.junit.Test)

Example 3 with DeleteLogicalSwitchCommand

use of com.cloud.agent.api.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.agent.api.DeleteLogicalSwitchCommand) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) DeleteLogicalSwitchAnswer(com.cloud.agent.api.DeleteLogicalSwitchAnswer) HostVO(com.cloud.host.HostVO)

Example 4 with DeleteLogicalSwitchCommand

use of com.cloud.agent.api.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.agent.api.DeleteLogicalSwitchCommand) DeleteLogicalSwitchAnswer(com.cloud.agent.api.DeleteLogicalSwitchAnswer) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) Test(org.junit.Test)

Example 5 with DeleteLogicalSwitchCommand

use of com.cloud.agent.api.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.agent.api.Answer) DeleteLogicalSwitchCommand(com.cloud.agent.api.DeleteLogicalSwitchCommand) NiciraNvpApi(com.cloud.network.nicira.NiciraNvpApi) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) Test(org.junit.Test)

Aggregations

DeleteLogicalSwitchCommand (com.cloud.agent.api.DeleteLogicalSwitchCommand)8 DeleteLogicalSwitchAnswer (com.cloud.agent.api.DeleteLogicalSwitchAnswer)6 Test (org.junit.Test)6 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)4 Answer (com.cloud.agent.api.Answer)2 HostVO (com.cloud.host.HostVO)2 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)2 NetworkVO (com.cloud.network.dao.NetworkVO)2 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)2 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)2