Search in sources :

Example 1 with LoadBalancerConfigurator

use of com.cloud.common.virtualnetwork.lb.LoadBalancerConfigurator in project cosmic by MissionCriticalCloud.

the class LoadBalancerConfigItem method generateConfig.

@Override
public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) {
    final LoadBalancerConfigCommand command = (LoadBalancerConfigCommand) cmd;
    final LoadBalancerConfigurator cfgtr = new HAProxyConfigurator();
    final String[] configuration = cfgtr.generateConfiguration(command);
    String routerIp = command.getNic().getIp();
    if (command.getVpcId() == null) {
        routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
    }
    final String tmpCfgFilePath = "/etc/haproxy/";
    final String tmpCfgFileName = "haproxy.cfg.new." + String.valueOf(System.currentTimeMillis());
    final String[][] allRules = cfgtr.generateFwRules(command);
    final String[] addRules = allRules[LoadBalancerConfigurator.ADD];
    final String[] removeRules = allRules[LoadBalancerConfigurator.REMOVE];
    final String[] statRules = allRules[LoadBalancerConfigurator.STATS];
    final LoadBalancerRule loadBalancerRule = new LoadBalancerRule(configuration, tmpCfgFilePath, tmpCfgFileName, addRules, removeRules, statRules, routerIp);
    final List<LoadBalancerRule> rules = new LinkedList<>();
    rules.add(loadBalancerRule);
    final LoadBalancerRules configRules = new LoadBalancerRules(rules);
    return generateConfigItems(configRules);
}
Also used : HAProxyConfigurator(com.cloud.common.virtualnetwork.lb.HAProxyConfigurator) LoadBalancerRule(com.cloud.legacymodel.network.rules.LoadBalancerRule) LoadBalancerRules(com.cloud.legacymodel.network.rules.LoadBalancerRules) LoadBalancerConfigurator(com.cloud.common.virtualnetwork.lb.LoadBalancerConfigurator) LinkedList(java.util.LinkedList) LoadBalancerConfigCommand(com.cloud.legacymodel.communication.command.LoadBalancerConfigCommand)

Aggregations

HAProxyConfigurator (com.cloud.common.virtualnetwork.lb.HAProxyConfigurator)1 LoadBalancerConfigurator (com.cloud.common.virtualnetwork.lb.LoadBalancerConfigurator)1 LoadBalancerConfigCommand (com.cloud.legacymodel.communication.command.LoadBalancerConfigCommand)1 LoadBalancerRule (com.cloud.legacymodel.network.rules.LoadBalancerRule)1 LoadBalancerRules (com.cloud.legacymodel.network.rules.LoadBalancerRules)1 LinkedList (java.util.LinkedList)1