mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-1851 Health Check monitor not getting created on Netscaler device in Basic zone setup.
This commit is contained in:
parent
f1c794de1b
commit
16865014a0
|
|
@ -19,6 +19,8 @@ package com.cloud.network.element;
|
|||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.routing.GlobalLoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.HealthCheckLBConfigAnswer;
|
||||
import com.cloud.agent.api.routing.HealthCheckLBConfigCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
|
|
@ -682,7 +684,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
|||
List<LbDestination> destinations = rule.getDestinations();
|
||||
|
||||
if ((destinations != null && !destinations.isEmpty()) || rule.isAutoScaleConfig()) {
|
||||
LoadBalancerTO loadBalancer = new LoadBalancerTO(lbUuid, srcIp, srcPort, protocol, algorithm, revoked, false, false, destinations, rule.getStickinessPolicies());
|
||||
LoadBalancerTO loadBalancer = new LoadBalancerTO(lbUuid, srcIp, srcPort, protocol, algorithm, revoked, false, false, destinations, rule.getStickinessPolicies(), rule.getHealthCheckPolicies());
|
||||
if (rule.isAutoScaleConfig()) {
|
||||
loadBalancer.setAutoScaleVmGroup(rule.getAutoScaleVmGroup());
|
||||
}
|
||||
|
|
@ -808,11 +810,75 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<LoadBalancerTO> getElasticLBRulesHealthCheck(Network network, List<? extends FirewallRule> rules)
|
||||
throws ResourceUnavailableException {
|
||||
|
||||
HealthCheckLBConfigAnswer answer = null;
|
||||
List<LoadBalancingRule> loadBalancingRules = new ArrayList<LoadBalancingRule>();
|
||||
for (FirewallRule rule : rules) {
|
||||
if (rule.getPurpose().equals(Purpose.LoadBalancing)) {
|
||||
loadBalancingRules.add((LoadBalancingRule) rule);
|
||||
}
|
||||
}
|
||||
|
||||
if (loadBalancingRules == null || loadBalancingRules.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String errMsg = null;
|
||||
ExternalLoadBalancerDeviceVO lbDeviceVO = getExternalLoadBalancerForNetwork(network);
|
||||
|
||||
if (lbDeviceVO == null) {
|
||||
s_logger.warn("There is no external load balancer device assigned to this network either network is not implement are already shutdown so just returning");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isNetscalerDevice(lbDeviceVO.getDeviceName())) {
|
||||
errMsg = "There are no NetScaler load balancer assigned for this network. So NetScaler element can not be handle elastic load balancer rules.";
|
||||
s_logger.error(errMsg);
|
||||
throw new ResourceUnavailableException(errMsg, this.getClass(), 0);
|
||||
}
|
||||
|
||||
List<LoadBalancerTO> loadBalancersToApply = new ArrayList<LoadBalancerTO>();
|
||||
for (int i = 0; i < loadBalancingRules.size(); i++) {
|
||||
LoadBalancingRule rule = loadBalancingRules.get(i);
|
||||
boolean revoked = (rule.getState().equals(FirewallRule.State.Revoke));
|
||||
String protocol = rule.getProtocol();
|
||||
String algorithm = rule.getAlgorithm();
|
||||
String lbUuid = rule.getUuid();
|
||||
String srcIp = _networkMgr.getIp(rule.getSourceIpAddressId()).getAddress().addr();
|
||||
int srcPort = rule.getSourcePortStart();
|
||||
List<LbDestination> destinations = rule.getDestinations();
|
||||
|
||||
if ((destinations != null && !destinations.isEmpty()) || rule.isAutoScaleConfig()) {
|
||||
LoadBalancerTO loadBalancer = new LoadBalancerTO(lbUuid, srcIp, srcPort, protocol, algorithm, revoked,
|
||||
false, false, destinations, null, rule.getHealthCheckPolicies());
|
||||
loadBalancersToApply.add(loadBalancer);
|
||||
}
|
||||
}
|
||||
|
||||
if (loadBalancersToApply.size() > 0) {
|
||||
int numLoadBalancersForCommand = loadBalancersToApply.size();
|
||||
LoadBalancerTO[] loadBalancersForCommand = loadBalancersToApply
|
||||
.toArray(new LoadBalancerTO[numLoadBalancersForCommand]);
|
||||
HealthCheckLBConfigCommand cmd = new HealthCheckLBConfigCommand(loadBalancersForCommand);
|
||||
HostVO externalLoadBalancer = _hostDao.findById(lbDeviceVO.getHostId());
|
||||
answer = (HealthCheckLBConfigAnswer) _agentMgr.easySend(externalLoadBalancer.getId(), cmd);
|
||||
return answer.getLoadBalancers();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<LoadBalancerTO> updateHealthChecks(Network network, List<LoadBalancingRule> lbrules) {
|
||||
|
||||
if (canHandle(network, Service.Lb)) {
|
||||
try {
|
||||
return getLBHealthChecks(network, lbrules);
|
||||
|
||||
if (isBasicZoneNetwok(network)) {
|
||||
return getElasticLBRulesHealthCheck(network, lbrules);
|
||||
} else {
|
||||
return getLBHealthChecks(network, lbrules);
|
||||
}
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.error("Error in getting the LB Rules from NetScaler " + e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue