Search in sources :

Example 21 with NiciraNvpApiException

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

the class NiciraNvpResourceTest method testCreateLogicalRouterApiException.

@Test
public void testCreateLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    when(nvpApi.createLogicalRouter((LogicalRouter) 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());
}
Also used : CreateLogicalRouterCommand(com.cloud.agent.api.CreateLogicalRouterCommand) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) CreateLogicalRouterAnswer(com.cloud.agent.api.CreateLogicalRouterAnswer) Test(org.junit.Test)

Example 22 with NiciraNvpApiException

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

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

the class NiciraNvpResourceTest method testConfigurePublicIpsOnLogicalRouterRetry.

@Test
public void testConfigurePublicIpsOnLogicalRouterRetry() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    final ConfigurePublicIpsOnLogicalRouterCommand cmd = mock(ConfigurePublicIpsOnLogicalRouterCommand.class);
    when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
    when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
    when(nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa", "bbbbb")).thenThrow(new NiciraNvpApiException("retry 1")).thenThrow(new NiciraNvpApiException("retry 2"));
    final ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer) resource.executeRequest(cmd);
    assertFalse(answer.getResult());
}
Also used : ConfigurePublicIpsOnLogicalRouterAnswer(com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) ConfigurePublicIpsOnLogicalRouterCommand(com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand) Test(org.junit.Test)

Example 24 with NiciraNvpApiException

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

the class NiciraNvpResourceTest method testDeleteLogicalSwitchPortException.

@Test
public void testDeleteLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    doThrow(new NiciraNvpApiException()).when(nvpApi).deleteLogicalSwitchPort((String) any(), (String) any());
    final DeleteLogicalSwitchPortAnswer dlspa = (DeleteLogicalSwitchPortAnswer) resource.executeRequest(new DeleteLogicalSwitchPortCommand("aaaa", "bbbb"));
    assertFalse(dlspa.getResult());
}
Also used : DeleteLogicalSwitchPortCommand(com.cloud.agent.api.DeleteLogicalSwitchPortCommand) DeleteLogicalSwitchPortAnswer(com.cloud.agent.api.DeleteLogicalSwitchPortAnswer) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) Test(org.junit.Test)

Example 25 with NiciraNvpApiException

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

the class NiciraNvpResourceTest method testCreateLogicalSwitchPortApiExceptionInModify.

@Test
public void testCreateLogicalSwitchPortApiExceptionInModify() 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);
    doThrow(new NiciraNvpApiException()).when(nvpApi).updateLogicalSwitchPortAttachment((String) any(), (String) any(), (Attachment) any());
    final CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
    final CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) resource.executeRequest(clspc);
    assertFalse(clspa.getResult());
    verify(nvpApi, atLeastOnce()).deleteLogicalSwitchPort((String) any(), (String) any());
}
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)

Aggregations

NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)39 Test (org.junit.Test)23 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)21 CommandRetryUtility (com.cloud.network.utils.CommandRetryUtility)13 LogicalSwitchPort (com.cloud.network.nicira.LogicalSwitchPort)8 ArrayList (java.util.ArrayList)8 LogicalRouterPort (com.cloud.network.nicira.LogicalRouterPort)7 Answer (com.cloud.agent.api.Answer)6 LogicalSwitch (com.cloud.network.nicira.LogicalSwitch)5 NiciraNvpTag (com.cloud.network.nicira.NiciraNvpTag)5 CreateLogicalRouterAnswer (com.cloud.agent.api.CreateLogicalRouterAnswer)4 NatRule (com.cloud.network.nicira.NatRule)4 ConfigurePublicIpsOnLogicalRouterAnswer (com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer)3 ConfigurePublicIpsOnLogicalRouterCommand (com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand)3 CreateLogicalRouterCommand (com.cloud.agent.api.CreateLogicalRouterCommand)3 CreateLogicalSwitchAnswer (com.cloud.agent.api.CreateLogicalSwitchAnswer)3 CreateLogicalSwitchCommand (com.cloud.agent.api.CreateLogicalSwitchCommand)3 CreateLogicalSwitchPortAnswer (com.cloud.agent.api.CreateLogicalSwitchPortAnswer)3 ControlClusterStatus (com.cloud.network.nicira.ControlClusterStatus)3 VifAttachment (com.cloud.network.nicira.VifAttachment)3