Search in sources :

Example 21 with LogicalSwitchPort

use of com.cloud.network.nicira.LogicalSwitchPort 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 22 with LogicalSwitchPort

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

the class NiciraNvpResourceTest method testCreateLogicalSwitchPortApiExceptionInCreate.

@Test
public void testCreateLogicalSwitchPortApiExceptionInCreate() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
    when(lsp.getUuid()).thenReturn("eeee");
    when(nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenThrow(new NiciraNvpApiException());
    final CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
    final CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) resource.executeRequest(clspc);
    assertFalse(clspa.getResult());
}
Also used : CreateLogicalSwitchPortAnswer(com.cloud.agent.api.CreateLogicalSwitchPortAnswer) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) CreateLogicalSwitchPortCommand(com.cloud.agent.api.CreateLogicalSwitchPortCommand) LogicalSwitchPort(com.cloud.network.nicira.LogicalSwitchPort) Test(org.junit.Test)

Example 23 with LogicalSwitchPort

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

the class NiciraNvpResourceTest method testCreateLogicalSwitchPort.

@Test
public void testCreateLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
    when(lsp.getUuid()).thenReturn("eeee");
    when(nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp);
    final CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
    final CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) resource.executeRequest(clspc);
    assertTrue(clspa.getResult());
    assertTrue("eeee".equals(clspa.getLogicalSwitchPortUuid()));
}
Also used : CreateLogicalSwitchPortAnswer(com.cloud.agent.api.CreateLogicalSwitchPortAnswer) CreateLogicalSwitchPortCommand(com.cloud.agent.api.CreateLogicalSwitchPortCommand) LogicalSwitchPort(com.cloud.network.nicira.LogicalSwitchPort) Test(org.junit.Test)

Example 24 with LogicalSwitchPort

use of com.cloud.network.nicira.LogicalSwitchPort 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)

Aggregations

LogicalSwitchPort (com.cloud.network.nicira.LogicalSwitchPort)24 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)14 Test (org.junit.Test)14 CreateLogicalSwitchPortAnswer (com.cloud.agent.api.CreateLogicalSwitchPortAnswer)8 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)8 LogicalRouterPort (com.cloud.network.nicira.LogicalRouterPort)7 CommandRetryUtility (com.cloud.network.utils.CommandRetryUtility)7 CreateLogicalRouterAnswer (com.cloud.agent.api.CreateLogicalRouterAnswer)6 CreateLogicalSwitchPortCommand (com.cloud.agent.api.CreateLogicalSwitchPortCommand)6 FindLogicalSwitchPortAnswer (com.cloud.agent.api.FindLogicalSwitchPortAnswer)6 LogicalRouter (com.cloud.network.nicira.LogicalRouter)6 NiciraNvpTag (com.cloud.network.nicira.NiciraNvpTag)6 ArrayList (java.util.ArrayList)6 CreateLogicalRouterCommand (com.cloud.agent.api.CreateLogicalRouterCommand)4 FindLogicalSwitchPortCommand (com.cloud.agent.api.FindLogicalSwitchPortCommand)4 PatchAttachment (com.cloud.network.nicira.PatchAttachment)3 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