mirror of https://github.com/apache/cloudstack.git
CS-15866. Packaging AutoScale Vm Group as part of delete
load balancer rule. ReviewedBy: Devdeep Singh
This commit is contained in:
parent
a9c7ae2934
commit
b10274efd9
|
|
@ -301,5 +301,5 @@ public class EventTypes {
|
|||
public static final String EVENT_AUTOSCALEVMGROUP_DELETE = "AUTOSCALEVMGROUP.DELETE";
|
||||
public static final String EVENT_AUTOSCALEVMGROUP_UPDATE = "AUTOSCALEVMGROUP.UPDATE";
|
||||
public static final String EVENT_AUTOSCALEVMGROUP_ENABLE = "AUTOSCALEVMGROUP.ENABLE";
|
||||
public static final String EVENT_AUTOSCALEVMGROUP_DISABLE = "AUTOSCALEVMGROUP.DIABLE";
|
||||
public static final String EVENT_AUTOSCALEVMGROUP_DISABLE = "AUTOSCALEVMGROUP.DISABLE";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -719,14 +719,15 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
return vmGroup.getLoadBalancerId() != null;
|
||||
}
|
||||
|
||||
public boolean configureAutoScaleVmGroup(long vmGroupid) {
|
||||
private boolean configureAutoScaleVmGroup(long vmGroupid) throws InvalidParameterValueException {
|
||||
AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
|
||||
|
||||
if (isLoadBalancerBasedAutoScaleVmGroup(vmGroup)) {
|
||||
try {
|
||||
return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid);
|
||||
} catch (RuntimeException re) {
|
||||
s_logger.warn("Exception during configureLbAutoScaleVmGrouop in lb rules manager", re);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Exception during configureLbAutoScaleVmGroup in lb rules manager", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
|
||||
|
||||
// Will return a string. For LB Stickiness this will be a json, for autoscale this will be "," separated values
|
||||
@Override
|
||||
public String getLBCapability(long networkid, String capabilityName) {
|
||||
|
|
@ -226,7 +227,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
serviceResponse.setName(service.getName());
|
||||
if ("Lb".equalsIgnoreCase(service.getName())) {
|
||||
Map<Capability, String> serviceCapabilities = serviceCapabilitiesMap
|
||||
.get(service);
|
||||
.get(service);
|
||||
if (serviceCapabilities != null) {
|
||||
for (Capability capability : serviceCapabilities
|
||||
.keySet()) {
|
||||
|
|
@ -278,7 +279,12 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
return new LbAutoScaleVmGroup(vmGroup, autoScalePolicies, lbAutoScaleVmProfile);
|
||||
}
|
||||
|
||||
private boolean applyAutoScaleConfig(LoadBalancerVO lb, LoadBalancingRule rule) throws ResourceUnavailableException {
|
||||
private boolean applyAutoScaleConfig(LoadBalancerVO lb, AutoScaleVmGroupVO vmGroup) throws ResourceUnavailableException {
|
||||
LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup);
|
||||
/* Regular config like destinations need not be packed for applying autoscale config as of today.*/
|
||||
LoadBalancingRule rule = new LoadBalancingRule(lb, null, null);
|
||||
rule.setAutoScaleVmGroup(lbAutoScaleVmGroup);
|
||||
|
||||
if (!isRollBackAllowedForProvider(lb)) {
|
||||
// this is for Netscalar type of devices. if their is failure the db entries will be rollbacked.
|
||||
return false;
|
||||
|
|
@ -314,12 +320,8 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
_lbDao.persist(loadBalancer);
|
||||
}
|
||||
|
||||
// LBTODO
|
||||
try {
|
||||
LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup);
|
||||
LoadBalancingRule rule = new LoadBalancingRule(loadBalancer, null, null);
|
||||
rule.setAutoScaleVmGroup(lbAutoScaleVmGroup);
|
||||
success = applyAutoScaleConfig(loadBalancer, rule);
|
||||
success = applyAutoScaleConfig(loadBalancer, vmGroup);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to configure AutoScaleVmGroup to the lb rule: " + loadBalancer.getId() + " because resource is unavaliable:", e);
|
||||
} finally {
|
||||
|
|
@ -839,9 +841,18 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
|
||||
if (apply) {
|
||||
try {
|
||||
if (!applyLoadBalancerConfig(loadBalancerId)) {
|
||||
s_logger.warn("Unable to apply the load balancer config");
|
||||
return false;
|
||||
if (_autoScaleVmGroupDao.isAutoScaleLoadBalancer(loadBalancerId)) {
|
||||
// Get the associated VmGroup
|
||||
AutoScaleVmGroupVO vmGroup = _autoScaleVmGroupDao.listByAll(loadBalancerId, null).get(0);
|
||||
if (!applyAutoScaleConfig(lb, vmGroup)) {
|
||||
s_logger.warn("Unable to apply the autoscale config");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!applyLoadBalancerConfig(loadBalancerId)) {
|
||||
s_logger.warn("Unable to apply the load balancer config");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (ResourceUnavailableException e) {
|
||||
if (rollBack && isRollBackAllowedForProvider(lb)) {
|
||||
|
|
@ -925,7 +936,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
try {
|
||||
if (ipVO.getAssociatedWithNetworkId() == null) {
|
||||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
|
||||
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
// set networkId just for verification purposes
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue