use of com.cloud.agent.api.DeleteLogicalRouterCommand in project cloudstack by apache.
the class NiciraNvpResourceTest method testDeleteLogicalRouterApiException.
@Test
public void testDeleteLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
doThrow(new NiciraNvpApiException()).when(nvpApi).deleteLogicalRouter(eq("aaaaa"));
final DeleteLogicalRouterAnswer dlspa = (DeleteLogicalRouterAnswer) resource.executeRequest(new DeleteLogicalRouterCommand("aaaaa"));
assertFalse(dlspa.getResult());
}
use of com.cloud.agent.api.DeleteLogicalRouterCommand in project cloudstack by apache.
the class NiciraNvpRequestWrapperTest method testDeleteLogicalRouterCommand.
@Test
public void testDeleteLogicalRouterCommand() {
final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class);
final String logicalRouterUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final DeleteLogicalRouterCommand command = new DeleteLogicalRouterCommand(logicalRouterUuid);
when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi);
try {
doNothing().when(niciraNvpApi).deleteLogicalRouter(command.getLogicalRouterUuid());
} 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.agent.api.DeleteLogicalRouterCommand in project cloudstack by apache.
the class NiciraNvpElement method shutdown.
@Override
public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
if (!canHandle(network, Service.Connectivity)) {
return false;
}
List<NiciraNvpDeviceVO> devices = niciraNvpDao.listByPhysicalNetwork(network.getPhysicalNetworkId());
if (devices.isEmpty()) {
s_logger.error("No NiciraNvp Controller on physical network " + network.getPhysicalNetworkId());
return false;
}
NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
HostVO niciraNvpHost = hostDao.findById(niciraNvpDevice.getHostId());
//Dont destroy logical router when removing Shared Networks
if (!network.getGuestType().equals(GuestType.Shared) && networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
s_logger.debug("Apparently we were providing SourceNat on this network");
// Deleting the LogicalRouter will also take care of all provisioned
// nat rules.
NiciraNvpRouterMappingVO routermapping = niciraNvpRouterMappingDao.findByNetworkId(network.getId());
if (routermapping == null) {
s_logger.warn("No logical router uuid found for network " + network.getDisplayText());
// This might be cause by a failed deployment, so don't make shutdown fail as well.
return true;
}
DeleteLogicalRouterCommand cmd = new DeleteLogicalRouterCommand(routermapping.getLogicalRouterUuid());
DeleteLogicalRouterAnswer answer = (DeleteLogicalRouterAnswer) agentMgr.easySend(niciraNvpHost.getId(), cmd);
if (answer.getResult() == false) {
s_logger.error("Failed to delete LogicalRouter for network " + network.getDisplayText());
return false;
}
niciraNvpRouterMappingDao.remove(routermapping.getId());
}
return true;
}
Aggregations