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);
}
Aggregations