Search in sources :

Example 6 with LoadBalancingServiceProvider

use of com.cloud.network.element.LoadBalancingServiceProvider in project cloudstack by apache.

the class LoadBalancingRulesManagerImpl method applyLoadBalancerConfig.

@Override
public boolean applyLoadBalancerConfig(long lbRuleId) throws ResourceUnavailableException {
    LoadBalancerVO lb = _lbDao.findById(lbRuleId);
    List<LoadBalancerVO> lbs;
    if (isRollBackAllowedForProvider(lb)) {
        // this is for Netscalar type of devices. if their is failure the db
        // entries will be rollbacked.
        lbs = Arrays.asList(lb);
    } else {
        boolean onlyRulesInTransitionState = true;
        for (LoadBalancingServiceProvider lbElement : _lbProviders) {
            Provider provider = lbElement.getProvider();
            boolean isLbProvider = _networkModel.isProviderSupportServiceInNetwork(lb.getNetworkId(), Service.Lb, provider);
            if (!isLbProvider) {
                continue;
            }
            onlyRulesInTransitionState = lbElement.handlesOnlyRulesInTransitionState();
            break;
        }
        // get all rules in transition state
        if (onlyRulesInTransitionState) {
            lbs = _lbDao.listInTransitionStateByNetworkIdAndScheme(lb.getNetworkId(), lb.getScheme());
        } else {
            lbs = _lbDao.listByNetworkIdAndScheme(lb.getNetworkId(), lb.getScheme());
        }
    }
    return applyLoadBalancerRules(lbs, true);
}
Also used : LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) LoadBalancingServiceProvider(com.cloud.network.element.LoadBalancingServiceProvider) LoadBalancingServiceProvider(com.cloud.network.element.LoadBalancingServiceProvider) Provider(com.cloud.network.Network.Provider)

Example 7 with LoadBalancingServiceProvider

use of com.cloud.network.element.LoadBalancingServiceProvider in project cloudstack by apache.

the class NetworkOrchestrator method getLoadBalancingProviderForNetwork.

@Override
public LoadBalancingServiceProvider getLoadBalancingProviderForNetwork(final Network network, final Scheme lbScheme) {
    final List<NetworkElement> lbElements = getElementForServiceInNetwork(network, Service.Lb);
    NetworkElement lbElement = null;
    if (lbElements.size() > 1) {
        String providerName = null;
        //get network offering details
        final NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
        if (lbScheme == Scheme.Public) {
            providerName = _ntwkOffDetailsDao.getDetail(off.getId(), NetworkOffering.Detail.PublicLbProvider);
        } else {
            providerName = _ntwkOffDetailsDao.getDetail(off.getId(), NetworkOffering.Detail.InternalLbProvider);
        }
        if (providerName == null) {
            throw new InvalidParameterValueException("Can't find Lb provider supporting scheme " + lbScheme.toString() + " in network " + network);
        }
        lbElement = _networkModel.getElementImplementingProvider(providerName);
    } else if (lbElements.size() == 1) {
        lbElement = lbElements.get(0);
    }
    assert lbElement != null;
    assert lbElement instanceof LoadBalancingServiceProvider;
    return (LoadBalancingServiceProvider) lbElement;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) NetworkOffering(com.cloud.offering.NetworkOffering) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) LoadBalancingServiceProvider(com.cloud.network.element.LoadBalancingServiceProvider)

Aggregations

LoadBalancingServiceProvider (com.cloud.network.element.LoadBalancingServiceProvider)7 Network (com.cloud.network.Network)3 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 Provider (com.cloud.network.Network.Provider)2 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)2 NetworkOffering (com.cloud.offering.NetworkOffering)2 LoadBalancerTO (com.cloud.agent.api.to.LoadBalancerTO)1 PublicIp (com.cloud.network.addr.PublicIp)1 AutoScaleVmGroupDao (com.cloud.network.as.dao.AutoScaleVmGroupDao)1 LBHealthCheckPolicyDao (com.cloud.network.dao.LBHealthCheckPolicyDao)1 LBStickinessPolicyDao (com.cloud.network.dao.LBStickinessPolicyDao)1 LoadBalancerCertMapDao (com.cloud.network.dao.LoadBalancerCertMapDao)1 LoadBalancerVMMapDao (com.cloud.network.dao.LoadBalancerVMMapDao)1 LoadBalancerVMMapVO (com.cloud.network.dao.LoadBalancerVMMapVO)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 NetworkElement (com.cloud.network.element.NetworkElement)1 LbDestination (com.cloud.network.lb.LoadBalancingRule.LbDestination)1 LbHealthCheckPolicy (com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy)1 Purpose (com.cloud.network.rules.FirewallRule.Purpose)1 AccountVO (com.cloud.user.AccountVO)1