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());
}
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"));
}
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());
}
Aggregations