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);
}
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());
}
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());
}
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());
}
Aggregations