use of com.cloud.network.nicira.NiciraNvpApiException in project cloudstack by apache.
the class NiciraNvpFindL2GatewayServiceCommandWrapper method execute.
@Override
public Answer execute(FindL2GatewayServiceCommand command, NiciraNvpResource niciraNvpResource) {
final GatewayServiceConfig config = command.getGatewayServiceConfig();
final String uuid = config.getUuid();
final String type = config.getType();
final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();
s_logger.info("Looking for L2 Gateway Service " + uuid + " of type " + type);
try {
List<L2GatewayServiceConfig> lstGW = niciraNvpApi.findL2GatewayServiceByUuidAndType(uuid, type);
if (lstGW.size() == 0) {
return new FindL2GatewayServiceAnswer(command, false, "L2 Gateway Service not found", null);
} else {
return new FindL2GatewayServiceAnswer(command, true, "L2 Gateway Service " + lstGW.get(0).getDisplayName() + " found", lstGW.get(0).getUuid());
}
} catch (NiciraNvpApiException e) {
s_logger.error("Error finding Gateway Service due to: " + e.getMessage());
final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility();
retryUtility.addRetry(command, NUM_RETRIES);
return retryUtility.retry(command, FindL2GatewayServiceAnswer.class, e);
}
}
use of com.cloud.network.nicira.NiciraNvpApiException in project cloudstack by apache.
the class NiciraNvpFindLogicalRouterPortCommandWrapper method execute.
@Override
public Answer execute(FindLogicalRouterPortCommand command, NiciraNvpResource niciraNvpResource) {
final String logicalRouterUuid = command.getLogicalRouterUuid();
final String attachmentLswitchUuid = command.getAttachmentLswitchUuid();
final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();
s_logger.debug("Finding Logical Router Port in Logical Router " + logicalRouterUuid + " and attachmentLSwitchUuid " + attachmentLswitchUuid);
try {
List<LogicalRouterPort> lRouterPorts = niciraNvpApi.findLogicalRouterPortByAttachmentLSwitchUuid(logicalRouterUuid, attachmentLswitchUuid);
if (lRouterPorts.size() == 0) {
return new FindLogicalRouterPortAnswer(command, false, "Logical Router Port not found", null);
} else {
return new FindLogicalRouterPortAnswer(command, true, "Logical Router Port found", lRouterPorts.get(0).getUuid());
}
} catch (NiciraNvpApiException e) {
s_logger.error("Error finding Logical Router Port due to: " + e.getMessage());
final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility();
retryUtility.addRetry(command, NUM_RETRIES);
return retryUtility.retry(command, FindLogicalRouterPortAnswer.class, e);
}
}
use of com.cloud.network.nicira.NiciraNvpApiException in project cloudstack by apache.
the class NiciraNvpFindLogicalSwitchPortCommandWrapper method execute.
@Override
public Answer execute(final FindLogicalSwitchPortCommand command, final NiciraNvpResource niciraNvpResource) {
final String logicalSwitchUuid = command.getLogicalSwitchUuid();
final String logicalSwitchPortUuid = command.getLogicalSwitchPortUuid();
final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();
try {
final List<LogicalSwitchPort> ports = niciraNvpApi.findLogicalSwitchPortsByUuid(logicalSwitchUuid, logicalSwitchPortUuid);
if (ports.size() == 0) {
return new FindLogicalSwitchPortAnswer(command, false, "Logical switchport " + logicalSwitchPortUuid + " not found", null);
} else {
return new FindLogicalSwitchPortAnswer(command, true, "Logical switchport " + logicalSwitchPortUuid + " found", logicalSwitchPortUuid);
}
} catch (final NiciraNvpApiException e) {
final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility();
retryUtility.addRetry(command, NUM_RETRIES);
return retryUtility.retry(command, FindLogicalSwitchPortAnswer.class, e);
}
}
use of com.cloud.network.nicira.NiciraNvpApiException in project cloudstack by apache.
the class NiciraNvpRequestWrapperTest method testConfigurePublicIpsOnLogicalRouterCommand.
@Test
public void testConfigurePublicIpsOnLogicalRouterCommand() {
final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class);
final LogicalRouterPort port1 = Mockito.mock(LogicalRouterPort.class);
final List<LogicalRouterPort> listPorts = new ArrayList<LogicalRouterPort>();
listPorts.add(port1);
final String logicalRouterUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final String l3GatewayServiceUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final List<String> publicCidrs = new ArrayList<String>();
publicCidrs.add("10.1.1.0/24");
final ConfigurePublicIpsOnLogicalRouterCommand command = new ConfigurePublicIpsOnLogicalRouterCommand(logicalRouterUuid, l3GatewayServiceUuid, publicCidrs);
when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi);
try {
when(niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(command.getLogicalRouterUuid(), command.getL3GatewayServiceUuid())).thenReturn(listPorts);
doNothing().when(niciraNvpApi).updateLogicalRouterPort(command.getLogicalRouterUuid(), port1);
} catch (final NiciraNvpApiException e) {
fail(e.getMessage());
}
final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, niciraNvpResource);
assertTrue(answer.getResult());
}
use of com.cloud.network.nicira.NiciraNvpApiException in project cloudstack by apache.
the class NiciraNvpRequestWrapperTest method testDeleteLogicalRouterCommand.
@Test
public void testDeleteLogicalRouterCommand() {
final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class);
final String logicalRouterUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final DeleteLogicalRouterCommand command = new DeleteLogicalRouterCommand(logicalRouterUuid);
when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi);
try {
doNothing().when(niciraNvpApi).deleteLogicalRouter(command.getLogicalRouterUuid());
} catch (final NiciraNvpApiException e) {
fail(e.getMessage());
}
final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, niciraNvpResource);
assertTrue(answer.getResult());
}
Aggregations