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);
}
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;
}
Aggregations