Search in sources :

Example 6 with LbSslCert

use of com.cloud.network.lb.LoadBalancingRule.LbSslCert in project cloudstack by apache.

the class ElasticLoadBalancerManagerImpl method applyLoadBalancerRules.

@Override
public boolean applyLoadBalancerRules(Network network, List<LoadBalancingRule> rules) throws ResourceUnavailableException {
    if (rules == null || rules.isEmpty()) {
        return true;
    }
    DomainRouterVO elbVm = findElbVmForLb(rules.get(0));
    if (elbVm == null) {
        s_logger.warn("Unable to apply lb rules, ELB vm  doesn't exist in the network " + network.getId());
        throw new ResourceUnavailableException("Unable to apply lb rules", DataCenter.class, network.getDataCenterId());
    }
    if (elbVm.getState() == State.Running) {
        //resend all rules for the public ip
        long sourceIpId = _networkModel.getPublicIpAddress(rules.get(0).getSourceIp().addr(), network.getDataCenterId()).getId();
        List<LoadBalancerVO> lbs = _lbDao.listByIpAddress(sourceIpId);
        List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
        for (LoadBalancerVO lb : lbs) {
            List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
            List<LbStickinessPolicy> policyList = _lbMgr.getStickinessPolicies(lb.getId());
            List<LbHealthCheckPolicy> hcPolicyList = _lbMgr.getHealthCheckPolicies(lb.getId());
            Ip sourceIp = _networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
            LbSslCert sslCert = _lbMgr.getLbSslCert(lb.getId());
            LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList, policyList, hcPolicyList, sourceIp, sslCert, lb.getLbProtocol());
            lbRules.add(loadBalancing);
        }
        return applyLBRules(elbVm, lbRules, network.getId());
    } else if (elbVm.getState() == State.Stopped || elbVm.getState() == State.Stopping) {
        s_logger.debug("ELB VM is in " + elbVm.getState() + ", so not sending apply LoadBalancing rules commands to the backend");
        return true;
    } else {
        s_logger.warn("Unable to apply loadbalancing rules, ELB VM is not in the right state " + elbVm.getState());
        throw new ResourceUnavailableException("Unable to apply loadbalancing rules, ELB VM is not in the right state", VirtualRouter.class, elbVm.getId());
    }
}
Also used : LbSslCert(com.cloud.network.lb.LoadBalancingRule.LbSslCert) Ip(com.cloud.utils.net.Ip) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) ArrayList(java.util.ArrayList) LbStickinessPolicy(com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy) VirtualRouter(com.cloud.network.router.VirtualRouter) LbDestination(com.cloud.network.lb.LoadBalancingRule.LbDestination) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) LbHealthCheckPolicy(com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 7 with LbSslCert

use of com.cloud.network.lb.LoadBalancingRule.LbSslCert in project cloudstack by apache.

the class LoadBalancingRulesManagerImpl method getLbSslCert.

@Override
public LbSslCert getLbSslCert(long lbRuleId) {
    LoadBalancerCertMapVO lbCertMap = _lbCertMapDao.findByLbRuleId(lbRuleId);
    if (lbCertMap == null)
        return null;
    SslCertVO certVO = _entityMgr.findById(SslCertVO.class, lbCertMap.getCertId());
    if (certVO == null) {
        s_logger.warn("Cert rule with cert ID " + lbCertMap.getCertId() + " but Cert is not found");
        return null;
    }
    return new LbSslCert(certVO.getCertificate(), certVO.getKey(), certVO.getPassword(), certVO.getChain(), certVO.getFingerPrint(), lbCertMap.isRevoke());
}
Also used : LbSslCert(com.cloud.network.lb.LoadBalancingRule.LbSslCert) SslCertVO(com.cloud.network.dao.SslCertVO) LoadBalancerCertMapVO(com.cloud.network.dao.LoadBalancerCertMapVO)

Aggregations

LbSslCert (com.cloud.network.lb.LoadBalancingRule.LbSslCert)7 LbDestination (com.cloud.network.lb.LoadBalancingRule.LbDestination)5 LbHealthCheckPolicy (com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy)5 LbStickinessPolicy (com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy)5 Ip (com.cloud.utils.net.Ip)5 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)4 LoadBalancingRule (com.cloud.network.lb.LoadBalancingRule)3 NetworkModel (com.cloud.network.NetworkModel)2 PublicIp (com.cloud.network.addr.PublicIp)2 LoadBalancerDao (com.cloud.network.dao.LoadBalancerDao)2 LoadBalancingRulesManager (com.cloud.network.lb.LoadBalancingRulesManager)2 com.citrix.netscaler.nitro.resource.config.basic.server_service_binding (com.citrix.netscaler.nitro.resource.config.basic.server_service_binding)1 com.citrix.netscaler.nitro.resource.config.gslb.gslbservice (com.citrix.netscaler.nitro.resource.config.gslb.gslbservice)1 com.citrix.netscaler.nitro.resource.config.gslb.gslbvserver (com.citrix.netscaler.nitro.resource.config.gslb.gslbvserver)1 com.citrix.netscaler.nitro.resource.config.lb.lbvserver (com.citrix.netscaler.nitro.resource.config.lb.lbvserver)1 com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding (com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding)1 com.citrix.netscaler.nitro.resource.config.ns.nsconfig (com.citrix.netscaler.nitro.resource.config.ns.nsconfig)1 com.citrix.netscaler.nitro.service.nitro_service (com.citrix.netscaler.nitro.service.nitro_service)1 Answer (com.cloud.agent.api.Answer)1 ExternalNetworkResourceUsageAnswer (com.cloud.agent.api.ExternalNetworkResourceUsageAnswer)1