Search in sources :

Example 11 with LogicalRouterPort

use of com.cloud.network.nicira.LogicalRouterPort in project cloudstack by apache.

the class NiciraNvpResourceTest method testCreateLogicalRouter.

@Test
public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    final LogicalRouter lrc = mock(LogicalRouter.class);
    final LogicalRouterPort lrp = mock(LogicalRouterPort.class);
    final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
    when(lrc.getUuid()).thenReturn("ccccc");
    when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
    when(lsp.getUuid()).thenReturn("fffff");
    when(nvpApi.createLogicalRouter((LogicalRouter) any())).thenReturn(lrc);
    when(nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort) any())).thenReturn(lrp);
    when(nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort) any())).thenReturn(lsp);
    final CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
    final CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) resource.executeRequest(clrc);
    assertTrue(clra.getResult());
    assertTrue("ccccc".equals(clra.getLogicalRouterUuid()));
    verify(nvpApi, atLeast(1)).createLogicalRouterNatRule((String) any(), (NatRule) any());
}
Also used : CreateLogicalRouterCommand(com.cloud.agent.api.CreateLogicalRouterCommand) LogicalRouterPort(com.cloud.network.nicira.LogicalRouterPort) LogicalRouter(com.cloud.network.nicira.LogicalRouter) CreateLogicalRouterAnswer(com.cloud.agent.api.CreateLogicalRouterAnswer) LogicalSwitchPort(com.cloud.network.nicira.LogicalSwitchPort) Test(org.junit.Test)

Example 12 with LogicalRouterPort

use of com.cloud.network.nicira.LogicalRouterPort in project cloudstack by apache.

the class NiciraNvpResourceTest method testConfigurePublicIpsOnLogicalRouterApiException.

@Test
public void testConfigurePublicIpsOnLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    final ConfigurePublicIpsOnLogicalRouterCommand cmd = mock(ConfigurePublicIpsOnLogicalRouterCommand.class);
    @SuppressWarnings("unchecked") final List<LogicalRouterPort> list = Collections.EMPTY_LIST;
    when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
    when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
    when(nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa", "bbbbb")).thenReturn(list);
    doThrow(new NiciraNvpApiException()).when(nvpApi).updateLogicalRouterPort((String) any(), (LogicalRouterPort) any());
    final ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer) resource.executeRequest(cmd);
    assertFalse(answer.getResult());
}
Also used : LogicalRouterPort(com.cloud.network.nicira.LogicalRouterPort) ConfigurePublicIpsOnLogicalRouterAnswer(com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) ConfigurePublicIpsOnLogicalRouterCommand(com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand) Test(org.junit.Test)

Example 13 with LogicalRouterPort

use of com.cloud.network.nicira.LogicalRouterPort in project cloudstack by apache.

the class NiciraNvpResourceTest method testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort.

@Test
public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    final LogicalRouter lrc = mock(LogicalRouter.class);
    final LogicalRouterPort lrp = mock(LogicalRouterPort.class);
    final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
    when(lrc.getUuid()).thenReturn("ccccc");
    when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
    when(lsp.getUuid()).thenReturn("fffff");
    when(nvpApi.createLogicalRouter((LogicalRouter) any())).thenReturn(lrc);
    when(nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort) any())).thenReturn(lrp);
    when(nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort) any())).thenReturn(lsp);
    when(nvpApi.createLogicalRouterNatRule((String) any(), (NatRule) any())).thenThrow(new NiciraNvpApiException());
    final CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
    final CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) resource.executeRequest(clrc);
    assertFalse(clra.getResult());
    verify(nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
    verify(nvpApi, atLeast(1)).deleteLogicalSwitchPort(eq("bbbbb"), eq("fffff"));
}
Also used : CreateLogicalRouterCommand(com.cloud.agent.api.CreateLogicalRouterCommand) LogicalRouterPort(com.cloud.network.nicira.LogicalRouterPort) LogicalRouter(com.cloud.network.nicira.LogicalRouter) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) CreateLogicalRouterAnswer(com.cloud.agent.api.CreateLogicalRouterAnswer) LogicalSwitchPort(com.cloud.network.nicira.LogicalSwitchPort) Test(org.junit.Test)

Example 14 with LogicalRouterPort

use of com.cloud.network.nicira.LogicalRouterPort in project cloudstack by apache.

the class NiciraNvpRequestWrapperTest method testConfigurePublicIpsOnLogicalRouterCommand.

@Test
public void testConfigurePublicIpsOnLogicalRouterCommand() {
    final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class);
    final LogicalRouterPort port1 = Mockito.mock(LogicalRouterPort.class);
    final List<LogicalRouterPort> listPorts = new ArrayList<LogicalRouterPort>();
    listPorts.add(port1);
    final String logicalRouterUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
    final String l3GatewayServiceUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
    final List<String> publicCidrs = new ArrayList<String>();
    publicCidrs.add("10.1.1.0/24");
    final ConfigurePublicIpsOnLogicalRouterCommand command = new ConfigurePublicIpsOnLogicalRouterCommand(logicalRouterUuid, l3GatewayServiceUuid, publicCidrs);
    when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi);
    try {
        when(niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(command.getLogicalRouterUuid(), command.getL3GatewayServiceUuid())).thenReturn(listPorts);
        doNothing().when(niciraNvpApi).updateLogicalRouterPort(command.getLogicalRouterUuid(), port1);
    } 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) LogicalRouterPort(com.cloud.network.nicira.LogicalRouterPort) NiciraNvpApi(com.cloud.network.nicira.NiciraNvpApi) ArrayList(java.util.ArrayList) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) ConfigurePublicIpsOnLogicalRouterCommand(com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand) Test(org.junit.Test)

Aggregations

LogicalRouterPort (com.cloud.network.nicira.LogicalRouterPort)14 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)12 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)8 Test (org.junit.Test)8 LogicalSwitchPort (com.cloud.network.nicira.LogicalSwitchPort)7 CreateLogicalRouterAnswer (com.cloud.agent.api.CreateLogicalRouterAnswer)6 LogicalRouter (com.cloud.network.nicira.LogicalRouter)6 CommandRetryUtility (com.cloud.network.utils.CommandRetryUtility)6 ArrayList (java.util.ArrayList)5 ConfigurePublicIpsOnLogicalRouterAnswer (com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer)4 ConfigurePublicIpsOnLogicalRouterCommand (com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand)4 CreateLogicalRouterCommand (com.cloud.agent.api.CreateLogicalRouterCommand)4 NiciraNvpTag (com.cloud.network.nicira.NiciraNvpTag)3 PatchAttachment (com.cloud.network.nicira.PatchAttachment)3 Answer (com.cloud.agent.api.Answer)2 L3GatewayAttachment (com.cloud.network.nicira.L3GatewayAttachment)2 Match (com.cloud.network.nicira.Match)2 RouterNextHop (com.cloud.network.nicira.RouterNextHop)2 SingleDefaultRouteImplicitRoutingConfig (com.cloud.network.nicira.SingleDefaultRouteImplicitRoutingConfig)2 SourceNatRule (com.cloud.network.nicira.SourceNatRule)2