use of com.cloud.network.nicira.NiciraNvpApiException in project cloudstack by apache.
the class NiciraNvpConfigurePublicIpsCommandWrapper method execute.
@Override
public Answer execute(final ConfigurePublicIpsOnLogicalRouterCommand command, final NiciraNvpResource niciraNvpResource) {
final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();
try {
final List<LogicalRouterPort> ports = niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(command.getLogicalRouterUuid(), command.getL3GatewayServiceUuid());
if (ports.size() != 1) {
return new ConfigurePublicIpsOnLogicalRouterAnswer(command, false, "No logical router ports found, unable to set ip addresses");
}
final LogicalRouterPort lrp = ports.get(0);
lrp.setIpAddresses(command.getPublicCidrs());
niciraNvpApi.updateLogicalRouterPort(command.getLogicalRouterUuid(), lrp);
return new ConfigurePublicIpsOnLogicalRouterAnswer(command, true, "Configured " + command.getPublicCidrs().size() + " ip addresses on logical router uuid " + command.getLogicalRouterUuid());
} catch (final NiciraNvpApiException e) {
final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility();
retryUtility.addRetry(command, NUM_RETRIES);
return retryUtility.retry(command, ConfigurePublicIpsOnLogicalRouterAnswer.class, e);
}
}
use of com.cloud.network.nicira.NiciraNvpApiException in project cloudstack by apache.
the class NiciraNvpResource method getCurrentStatus.
@Override
public PingCommand getCurrentStatus(final long id) {
try {
final ControlClusterStatus ccs = niciraNvpApi.getControlClusterStatus();
getApiProviderMajorityVersion(ccs);
if (!"stable".equals(ccs.getClusterStatus())) {
s_logger.error("ControlCluster state is not stable: " + ccs.getClusterStatus());
return null;
}
} catch (final NiciraNvpApiException e) {
s_logger.error("getControlClusterStatus failed", e);
return null;
}
return new PingCommand(Host.Type.L2Networking, id);
}
use of com.cloud.network.nicira.NiciraNvpApiException in project cloudstack by apache.
the class NiciraNvpResourceTest method testFindLogicalSwitchPortApiException.
@Test
public void testFindLogicalSwitchPortApiException() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
when(nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenThrow(new NiciraNvpApiException());
final FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
assertFalse(flspa.getResult());
}
use of com.cloud.network.nicira.NiciraNvpApiException 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());
}
use of com.cloud.network.nicira.NiciraNvpApiException in project cloudstack by apache.
the class NiciraNvpResourceTest method testRetries.
@Test
public void testRetries() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
final LogicalSwitch ls = mock(LogicalSwitch.class);
when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
when(nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException()).thenThrow(new NiciraNvpApiException()).thenReturn(ls);
final CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String) parameters.get("guid"), "stt", "loigicalswitch", "owner");
final CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) resource.executeRequest(clsc);
assertTrue(clsa.getResult());
}
Aggregations