Search in sources :

Example 21 with LbDestination

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"));
}
Also used : ArrayList(java.util.ArrayList) LoadBalancerTO(com.cloud.agent.api.to.LoadBalancerTO) LbDestination(com.cloud.network.lb.LoadBalancingRule.LbDestination) LoadBalancerConfigCommand(com.cloud.agent.api.routing.LoadBalancerConfigCommand) Test(org.junit.Test)

Example 22 with LbDestination

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

Example 23 with LbDestination

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

Example 24 with LbDestination

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

Example 25 with LbDestination

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

Aggregations

LbDestination (com.cloud.network.lb.LoadBalancingRule.LbDestination)31 ArrayList (java.util.ArrayList)20 LoadBalancerTO (com.cloud.agent.api.to.LoadBalancerTO)16 LbStickinessPolicy (com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy)16 LoadBalancingRule (com.cloud.network.lb.LoadBalancingRule)15 LbHealthCheckPolicy (com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy)15 Ip (com.cloud.utils.net.Ip)14 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)13 LoadBalancerConfigCommand (com.cloud.agent.api.routing.LoadBalancerConfigCommand)12 LbSslCert (com.cloud.network.lb.LoadBalancingRule.LbSslCert)9 Nic (com.cloud.vm.Nic)9 PublicIp (com.cloud.network.addr.PublicIp)7 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)6 Network (com.cloud.network.Network)6 DataCenterVO (com.cloud.dc.DataCenterVO)5 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)5 HealthCheckLBConfigAnswer (com.cloud.agent.api.routing.HealthCheckLBConfigAnswer)4 NicTO (com.cloud.agent.api.to.NicTO)4 HostVO (com.cloud.host.HostVO)4 NetworkModel (com.cloud.network.NetworkModel)4