Search in sources :

Example 6 with LbDestination

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;
}
Also used : ArrayList(java.util.ArrayList) LoadBalancerTO(com.cloud.legacymodel.to.LoadBalancerTO) LbDestination(com.cloud.legacymodel.network.LoadBalancingRule.LbDestination) NicTO(com.cloud.legacymodel.to.NicTO) LoadBalancerConfigCommand(com.cloud.legacymodel.communication.command.LoadBalancerConfigCommand)

Example 7 with LbDestination

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"));
}
Also used : HAProxyConfigurator(com.cloud.common.virtualnetwork.lb.HAProxyConfigurator) ArrayList(java.util.ArrayList) LoadBalancerTO(com.cloud.legacymodel.to.LoadBalancerTO) LbDestination(com.cloud.legacymodel.network.LoadBalancingRule.LbDestination) LoadBalancerConfigCommand(com.cloud.legacymodel.communication.command.LoadBalancerConfigCommand) Test(org.junit.Test)

Example 8 with LbDestination

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;
}
Also used : LbSslCert(com.cloud.legacymodel.network.LoadBalancingRule.LbSslCert) LoadBalancingRule(com.cloud.legacymodel.network.LoadBalancingRule) Ip(com.cloud.legacymodel.network.Ip) PublicIp(com.cloud.network.addr.PublicIp) LbHealthCheckPolicy(com.cloud.legacymodel.network.LoadBalancingRule.LbHealthCheckPolicy) LbStickinessPolicy(com.cloud.legacymodel.network.LoadBalancingRule.LbStickinessPolicy) LbDestination(com.cloud.legacymodel.network.LoadBalancingRule.LbDestination)

Example 9 with LbDestination

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;
}
Also used : UserVm(com.cloud.uservm.UserVm) ArrayList(java.util.ArrayList) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) Nic(com.cloud.legacymodel.network.Nic) LoadBalancerVMMapVO(com.cloud.network.dao.LoadBalancerVMMapVO) LbDestination(com.cloud.legacymodel.network.LoadBalancingRule.LbDestination)

Aggregations

LbDestination (com.cloud.legacymodel.network.LoadBalancingRule.LbDestination)9 LoadBalancingRule (com.cloud.legacymodel.network.LoadBalancingRule)6 Ip (com.cloud.legacymodel.network.Ip)5 LbHealthCheckPolicy (com.cloud.legacymodel.network.LoadBalancingRule.LbHealthCheckPolicy)5 LbStickinessPolicy (com.cloud.legacymodel.network.LoadBalancingRule.LbStickinessPolicy)5 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)5 ArrayList (java.util.ArrayList)5 LbSslCert (com.cloud.legacymodel.network.LoadBalancingRule.LbSslCert)4 LoadBalancerTO (com.cloud.legacymodel.to.LoadBalancerTO)4 LoadBalancerConfigCommand (com.cloud.legacymodel.communication.command.LoadBalancerConfigCommand)3 Nic (com.cloud.legacymodel.network.Nic)3 PublicIp (com.cloud.network.addr.PublicIp)3 Network (com.cloud.legacymodel.network.Network)2 NetworkModel (com.cloud.network.NetworkModel)2 LoadBalancerDao (com.cloud.network.dao.LoadBalancerDao)2 LoadBalancerVMMapVO (com.cloud.network.dao.LoadBalancerVMMapVO)2 LoadBalancingRulesManager (com.cloud.network.lb.LoadBalancingRulesManager)2 UserVm (com.cloud.uservm.UserVm)2 HAProxyConfigurator (com.cloud.common.virtualnetwork.lb.HAProxyConfigurator)1 Zone (com.cloud.db.model.Zone)1