Search in sources :

Example 1 with DeleteLogicalRouterCommand

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());
}
Also used : DeleteLogicalRouterAnswer(com.cloud.agent.api.DeleteLogicalRouterAnswer) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) DeleteLogicalRouterCommand(com.cloud.agent.api.DeleteLogicalRouterCommand) Test(org.junit.Test)

Example 2 with DeleteLogicalRouterCommand

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());
}
Also used : Answer(com.cloud.agent.api.Answer) NiciraNvpApi(com.cloud.network.nicira.NiciraNvpApi) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) DeleteLogicalRouterCommand(com.cloud.agent.api.DeleteLogicalRouterCommand) Test(org.junit.Test)

Example 3 with DeleteLogicalRouterCommand

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;
}
Also used : DeleteLogicalRouterAnswer(com.cloud.agent.api.DeleteLogicalRouterAnswer) NiciraNvpRouterMappingVO(com.cloud.network.NiciraNvpRouterMappingVO) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) HostVO(com.cloud.host.HostVO) DeleteLogicalRouterCommand(com.cloud.agent.api.DeleteLogicalRouterCommand)

Aggregations

DeleteLogicalRouterCommand (com.cloud.agent.api.DeleteLogicalRouterCommand)3 DeleteLogicalRouterAnswer (com.cloud.agent.api.DeleteLogicalRouterAnswer)2 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)2 Test (org.junit.Test)2 Answer (com.cloud.agent.api.Answer)1 HostVO (com.cloud.host.HostVO)1 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)1 NiciraNvpRouterMappingVO (com.cloud.network.NiciraNvpRouterMappingVO)1 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)1