Search in sources :

Example 11 with NiciraNvpRouterMappingVO

use of com.cloud.network.NiciraNvpRouterMappingVO in project cloudstack by apache.

the class NiciraNvpElement method shutdown.

@Override
public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
    if (!canHandle(network, Service.Connectivity)) {
        return false;
    }
    List<NiciraNvpDeviceVO> devices = niciraNvpDao.listByPhysicalNetwork(network.getPhysicalNetworkId());
    if (devices.isEmpty()) {
        s_logger.error("No NiciraNvp Controller on physical network " + network.getPhysicalNetworkId());
        return false;
    }
    NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
    HostVO niciraNvpHost = hostDao.findById(niciraNvpDevice.getHostId());
    //Dont destroy logical router when removing Shared Networks
    if (!network.getGuestType().equals(GuestType.Shared) && networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
        s_logger.debug("Apparently we were providing SourceNat on this network");
        // Deleting the LogicalRouter will also take care of all provisioned
        // nat rules.
        NiciraNvpRouterMappingVO routermapping = niciraNvpRouterMappingDao.findByNetworkId(network.getId());
        if (routermapping == null) {
            s_logger.warn("No logical router uuid found for network " + network.getDisplayText());
            // This might be cause by a failed deployment, so don't make shutdown fail as well.
            return true;
        }
        DeleteLogicalRouterCommand cmd = new DeleteLogicalRouterCommand(routermapping.getLogicalRouterUuid());
        DeleteLogicalRouterAnswer answer = (DeleteLogicalRouterAnswer) agentMgr.easySend(niciraNvpHost.getId(), cmd);
        if (answer.getResult() == false) {
            s_logger.error("Failed to delete LogicalRouter for network " + network.getDisplayText());
            return false;
        }
        niciraNvpRouterMappingDao.remove(routermapping.getId());
    }
    return true;
}
Also used : DeleteLogicalRouterAnswer(com.cloud.agent.api.DeleteLogicalRouterAnswer) NiciraNvpRouterMappingVO(com.cloud.network.NiciraNvpRouterMappingVO) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) HostVO(com.cloud.host.HostVO) DeleteLogicalRouterCommand(com.cloud.agent.api.DeleteLogicalRouterCommand)

Aggregations

NiciraNvpRouterMappingVO (com.cloud.network.NiciraNvpRouterMappingVO)11 HostVO (com.cloud.host.HostVO)7 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)7 PublicIpAddress (com.cloud.network.PublicIpAddress)4 ArrayList (java.util.ArrayList)4 ConfigurePublicIpsOnLogicalRouterAnswer (com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer)2 ConfigurePublicIpsOnLogicalRouterCommand (com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand)2 ConfigureSharedNetworkUuidAnswer (com.cloud.agent.api.ConfigureSharedNetworkUuidAnswer)2 IpAddress (com.cloud.network.IpAddress)2 Network (com.cloud.network.Network)2 PublicIp (com.cloud.network.addr.PublicIp)2 NetworkOffering (com.cloud.offering.NetworkOffering)2 Account (com.cloud.user.Account)2 Test (org.junit.Test)2 ConfigurePortForwardingRulesOnLogicalRouterAnswer (com.cloud.agent.api.ConfigurePortForwardingRulesOnLogicalRouterAnswer)1 ConfigurePortForwardingRulesOnLogicalRouterCommand (com.cloud.agent.api.ConfigurePortForwardingRulesOnLogicalRouterCommand)1 ConfigureSharedNetworkUuidCommand (com.cloud.agent.api.ConfigureSharedNetworkUuidCommand)1 ConfigureStaticNatRulesOnLogicalRouterAnswer (com.cloud.agent.api.ConfigureStaticNatRulesOnLogicalRouterAnswer)1 ConfigureStaticNatRulesOnLogicalRouterCommand (com.cloud.agent.api.ConfigureStaticNatRulesOnLogicalRouterCommand)1 CreateLogicalRouterAnswer (com.cloud.agent.api.CreateLogicalRouterAnswer)1