Search in sources :

Example 6 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 7 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 8 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)

Aggregations

LogicalRouterPort (com.cloud.network.nicira.LogicalRouterPort)8 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)7 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)5 LogicalSwitchPort (com.cloud.network.nicira.LogicalSwitchPort)4 CommandRetryUtility (com.cloud.network.utils.CommandRetryUtility)4 Test (org.junit.Test)4 CreateLogicalRouterAnswer (com.cloud.agent.api.CreateLogicalRouterAnswer)3 LogicalRouter (com.cloud.network.nicira.LogicalRouter)3 ArrayList (java.util.ArrayList)3 ConfigurePublicIpsOnLogicalRouterAnswer (com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer)2 ConfigurePublicIpsOnLogicalRouterCommand (com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand)2 CreateLogicalRouterCommand (com.cloud.agent.api.CreateLogicalRouterCommand)2 NiciraNvpTag (com.cloud.network.nicira.NiciraNvpTag)2 PatchAttachment (com.cloud.network.nicira.PatchAttachment)2 Answer (com.cloud.agent.api.Answer)1 ConfigureSharedNetworkUuidAnswer (com.cloud.agent.api.ConfigureSharedNetworkUuidAnswer)1 FindLogicalRouterPortAnswer (com.cloud.agent.api.FindLogicalRouterPortAnswer)1 L3GatewayAttachment (com.cloud.network.nicira.L3GatewayAttachment)1 LogicalSwitch (com.cloud.network.nicira.LogicalSwitch)1 Match (com.cloud.network.nicira.Match)1