use of com.cloud.network.lb.LoadBalancingRule.LbDestination in project cloudstack by apache.
the class HAProxyConfiguratorTest method testGenerateConfigurationLoadBalancerProxyProtocolConfigCommand.
/**
* Test method for {@link com.cloud.network.HAProxyConfigurator#generateConfiguration(com.cloud.agent.api.routing.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));
LoadBalancerTO lb = new LoadBalancerTO("1", "10.2.0.1", 443, "tcp", "http", false, false, false, dests);
lb.setLbProtocol("tcp-proxy");
LoadBalancerTO[] lba = new LoadBalancerTO[1];
lba[0] = lb;
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("'send-proxy' should result if protocol is 'tcp-proxy'", result.contains("send-proxy"));
}
use of com.cloud.network.lb.LoadBalancingRule.LbDestination in project cosmic by MissionCriticalCloud.
the class LoadBalancingRulesManagerImpl method getLoadBalancerRuleToApply.
private LoadBalancingRule getLoadBalancerRuleToApply(final LoadBalancerVO lb) {
final List<LbStickinessPolicy> policyList = getStickinessPolicies(lb.getId());
final Ip sourceIp = getSourceIp(lb);
final LbSslCert sslCert = getLbSslCert(lb.getId());
final LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, null, policyList, null, sourceIp, sslCert, lb.getLbProtocol());
final List<LbDestination> dstList = getExistingDestinations(lb.getId());
loadBalancing.setDestinations(dstList);
final List<LbHealthCheckPolicy> hcPolicyList = getHealthCheckPolicies(lb.getId());
loadBalancing.setHealthCheckPolicies(hcPolicyList);
return loadBalancing;
}
use of com.cloud.network.lb.LoadBalancingRule.LbDestination in project cosmic by MissionCriticalCloud.
the class LoadBalancingRulesManagerImpl method getExistingDestinations.
@Override
public List<LbDestination> getExistingDestinations(final long lbId) {
final List<LbDestination> dstList = new ArrayList<>();
final List<LoadBalancerVMMapVO> lbVmMaps = _lb2VmMapDao.listByLoadBalancerId(lbId);
final LoadBalancerVO lb = _lbDao.findById(lbId);
String dstIp = null;
for (final LoadBalancerVMMapVO lbVmMap : lbVmMaps) {
final UserVm vm = _vmDao.findById(lbVmMap.getInstanceId());
final Nic nic = _nicDao.findByInstanceIdAndNetworkIdIncludingRemoved(lb.getNetworkId(), vm.getId());
dstIp = lbVmMap.getInstanceIp() == null ? nic.getIPv4Address() : lbVmMap.getInstanceIp();
final LbDestination lbDst = new LbDestination(lb.getDefaultPortStart(), lb.getDefaultPortEnd(), dstIp, lbVmMap.isRevoke());
dstList.add(lbDst);
}
return dstList;
}
use of com.cloud.network.lb.LoadBalancingRule.LbDestination in project cloudstack by apache.
the class VirtualRoutingResourceTest method generateLoadBalancerConfigCommand1.
protected LoadBalancerConfigCommand generateLoadBalancerConfigCommand1() {
final List<LoadBalancerTO> lbs = new ArrayList<>();
final List<LbDestination> dests = new ArrayList<>();
dests.add(new LbDestination(80, 8080, "10.1.10.2", false));
dests.add(new LbDestination(80, 8080, "10.1.10.2", true));
lbs.add(new LoadBalancerTO(UUID.randomUUID().toString(), "64.10.1.10", 80, "tcp", "algo", false, false, false, dests));
final LoadBalancerTO[] arrayLbs = new LoadBalancerTO[lbs.size()];
lbs.toArray(arrayLbs);
final NicTO nic = new NicTO();
final LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, null, "1000", false);
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, "10.1.10.2");
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
return cmd;
}
use of com.cloud.network.lb.LoadBalancingRule.LbDestination in project cloudstack by apache.
the class VirtualRoutingResourceTest method generateLoadBalancerConfigCommand2.
protected LoadBalancerConfigCommand generateLoadBalancerConfigCommand2() {
final List<LoadBalancerTO> lbs = new ArrayList<>();
final List<LbDestination> dests = new ArrayList<>();
dests.add(new LbDestination(80, 8080, "10.1.10.2", false));
dests.add(new LbDestination(80, 8080, "10.1.10.2", true));
lbs.add(new LoadBalancerTO(UUID.randomUUID().toString(), "64.10.1.10", 80, "tcp", "algo", false, false, false, dests));
final LoadBalancerTO[] arrayLbs = new LoadBalancerTO[lbs.size()];
lbs.toArray(arrayLbs);
final NicTO nic = new NicTO();
nic.setIp("10.1.10.2");
final LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, Long.valueOf(1), "1000", false);
cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, "10.1.10.2");
cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
return cmd;
}
Aggregations