Search in sources :

Example 1 with DeleteLogicalRouterPortAnswer

use of com.cloud.agent.api.DeleteLogicalRouterPortAnswer in project cloudstack by apache.

the class NiciraNvpDeleteLogicalRouterPortCommandWrapper method execute.

@Override
public Answer execute(DeleteLogicalRouterPortCommand command, NiciraNvpResource niciraNvpResource) {
    final String logicalRouterUuid = command.getLogicalRouterUuid();
    final String logicalRouterPortUuid = command.getLogicalRouterPortUuid();
    final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();
    s_logger.debug("Deleting Logical Router Port " + logicalRouterPortUuid + " in Logical Router " + logicalRouterUuid);
    try {
        niciraNvpApi.deleteLogicalRouterPort(logicalRouterUuid, logicalRouterPortUuid);
        return new DeleteLogicalRouterPortAnswer(command, true, "Logical Router Port " + logicalRouterPortUuid + " deleted");
    } catch (NiciraNvpApiException e) {
        final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility();
        retryUtility.addRetry(command, NUM_RETRIES);
        return retryUtility.retry(command, DeleteLogicalRouterPortAnswer.class, e);
    }
}
Also used : DeleteLogicalRouterPortAnswer(com.cloud.agent.api.DeleteLogicalRouterPortAnswer) NiciraNvpApi(com.cloud.network.nicira.NiciraNvpApi) CommandRetryUtility(com.cloud.network.utils.CommandRetryUtility) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException)

Example 2 with DeleteLogicalRouterPortAnswer

use of com.cloud.agent.api.DeleteLogicalRouterPortAnswer 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");
        }
    }
}
Also used : DeleteLogicalRouterPortAnswer(com.cloud.agent.api.DeleteLogicalRouterPortAnswer) NiciraNvpRouterMappingVO(com.cloud.network.NiciraNvpRouterMappingVO) FindLogicalRouterPortAnswer(com.cloud.agent.api.FindLogicalRouterPortAnswer) FindLogicalRouterPortCommand(com.cloud.agent.api.FindLogicalRouterPortCommand) DeleteLogicalRouterPortCommand(com.cloud.agent.api.DeleteLogicalRouterPortCommand)

Aggregations

DeleteLogicalRouterPortAnswer (com.cloud.agent.api.DeleteLogicalRouterPortAnswer)2 DeleteLogicalRouterPortCommand (com.cloud.agent.api.DeleteLogicalRouterPortCommand)1 FindLogicalRouterPortAnswer (com.cloud.agent.api.FindLogicalRouterPortAnswer)1 FindLogicalRouterPortCommand (com.cloud.agent.api.FindLogicalRouterPortCommand)1 NiciraNvpRouterMappingVO (com.cloud.network.NiciraNvpRouterMappingVO)1 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)1 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)1 CommandRetryUtility (com.cloud.network.utils.CommandRetryUtility)1