Search in sources :

Example 11 with LoadBalancingRule

use of com.cloud.legacymodel.network.LoadBalancingRule in project cosmic by MissionCriticalCloud.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final FirewallRules firewall) throws ResourceUnavailableException {
    final Network network = firewall.getNetwork();
    final DomainRouterVO router = (DomainRouterVO) firewall.getRouter();
    final List<? extends FirewallRule> rules = firewall.getRules();
    final List<LoadBalancingRule> loadbalancingRules = firewall.getLoadbalancingRules();
    final Purpose purpose = firewall.getPurpose();
    final Commands cmds = new Commands(Command.OnError.Continue);
    _commandSetupHelper.createPublicIpACLsCommands(router, cmds);
    if (purpose == Purpose.LoadBalancing) {
        _commandSetupHelper.createApplyLoadBalancingRulesCommands(loadbalancingRules, router, cmds, network.getId());
        return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
    } else if (purpose == Purpose.PortForwarding) {
        _commandSetupHelper.createApplyPortForwardingRulesCommands((List<? extends PortForwardingRule>) rules, router, cmds, network.getId());
        return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
    } else if (purpose == Purpose.StaticNat) {
        _commandSetupHelper.createApplyStaticNatRulesCommands((List<StaticNatRule>) rules, router, cmds, network.getId());
        return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
    } else if (purpose == Purpose.Firewall) {
        _commandSetupHelper.createApplyFirewallRulesCommands(rules, router, cmds, network.getId());
        return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
    }
    s_logger.warn("Unable to apply rules of purpose: " + rules.get(0).getPurpose());
    return false;
}
Also used : LoadBalancingRule(com.cloud.legacymodel.network.LoadBalancingRule) Network(com.cloud.legacymodel.network.Network) Commands(com.cloud.agent.manager.Commands) Purpose(com.cloud.legacymodel.network.FirewallRule.Purpose) List(java.util.List) StaticNatRule(com.cloud.legacymodel.network.StaticNatRule) PortForwardingRule(com.cloud.legacymodel.network.PortForwardingRule) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 12 with LoadBalancingRule

use of com.cloud.legacymodel.network.LoadBalancingRule in project cosmic by MissionCriticalCloud.

the class BasicNetworkVisitor method visit.

@Override
public boolean visit(final LoadBalancingRules loadbalancing) throws ResourceUnavailableException {
    final Network network = loadbalancing.getNetwork();
    final DomainRouterVO router = (DomainRouterVO) loadbalancing.getRouter();
    final List<LoadBalancingRule> rules = loadbalancing.getRules();
    final Commands cmds = new Commands(Command.OnError.Continue);
    _commandSetupHelper.createApplyLoadBalancingRulesCommands(rules, router, cmds, network.getId());
    _commandSetupHelper.createPublicIpACLsCommands(router, cmds);
    return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
}
Also used : LoadBalancingRule(com.cloud.legacymodel.network.LoadBalancingRule) Network(com.cloud.legacymodel.network.Network) Commands(com.cloud.agent.manager.Commands) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Aggregations

LoadBalancingRule (com.cloud.legacymodel.network.LoadBalancingRule)12 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)8 Ip (com.cloud.legacymodel.network.Ip)7 LbDestination (com.cloud.legacymodel.network.LoadBalancingRule.LbDestination)6 LbStickinessPolicy (com.cloud.legacymodel.network.LoadBalancingRule.LbStickinessPolicy)6 LbHealthCheckPolicy (com.cloud.legacymodel.network.LoadBalancingRule.LbHealthCheckPolicy)5 PublicIp (com.cloud.network.addr.PublicIp)5 ArrayList (java.util.ArrayList)5 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)4 LbSslCert (com.cloud.legacymodel.network.LoadBalancingRule.LbSslCert)4 Network (com.cloud.legacymodel.network.Network)4 DB (com.cloud.utils.db.DB)4 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)3 ResourceUnavailableException (com.cloud.legacymodel.exceptions.ResourceUnavailableException)3 Commands (com.cloud.agent.manager.Commands)2 ActionEvent (com.cloud.event.ActionEvent)2 InsufficientAddressCapacityException (com.cloud.legacymodel.exceptions.InsufficientAddressCapacityException)2 NetworkRuleConflictException (com.cloud.legacymodel.exceptions.NetworkRuleConflictException)2 PermissionDeniedException (com.cloud.legacymodel.exceptions.PermissionDeniedException)2 Nic (com.cloud.legacymodel.network.Nic)2