You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/04 20:32:06 UTC

[4/18] api_refactor: refactor autoscale apis

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/ListConditionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/ListConditionsCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListConditionsCmd.java
new file mode 100644
index 0000000..d5dd067
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListConditionsCmd.java
@@ -0,0 +1,96 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.user.autoscale.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListAccountResourcesCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.ConditionResponse;
+import com.cloud.api.response.CounterResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.network.as.Condition;
+
+@Implementation(description = "List Conditions for the specific user", responseObject = CounterResponse.class)
+public class ListConditionsCmd extends BaseListAccountResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListConditionsCmd.class.getName());
+    private static final String s_name = "listconditionsresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "conditions")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = false, description = "ID of the Condition.")
+    private Long id;
+
+    @IdentityMapper(entityTableName = "counter")
+    @Parameter(name = ApiConstants.COUNTER_ID, type = CommandType.LONG, required = false, description = "Counter-id of the condition.")
+    private Long counterId;
+
+    @IdentityMapper(entityTableName="autoscale_policies")
+    @Parameter(name = ApiConstants.POLICY_ID, type = CommandType.LONG, description = "the ID of the policy")
+    private Long policyId;
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public void execute() {
+        List<? extends Condition> conditions = null;
+        conditions = _autoScaleService.listConditions(this);
+        ListResponse<ConditionResponse> response = new ListResponse<ConditionResponse>();
+        List<ConditionResponse> cndnResponses = new ArrayList<ConditionResponse>();
+        for (Condition cndn : conditions) {
+            ConditionResponse cndnResponse = _responseGenerator.createConditionResponse(cndn);
+            cndnResponses.add(cndnResponse);
+        }
+
+        response.setResponses(cndnResponses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+    // /////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Long getCounterId() {
+        return counterId;
+    }
+
+    public Long getPolicyId() {
+        return policyId;
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/ListCountersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/ListCountersCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListCountersCmd.java
new file mode 100644
index 0000000..b55aeb5
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListCountersCmd.java
@@ -0,0 +1,99 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.user.autoscale.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.CounterResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.network.as.Counter;
+import com.cloud.user.Account;
+
+@Implementation(description = "List the counters", responseObject = CounterResponse.class)
+public class ListCountersCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListCountersCmd.class.getName());
+    private static final String s_name = "counterresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "counter")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "ID of the Counter.")
+    private Long id;
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Name of the counter.")
+    private String name;
+
+    @Parameter(name = ApiConstants.SOURCE, type = CommandType.STRING, description = "Source of the counter.")
+    private String source;
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public void execute() {
+        List<? extends Counter> counters = null;
+        counters = _autoScaleService.listCounters(this);
+        ListResponse<CounterResponse> response = new ListResponse<CounterResponse>();
+        List<CounterResponse> ctrResponses = new ArrayList<CounterResponse>();
+        for (Counter ctr : counters) {
+            CounterResponse ctrResponse = _responseGenerator.createCounterResponse(ctr);
+            ctrResponses.add(ctrResponse);
+        }
+
+        response.setResponses(ctrResponses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+    // /////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScalePolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScalePolicyCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScalePolicyCmd.java
new file mode 100644
index 0000000..01945f2
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScalePolicyCmd.java
@@ -0,0 +1,126 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.user.autoscale.command;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.AutoScalePolicyResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.network.as.AutoScalePolicy;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description = "Updates an existing autoscale policy.", responseObject = AutoScalePolicyResponse.class)
+public class UpdateAutoScalePolicyCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateAutoScalePolicyCmd.class.getName());
+
+    private static final String s_name = "updateautoscalepolicyresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.DURATION, type = CommandType.INTEGER, description = "the duration for which the conditions have to be true before action is taken")
+    private Integer duration;
+
+    @Parameter(name = ApiConstants.QUIETTIME, type = CommandType.INTEGER, description = "the cool down period for which the policy should not be evaluated after the action has been taken")
+    private Integer quietTime;
+
+    @IdentityMapper(entityTableName = "conditions")
+    @Parameter(name = ApiConstants.CONDITION_IDS, type = CommandType.LIST, collectionType = CommandType.LONG, description = "the list of IDs of the conditions that are being evaluated on every interval")
+    private List<Long> conditionIds;
+
+    @IdentityMapper(entityTableName = "autoscale_policies")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the autoscale policy")
+    private Long id;
+
+    @Override
+    public void execute() {
+        UserContext.current().setEventDetails("AutoScale Policy Id: " + getId());
+        AutoScalePolicy result = _autoScaleService.updateAutoScalePolicy(this);
+        if (result != null) {
+            AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update autoscale policy");
+        }
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Integer getDuration() {
+        return duration;
+    }
+
+    public Integer getQuietTime() {
+        return quietTime;
+    }
+
+
+    public List<Long> getConditionIds() {
+        return conditionIds;
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        AutoScalePolicy autoScalePolicy = _entityMgr.findById(AutoScalePolicy.class, getId());
+        if (autoScalePolicy != null) {
+            return autoScalePolicy.getAccountId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are
+        // tracked
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_AUTOSCALEPOLICY_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Updating Auto Scale Policy. Policy Id: " + getId();
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.AutoScalePolicy;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScaleVmGroupCmd.java
new file mode 100644
index 0000000..1d7911e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScaleVmGroupCmd.java
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.user.autoscale.command;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.AutoScaleVmGroupResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.network.as.AutoScaleVmGroup;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description = "Updates an existing autoscale vm group.", responseObject = AutoScaleVmGroupResponse.class)
+public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateAutoScaleVmGroupCmd.class.getName());
+
+    private static final String s_name = "updateautoscalevmgroupresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.MIN_MEMBERS, type = CommandType.INTEGER, description = "the minimum number of members in the vmgroup, the number of instances in the vm group will be equal to or more than this number.")
+    private Integer minMembers;
+
+    @Parameter(name = ApiConstants.MAX_MEMBERS, type = CommandType.INTEGER, description = "the maximum number of members in the vmgroup, The number of instances in the vm group will be equal to or less than this number.")
+    private Integer maxMembers;
+
+    @Parameter(name=ApiConstants.INTERVAL, type=CommandType.INTEGER, description="the frequency at which the conditions have to be evaluated")
+    private Integer interval;
+
+    @IdentityMapper(entityTableName = "autoscale_policies")
+    @Parameter(name = ApiConstants.SCALEUP_POLICY_IDS, type = CommandType.LIST, collectionType = CommandType.LONG, description = "list of scaleup autoscale policies")
+    private List<Long> scaleUpPolicyIds;
+
+    @IdentityMapper(entityTableName = "autoscale_policies")
+    @Parameter(name = ApiConstants.SCALEDOWN_POLICY_IDS, type = CommandType.LIST, collectionType = CommandType.LONG, description = "list of scaledown autoscale policies")
+    private List<Long> scaleDownPolicyIds;
+
+    @IdentityMapper(entityTableName = "autoscale_vmgroups")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the autoscale group")
+    private Long id;
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public void execute() {
+        UserContext.current().setEventDetails("AutoScale Vm Group Id: " + getId());
+        AutoScaleVmGroup result = _autoScaleService.updateAutoScaleVmGroup(this);
+        if (result != null) {
+            AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update autoscale VmGroup");
+        }
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Integer getMinMembers() {
+        return minMembers;
+    }
+
+    public Integer getMaxMembers() {
+        return maxMembers;
+    }
+
+    public Integer getInterval() {
+        return interval;
+    }
+
+    public List<Long> getScaleUpPolicyIds() {
+        return scaleUpPolicyIds;
+    }
+
+    public List<Long> getScaleDownPolicyIds() {
+        return scaleDownPolicyIds;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_AUTOSCALEVMGROUP_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Updating AutoScale Vm Group. Vm Group Id: "+getId();
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        AutoScaleVmGroup autoScaleVmGroup = _entityMgr.findById(AutoScaleVmGroup.class, getId());
+        if (autoScaleVmGroup != null) {
+            return autoScaleVmGroup.getAccountId();
+        }
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are
+        // tracked
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.AutoScaleVmGroup;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScaleVmProfileCmd.java
new file mode 100644
index 0000000..08e0667
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/UpdateAutoScaleVmProfileCmd.java
@@ -0,0 +1,136 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.user.autoscale.command;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.AutoScaleVmProfileResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.network.as.AutoScaleVmProfile;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description = "Updates an existing autoscale vm profile.", responseObject = AutoScaleVmProfileResponse.class)
+public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateAutoScaleVmProfileCmd.class.getName());
+
+    private static final String s_name = "updateautoscalevmprofileresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "autoscale_vmprofiles")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the autoscale vm profile")
+    private Long id;
+
+    @IdentityMapper(entityTableName = "vm_template")
+    @Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.LONG, description = "the template of the auto deployed virtual machine")
+    private Long templateId;
+
+    @Parameter(name = ApiConstants.AUTOSCALE_VM_DESTROY_TIME, type = CommandType.INTEGER, description = "the time allowed for existing connections to get closed before a vm is destroyed")
+    private Integer destroyVmGraceperiod;
+
+    @Parameter(name = ApiConstants.COUNTERPARAM_LIST, type = CommandType.MAP, description = "counterparam list. Example: counterparam[0].name=snmpcommunity&counterparam[0].value=public&counterparam[1].name=snmpport&counterparam[1].value=161")
+    private Map counterParamList;
+
+    @IdentityMapper(entityTableName = "user")
+    @Parameter(name = ApiConstants.AUTOSCALE_USER_ID, type = CommandType.LONG, description = "the ID of the user used to launch and destroy the VMs")
+    private Long autoscaleUserId;
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public void execute() {
+        UserContext.current().setEventDetails("AutoScale Policy Id: " + getId());
+        AutoScaleVmProfile result = _autoScaleService.updateAutoScaleVmProfile(this);
+        if (result != null) {
+            AutoScaleVmProfileResponse response = _responseGenerator.createAutoScaleVmProfileResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update autoscale vm profile");
+        }
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Long getTemplateId() {
+        return templateId;
+    }
+
+    public Map getCounterParamList() {
+        return counterParamList;
+    }
+
+    public Long getAutoscaleUserId() {
+        return autoscaleUserId;
+    }
+
+    public Integer getDestroyVmGraceperiod() {
+        return destroyVmGraceperiod;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_AUTOSCALEVMPROFILE_UPDATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Updating AutoScale Vm Profile. Vm Profile Id: " + getId();
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        AutoScaleVmProfile vmProfile = _entityMgr.findById(AutoScaleVmProfile.class, getId());
+        if (vmProfile != null) {
+            return vmProfile.getAccountId();
+        }
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are
+        // tracked
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.AutoScaleVmProfile;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 4893877..5632fe6 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -155,25 +155,25 @@ updateLoadBalancerRule=org.apache.cloudstack.api.user.lb.command.UpdateLoadBalan
 
 #### autoscale commands
 createCounter = com.cloud.api.commands.CreateCounterCmd;1
-createCondition = com.cloud.api.commands.CreateConditionCmd;15
-createAutoScalePolicy=com.cloud.api.commands.CreateAutoScalePolicyCmd;15
-createAutoScaleVmProfile=com.cloud.api.commands.CreateAutoScaleVmProfileCmd;15
-createAutoScaleVmGroup=com.cloud.api.commands.CreateAutoScaleVmGroupCmd;15
+createCondition = org.apache.cloudstack.api.user.autoscale.command.CreateConditionCmd;15
+createAutoScalePolicy=org.apache.cloudstack.api.user.autoscale.command.CreateAutoScalePolicyCmd;15
+createAutoScaleVmProfile=org.apache.cloudstack.api.user.autoscale.command.CreateAutoScaleVmProfileCmd;15
+createAutoScaleVmGroup=org.apache.cloudstack.api.user.autoscale.command.CreateAutoScaleVmGroupCmd;15
 deleteCounter = com.cloud.api.commands.DeleteCounterCmd;1
-deleteCondition = com.cloud.api.commands.DeleteConditionCmd;15
-deleteAutoScalePolicy=com.cloud.api.commands.DeleteAutoScalePolicyCmd;15
-deleteAutoScaleVmProfile=com.cloud.api.commands.DeleteAutoScaleVmProfileCmd;15
-deleteAutoScaleVmGroup=com.cloud.api.commands.DeleteAutoScaleVmGroupCmd;15
-listCounters = com.cloud.api.commands.ListCountersCmd;15
-listConditions = com.cloud.api.commands.ListConditionsCmd;15
-listAutoScalePolicies=com.cloud.api.commands.ListAutoScalePoliciesCmd;15
-listAutoScaleVmProfiles=com.cloud.api.commands.ListAutoScaleVmProfilesCmd;15
-listAutoScaleVmGroups=com.cloud.api.commands.ListAutoScaleVmGroupsCmd;15
-enableAutoScaleVmGroup=com.cloud.api.commands.EnableAutoScaleVmGroupCmd;15
-disableAutoScaleVmGroup=com.cloud.api.commands.DisableAutoScaleVmGroupCmd;15
-updateAutoScalePolicy=com.cloud.api.commands.UpdateAutoScalePolicyCmd;15
-updateAutoScaleVmProfile=com.cloud.api.commands.UpdateAutoScaleVmProfileCmd;15
-updateAutoScaleVmGroup=com.cloud.api.commands.UpdateAutoScaleVmGroupCmd;15
+deleteCondition = org.apache.cloudstack.api.user.autoscale.command.DeleteConditionCmd;15
+deleteAutoScalePolicy=org.apache.cloudstack.api.user.autoscale.command.DeleteAutoScalePolicyCmd;15
+deleteAutoScaleVmProfile=org.apache.cloudstack.api.user.autoscale.command.DeleteAutoScaleVmProfileCmd;15
+deleteAutoScaleVmGroup=org.apache.cloudstack.api.user.autoscale.command.DeleteAutoScaleVmGroupCmd;15
+listCounters = org.apache.cloudstack.api.user.autoscale.command.ListCountersCmd;15
+listConditions = org.apache.cloudstack.api.user.autoscale.command.ListConditionsCmd;15
+listAutoScalePolicies=org.apache.cloudstack.api.user.autoscale.command.ListAutoScalePoliciesCmd;15
+listAutoScaleVmProfiles=org.apache.cloudstack.api.user.autoscale.command.ListAutoScaleVmProfilesCmd;15
+listAutoScaleVmGroups=org.apache.cloudstack.api.user.autoscale.command.ListAutoScaleVmGroupsCmd;15
+enableAutoScaleVmGroup=org.apache.cloudstack.api.user.autoscale.command.EnableAutoScaleVmGroupCmd;15
+disableAutoScaleVmGroup=org.apache.cloudstack.api.user.autoscale.command.DisableAutoScaleVmGroupCmd;15
+updateAutoScalePolicy=org.apache.cloudstack.api.user.autoscale.command.UpdateAutoScalePolicyCmd;15
+updateAutoScaleVmProfile=org.apache.cloudstack.api.user.autoscale.command.UpdateAutoScaleVmProfileCmd;15
+updateAutoScaleVmGroup=org.apache.cloudstack.api.user.autoscale.command.UpdateAutoScaleVmGroupCmd;15
 
 #### router commands
 startRouter=com.cloud.api.commands.StartRouterCmd;7

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/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 651625b..7917922 100644
--- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
+++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.user.autoscale.command.*;
 import org.apache.log4j.Logger;
 
 import com.cloud.acl.ControlledEntity;
@@ -32,20 +33,18 @@ import org.apache.cloudstack.api.ApiConstants;
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.ApiDispatcher;
 import org.apache.cloudstack.api.BaseListAccountResourcesCmd;
-import com.cloud.api.commands.CreateAutoScalePolicyCmd;
-import com.cloud.api.commands.CreateAutoScaleVmGroupCmd;
-import com.cloud.api.commands.CreateAutoScaleVmProfileCmd;
-import com.cloud.api.commands.CreateConditionCmd;
+import org.apache.cloudstack.api.user.autoscale.command.CreateAutoScalePolicyCmd;
+import org.apache.cloudstack.api.user.autoscale.command.CreateAutoScaleVmGroupCmd;
+import org.apache.cloudstack.api.user.autoscale.command.CreateAutoScaleVmProfileCmd;
+import org.apache.cloudstack.api.user.autoscale.command.CreateConditionCmd;
 import com.cloud.api.commands.CreateCounterCmd;
 import org.apache.cloudstack.api.user.vm.command.DeployVMCmd;
-import com.cloud.api.commands.ListAutoScalePoliciesCmd;
-import com.cloud.api.commands.ListAutoScaleVmGroupsCmd;
-import com.cloud.api.commands.ListAutoScaleVmProfilesCmd;
-import com.cloud.api.commands.ListConditionsCmd;
-import com.cloud.api.commands.ListCountersCmd;
-import com.cloud.api.commands.UpdateAutoScalePolicyCmd;
-import com.cloud.api.commands.UpdateAutoScaleVmGroupCmd;
-import com.cloud.api.commands.UpdateAutoScaleVmProfileCmd;
+import org.apache.cloudstack.api.user.autoscale.command.ListAutoScalePoliciesCmd;
+import org.apache.cloudstack.api.user.autoscale.command.ListAutoScaleVmGroupsCmd;
+import org.apache.cloudstack.api.user.autoscale.command.ListConditionsCmd;
+import org.apache.cloudstack.api.user.autoscale.command.ListCountersCmd;
+import org.apache.cloudstack.api.user.autoscale.command.UpdateAutoScalePolicyCmd;
+import org.apache.cloudstack.api.user.autoscale.command.UpdateAutoScaleVmProfileCmd;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.dao.ConfigurationDao;