use of com.cloud.legacymodel.network.LoadBalancingRule.LbDestination in project cosmic by MissionCriticalCloud.
the class ConfigHelperTest method generateLoadBalancerConfigCommand.
protected LoadBalancerConfigCommand generateLoadBalancerConfigCommand() {
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, 60000, 60000));
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, this.ROUTERNAME);
return cmd;
}
use of com.cloud.legacymodel.network.LoadBalancingRule.LbDestination 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"));
}
use of com.cloud.legacymodel.network.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.legacymodel.network.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;
}
Aggregations