use of com.cloud.agent.api.FindLogicalRouterPortAnswer in project cloudstack by apache.
the class NiciraNvpGuestNetworkGuru method sharedNetworksCleanup.
private void sharedNetworksCleanup(NetworkVO networkObject, String logicalSwitchUuid, HostVO niciraNvpHost) {
NiciraNvpRouterMappingVO routermapping = niciraNvpRouterMappingDao.findByNetworkId(networkObject.getId());
if (routermapping == null) {
// Case 1: Numerical Vlan Provided -> No lrouter used.
s_logger.info("Shared Network " + networkObject.getDisplayText() + " didn't use Logical Router");
} else {
//Case 2: Logical Router's UUID provided as Vlan id -> Remove lrouter port but not lrouter.
String lRouterUuid = routermapping.getLogicalRouterUuid();
s_logger.debug("Finding Logical Router Port on Logical Router " + lRouterUuid + " with attachment_lswitch_uuid=" + logicalSwitchUuid + " to delete it");
final FindLogicalRouterPortCommand cmd = new FindLogicalRouterPortCommand(lRouterUuid, logicalSwitchUuid);
final FindLogicalRouterPortAnswer answer = (FindLogicalRouterPortAnswer) agentMgr.easySend(niciraNvpHost.getId(), cmd);
if (answer != null && answer.getResult()) {
String logicalRouterPortUuid = answer.getLogicalRouterPortUuid();
s_logger.debug("Found Logical Router Port " + logicalRouterPortUuid + ", deleting it");
final DeleteLogicalRouterPortCommand cmdDeletePort = new DeleteLogicalRouterPortCommand(lRouterUuid, logicalRouterPortUuid);
final DeleteLogicalRouterPortAnswer answerDelete = (DeleteLogicalRouterPortAnswer) agentMgr.easySend(niciraNvpHost.getId(), cmdDeletePort);
if (answerDelete != null && answerDelete.getResult()) {
s_logger.info("Successfully deleted Logical Router Port " + logicalRouterPortUuid);
} else {
s_logger.error("Could not delete Logical Router Port " + logicalRouterPortUuid);
}
} else {
s_logger.error("Find Logical Router Port failed");
}
}
}
use of com.cloud.agent.api.FindLogicalRouterPortAnswer 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);
}
}
Aggregations