Search in sources :

Example 1 with VpcIpAssociationRules

use of com.cloud.network.rules.VpcIpAssociationRules in project cosmic by MissionCriticalCloud.

the class AdvancedNetworkTopology method associatePublicIP.

@Override
public boolean associatePublicIP(final Network network, final List<? extends PublicIpAddress> ipAddresses, final VirtualRouter router) throws ResourceUnavailableException {
    if (ipAddresses == null || ipAddresses.isEmpty()) {
        s_logger.debug("No ip association rules to be applied for network " + network.getId());
        return true;
    }
    if (network.getVpcId() == null) {
        return super.associatePublicIP(network, ipAddresses, router);
    }
    s_logger.debug("APPLYING VPC IP RULES");
    final String typeString = "vpc ip association";
    final boolean isPodLevelException = false;
    final boolean failWhenDisconnect = false;
    final Long podId = null;
    final NicPlugInOutRules nicPlugInOutRules = new NicPlugInOutRules(network, ipAddresses);
    nicPlugInOutRules.accept(_advancedVisitor, router);
    final VpcIpAssociationRules ipAssociationRules = new VpcIpAssociationRules(network, ipAddresses);
    final boolean result = applyRules(network, router, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<>(ipAssociationRules));
    if (result) {
        _advancedVisitor.visit(nicPlugInOutRules);
    }
    return result;
}
Also used : NicPlugInOutRules(com.cloud.network.rules.NicPlugInOutRules) VpcIpAssociationRules(com.cloud.network.rules.VpcIpAssociationRules)

Example 2 with VpcIpAssociationRules

use of com.cloud.network.rules.VpcIpAssociationRules in project cloudstack by apache.

the class AdvancedNetworkTopology method associatePublicIP.

@Override
public boolean associatePublicIP(final Network network, final List<? extends PublicIpAddress> ipAddresses, final VirtualRouter router) throws ResourceUnavailableException {
    if (ipAddresses == null || ipAddresses.isEmpty()) {
        s_logger.debug("No ip association rules to be applied for network " + network.getId());
        return true;
    }
    if (network.getVpcId() == null) {
        return super.associatePublicIP(network, ipAddresses, router);
    }
    s_logger.debug("APPLYING VPC IP RULES");
    final String typeString = "vpc ip association";
    final boolean isPodLevelException = false;
    final boolean failWhenDisconnect = false;
    final Long podId = null;
    final NicPlugInOutRules nicPlugInOutRules = new NicPlugInOutRules(network, ipAddresses);
    nicPlugInOutRules.accept(_advancedVisitor, router);
    final VpcIpAssociationRules ipAssociationRules = new VpcIpAssociationRules(network, ipAddresses);
    final boolean result = applyRules(network, router, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(ipAssociationRules));
    if (result) {
        if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
            s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending NicPlugInOutRules command to the backend");
        } else {
            _advancedVisitor.visit(nicPlugInOutRules);
        }
    }
    return result;
}
Also used : NicPlugInOutRules(com.cloud.network.rules.NicPlugInOutRules) RuleApplier(com.cloud.network.rules.RuleApplier) VpcIpAssociationRules(com.cloud.network.rules.VpcIpAssociationRules)

Aggregations

NicPlugInOutRules (com.cloud.network.rules.NicPlugInOutRules)2 VpcIpAssociationRules (com.cloud.network.rules.VpcIpAssociationRules)2 RuleApplier (com.cloud.network.rules.RuleApplier)1