You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2014/02/05 00:52:46 UTC

[2/5] git commit: updated refs/heads/master to 7cb4b57

External UUID control support for AutoscaleVmProfile and AutoscaleVmGroup


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7cd0ad33
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7cd0ad33
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7cd0ad33

Branch: refs/heads/master
Commit: 7cd0ad336b187b1f76b0dc053eb8ec6c13bda193
Parents: 6af6ce7
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Tue Feb 4 11:10:44 2014 -0800
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Tue Feb 4 15:47:12 2014 -0800

----------------------------------------------------------------------
 .../autoscale/UpdateAutoScaleVmGroupCmd.java    | 14 ++++++++---
 .../autoscale/UpdateAutoScaleVmProfileCmd.java  | 14 ++++++++---
 .../cloud/network/as/AutoScaleVmGroupVO.java    |  4 +++
 .../cloud/network/as/AutoScaleVmProfileVO.java  |  4 +++
 .../cloud/network/as/AutoScaleManagerImpl.java  | 26 ++++++++++++++------
 5 files changed, 46 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7cd0ad33/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java
index dbbd85f..221cc36 100644
--- a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java
@@ -19,25 +19,24 @@ package org.apache.cloudstack.api.command.user.autoscale;
 
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseAsyncCustomIdCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
 import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.network.as.AutoScaleVmGroup;
 import com.cloud.user.Account;
 
 @APICommand(name = "updateAutoScaleVmGroup", description = "Updates an existing autoscale vm group.", responseObject = AutoScaleVmGroupResponse.class)
-public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd {
+public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCustomIdCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateAutoScaleVmGroupCmd.class.getName());
 
     private static final String s_name = "updateautoscalevmgroupresponse";
@@ -154,4 +153,11 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd {
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.AutoScaleVmGroup;
     }
+
+    @Override
+    public void checkUuid(String id, Class<?> cls) {
+        if (this.getCustomId() != null) {
+            _uuidMgr.checkUuid(this.getCustomId(), AutoScaleVmGroup.class);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7cd0ad33/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java
index f3361d8..b9d53b2 100644
--- a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java
@@ -19,26 +19,25 @@ package org.apache.cloudstack.api.command.user.autoscale;
 
 import java.util.Map;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseAsyncCustomIdCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.UserResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.network.as.AutoScaleVmProfile;
 import com.cloud.user.Account;
 
 @APICommand(name = "updateAutoScaleVmProfile", description = "Updates an existing autoscale vm profile.", responseObject = AutoScaleVmProfileResponse.class)
-public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd {
+public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCustomIdCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateAutoScaleVmProfileCmd.class.getName());
 
     private static final String s_name = "updateautoscalevmprofileresponse";
@@ -146,4 +145,11 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd {
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.AutoScaleVmProfile;
     }
+
+    @Override
+    public void checkUuid(String id, Class<?> cls) {
+        if (this.getCustomId() != null) {
+            _uuidMgr.checkUuid(this.getCustomId(), AutoScaleVmProfile.class);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7cd0ad33/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
index d8612b0..9650249 100644
--- a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
+++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java
@@ -208,4 +208,8 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity {
     public String getUuid() {
         return uuid;
     }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7cd0ad33/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
index ec643b0..9a8fbd8 100644
--- a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
+++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java
@@ -216,4 +216,8 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter
     public long getAutoScaleUserId() {
         return autoscaleUserId;
     }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7cd0ad33/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
index f1ca007..436737a 100644
--- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
+++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
@@ -53,7 +53,6 @@ import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
 import org.apache.cloudstack.config.ApiServiceConfiguration;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-
 import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiDBUtils;
@@ -119,7 +118,6 @@ import com.cloud.utils.db.TransactionStatus;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.UserVmManager;
 import com.cloud.vm.UserVmService;
-
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 
@@ -394,6 +392,8 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
         AutoScaleVmProfileVO vmProfile = getEntityInDatabase(CallContext.current().getCallingAccount(), "Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
 
+        boolean physicalParameterUpdate = (templateId != null || autoscaleUserId != null || counterParamList != null || destroyVmGraceperiod != null);
+
         if (templateId != null) {
             vmProfile.setTemplateId(templateId);
         }
@@ -410,9 +410,13 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             vmProfile.setDestroyVmGraceperiod(destroyVmGraceperiod);
         }
 
-        final List<AutoScaleVmGroupVO> vmGroupList = _autoScaleVmGroupDao.listByAll(null, profileId);
-        for (final AutoScaleVmGroupVO vmGroupVO : vmGroupList) {
-            if (!vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
+        if (cmd.getCustomId() != null) {
+            vmProfile.setUuid(cmd.getCustomId());
+        }
+
+        List<AutoScaleVmGroupVO> vmGroupList = _autoScaleVmGroupDao.listByAll(null, profileId);
+        for (AutoScaleVmGroupVO vmGroupVO : vmGroupList) {
+            if (physicalParameterUpdate && !vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
                 throw new InvalidParameterValueException("The AutoScale Vm Profile can be updated only if the Vm Group it is associated with is disabled in state");
             }
         }
@@ -976,8 +980,10 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
         AutoScaleVmGroupVO vmGroupVO = getEntityInDatabase(CallContext.current().getCallingAccount(), "AutoScale Vm Group", vmGroupId, _autoScaleVmGroupDao);
 
-        if (!vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
-            throw new InvalidParameterValueException("An AutoScale Vm Group can be updated only when it is in disabled state");
+        boolean physicalParametersUpdate = (minMembers != null || maxMembers != null || interval != null);
+
+        if (physicalParametersUpdate && !vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
+            throw new InvalidParameterValueException("An AutoScale Vm Group can be updated with minMembers/maxMembers/Interval only when it is in disabled state");
         }
 
         if (minMembers != null) {
@@ -988,10 +994,14 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             vmGroupVO.setMaxMembers(maxMembers);
         }
 
-        if (interval != null) {
+        if (maxMembers != null) {
             vmGroupVO.setInterval(interval);
         }
 
+        if (cmd.getCustomId() != null) {
+            vmGroupVO.setUuid(cmd.getCustomId());
+        }
+
         vmGroupVO = checkValidityAndPersist(vmGroupVO, scaleUpPolicyIds, scaleDownPolicyIds);
         if (vmGroupVO != null) {
             s_logger.debug("Updated Auto Scale VmGroup id:" + vmGroupId);