use of com.cloud.common.virtualnetwork.lb.HAProxyConfigurator in project cosmic by MissionCriticalCloud.
the class HAProxyConfiguratorTest method testGenerateConfigurationLoadBalancerConfigCommand.
/**
* Test method for {@link HAProxyConfigurator#generateConfiguration(LoadBalancerConfigCommand)}.
*/
@Test
public void testGenerateConfigurationLoadBalancerConfigCommand() {
final LoadBalancerTO lb = new LoadBalancerTO("1", "10.2.0.1", 80, "http", "bla", false, false, false, null, 60000, 60000);
final LoadBalancerTO[] lba = new LoadBalancerTO[1];
lba[0] = lb;
final HAProxyConfigurator hpg = new HAProxyConfigurator();
LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lba, "10.0.0.1", "10.1.0.1", "10.1.1.1", null, 1L, "12", false);
String result = genConfig(hpg, cmd);
assertTrue("keepalive disabled should result in 'mode http' in the resulting haproxy config", result.contains("mode http"));
cmd = new LoadBalancerConfigCommand(lba, "10.0.0.1", "10.1.0.1", "10.1.1.1", null, 1L, "4", true);
result = genConfig(hpg, cmd);
assertTrue("keepalive enabled should not result in 'mode http' in the resulting haproxy config", !result.contains("mode http"));
// TODO
// create lb command
// setup tests for
// maxconn (test for maxpipes as well)
// httpmode
}
use of com.cloud.common.virtualnetwork.lb.HAProxyConfigurator 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);
}
use of com.cloud.common.virtualnetwork.lb.HAProxyConfigurator in project cosmic by MissionCriticalCloud.
the class HAProxyConfiguratorTest method testGenerateConfigurationLoadBalancerProxyProtocolConfigCommand.
/**
* Test method for {@link HAProxyConfigurator#generateConfiguration(LoadBalancerConfigCommand)}.
*/
@Test
public void testGenerateConfigurationLoadBalancerProxyProtocolConfigCommand() {
final List<LbDestination> dests = new ArrayList<>();
dests.add(new LbDestination(443, 8443, "10.1.10.2", false));
dests.add(new LbDestination(443, 8443, "10.1.10.2", true));
final LoadBalancerTO lb = new LoadBalancerTO("1", "10.2.0.1", 443, "tcp", "http", false, false, false, dests, 60000, 60000);
lb.setLbProtocol("tcp-proxy");
final LoadBalancerTO[] lba = new LoadBalancerTO[1];
lba[0] = lb;
final HAProxyConfigurator hpg = new HAProxyConfigurator();
final LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lba, "10.0.0.1", "10.1.0.1", "10.1.1.1", null, 1L, "12", false);
final String result = genConfig(hpg, cmd);
assertTrue("'send-proxy' should result if protocol is 'tcp-proxy'", result.contains("send-proxy"));
}
Aggregations