use of com.cloud.agent.api.FindLogicalRouterPortCommand 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");
}
}
}
Aggregations