From 2f1dbb17cec8212fd08c36a8a2198a1cd40f9e7a Mon Sep 17 00:00:00 2001 From: Vijay Date: Fri, 31 Aug 2012 21:17:31 +0530 Subject: [PATCH] CS-16209. Correct the updateAutoScaleVmProfileCmd. The counterParams is corrected. Reviewed-By:Devdeep --- .../cloud/network/as/AutoScaleManagerImpl.java | 4 +++- .../cloud/network/as/AutoScaleVmProfileVO.java | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java index 69ac629761c..d0d641ac0fb 100644 --- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java +++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java @@ -278,6 +278,7 @@ public class AutoScaleManagerImpl implements AutoScaleManager, AutoScaleSe return policies; } + @DB protected AutoScaleVmProfileVO checkValidityAndPersist(AutoScaleVmProfileVO vmProfile) { long templateId = vmProfile.getTemplateId(); long autoscaleUserId = vmProfile.getAutoScaleUserId(); @@ -388,7 +389,7 @@ public class AutoScaleManagerImpl implements AutoScaleManager, AutoScaleSe } if (counterParamList != null) { - vmProfile.setCounterParams(counterParamList); + vmProfile.setCounterParamsForUpdate(counterParamList); } if (destroyVmGraceperiod != null) { @@ -1168,6 +1169,7 @@ public class AutoScaleManagerImpl implements AutoScaleManager, AutoScaleSe return success; } + @Override public void cleanUpAutoScaleResources(Long accountId) { // cleans Autoscale VmProfiles, AutoScale Policies and Conditions belonging to an account int count = 0; diff --git a/server/src/com/cloud/network/as/AutoScaleVmProfileVO.java b/server/src/com/cloud/network/as/AutoScaleVmProfileVO.java index 4b57e0c8b68..8c4c2e8a1d4 100644 --- a/server/src/com/cloud/network/as/AutoScaleVmProfileVO.java +++ b/server/src/com/cloud/network/as/AutoScaleVmProfileVO.java @@ -96,8 +96,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity { if (destroyVmGraceperiod != null) { this.destroyVmGraceperiod = destroyVmGraceperiod; } - setCounterParams(counterParamList); - + setCounterParamsForUpdate(counterParamList); } @Override @@ -141,8 +140,11 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity { return paramsList; } + public void setCounterParams(String counterParam) { + this.counterParams = counterParam; + } - public void setCounterParams(Map counterParamList) { + public void setCounterParamsForUpdate(Map counterParamList) { StringBuilder sb = new StringBuilder(""); boolean isFirstParam = true; if (counterParamList != null) { @@ -158,7 +160,12 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity { isFirstParam = false; } } - counterParams = sb.toString(); + /* + * setCounterParams(String counterParam)'s String param is caught by UpdateBuilder and stored in an internal list. + * Which is used later to update the db. The variables in a VO object is not used to update the db. + * Hence calling the function which is intercepted. + * */ + setCounterParams(sb.toString()); } @Override