From d027a0f7051f83608a57cce9db113ca6200800e5 Mon Sep 17 00:00:00 2001 From: Vijay Date: Thu, 2 Aug 2012 14:11:08 +0530 Subject: [PATCH] CS-15781. AutoScale. During update of Autoscale VM Group, the interval is checked for validity against existing policies in the group as well. --- .../network/as/AutoScaleManagerImpl.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java index cfddc0a241b..d0ea5c321b0 100644 --- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java +++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java @@ -173,7 +173,7 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { for (Counter counter : counters) { if (!supportedCounters.contains(counter.getSource().name().toString())) { throw new InvalidParameterException("AutoScale counter with source='" + counter.getSource() + "' is not supported " + - "in the network where lb is configured"); + "in the network where lb is configured"); } } } @@ -565,7 +565,7 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { Account caller = UserContext.current().getCaller(); Ternary domainIdRecursiveListProject = new Ternary(domainId, isRecursive, null); + ListProjectResourcesCriteria>(domainId, isRecursive, null); _accountMgr.buildACLSearchParameters(caller, id, accountName, null, permittedAccounts, domainIdRecursiveListProject, listAll, false); domainId = domainIdRecursiveListProject.first(); @@ -829,6 +829,10 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { List counters = new ArrayList(); List policies = new ArrayList(); List policyIds = new ArrayList(); + List bakupScaleUpPolicyIds = new ArrayList(); + List bakupScaleDownPolicyIds = new ArrayList(); + if(vmGroup.getCreated() != null) + ApiDBUtils.getAutoScaleVmGroupPolicyIds(vmGroup.getId(), bakupScaleUpPolicyIds, bakupScaleDownPolicyIds); if (minMembers < 0) { throw new InvalidParameterValueException(ApiConstants.MIN_MEMBERS + " is an invalid value: " + minMembers, null); @@ -848,10 +852,20 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { if (scaleUpPolicyIds != null) { policies.addAll(getAutoScalePolicies("scaleuppolicyid", scaleUpPolicyIds, counters, interval, true)); + policyIds.addAll(scaleUpPolicyIds); + } else { + // Run the interval check for existing policies + getAutoScalePolicies("scaleuppolicyid", bakupScaleUpPolicyIds, counters, interval, true); + policyIds.addAll(bakupScaleUpPolicyIds); } if (scaleDownPolicyIds != null) { policies.addAll(getAutoScalePolicies("scaledownpolicyid", scaleDownPolicyIds, counters, interval, false)); + policyIds.addAll(scaleDownPolicyIds); + } else { + // Run the interval check for existing policies + getAutoScalePolicies("scaledownpolicyid", bakupScaleDownPolicyIds, counters, interval, true); + policyIds.addAll(bakupScaleDownPolicyIds); } LoadBalancerVO loadBalancer = getEntityInDatabase(UserContext.current().getCaller(), ApiConstants.LBID, vmGroup.getLoadBalancerId(), _lbDao); @@ -869,20 +883,6 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { vmGroup = _autoScaleVmGroupDao.persist(vmGroup); if (scaleUpPolicyIds != null || scaleDownPolicyIds != null) { - List bakupScaleUpPolicyIds = new ArrayList(); - List bakupScaleDownPolicyIds = new ArrayList(); - ApiDBUtils.getAutoScaleVmGroupPolicyIds(vmGroup.getId(), bakupScaleUpPolicyIds, bakupScaleDownPolicyIds); - if (scaleUpPolicyIds == null) { - policyIds.addAll(bakupScaleUpPolicyIds); - } else { - policyIds.addAll(scaleUpPolicyIds); - } - if (scaleDownPolicyIds == null) { - policyIds.addAll(bakupScaleDownPolicyIds); - } else { - policyIds.addAll(scaleDownPolicyIds); - } - _autoScaleVmGroupPolicyMapDao.removeByGroupId(vmGroup.getId()); for (Long policyId : policyIds) {