incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [3/18] api_refactor: refactor autoscale apis
Date Tue, 04 Dec 2012 19:32:06 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/com/cloud/api/commands/UpdateAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateAutoScaleVmGroupCmd.java b/api/src/com/cloud/api/commands/UpdateAutoScaleVmGroupCmd.java
deleted file mode 100644
index 600f9c8..0000000
--- a/api/src/com/cloud/api/commands/UpdateAutoScaleVmGroupCmd.java
+++ /dev/null
@@ -1,143 +0,0 @@
-// 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 com.cloud.api.commands;
-
-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/com/cloud/api/commands/UpdateAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateAutoScaleVmProfileCmd.java b/api/src/com/cloud/api/commands/UpdateAutoScaleVmProfileCmd.java
deleted file mode 100644
index ff2135a..0000000
--- a/api/src/com/cloud/api/commands/UpdateAutoScaleVmProfileCmd.java
+++ /dev/null
@@ -1,136 +0,0 @@
-// 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 com.cloud.api.commands;
-
-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/api/src/com/cloud/network/as/AutoScaleService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/as/AutoScaleService.java b/api/src/com/cloud/network/as/AutoScaleService.java
index f62a4d6..3084868 100644
--- a/api/src/com/cloud/network/as/AutoScaleService.java
+++ b/api/src/com/cloud/network/as/AutoScaleService.java
@@ -18,19 +18,15 @@ package com.cloud.network.as;
 
 import java.util.List;
 
-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.*;
 import com.cloud.api.commands.CreateCounterCmd;
-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.ListConditionsCmd;
+import org.apache.cloudstack.api.user.autoscale.command.UpdateAutoScaleVmGroupCmd;
+import org.apache.cloudstack.api.user.autoscale.command.UpdateAutoScaleVmProfileCmd;
 import com.cloud.exception.ResourceInUseException;
 import com.cloud.exception.ResourceUnavailableException;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScalePolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScalePolicyCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScalePolicyCmd.java
new file mode 100644
index 0000000..75cead9
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScalePolicyCmd.java
@@ -0,0 +1,170 @@
+// 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.BaseAsyncCreateCmd;
+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.domain.Domain;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.network.as.AutoScalePolicy;
+import com.cloud.network.as.Condition;
+import com.cloud.user.Account;
+
+@Implementation(description = "Creates an autoscale policy for a provision or deprovision action, the action is taken when the all the conditions evaluates to true for the specified duration. The policy is in effect once it is attached to a autscale vm group.", responseObject = AutoScalePolicyResponse.class)
+public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateAutoScalePolicyCmd.class.getName());
+
+    private static final String s_name = "autoscalepolicyresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, required = true, description = "the action to be executed if all the conditions evaluate to true for the specified duration.")
+    private String action;
+
+    @Parameter(name = ApiConstants.DURATION, type = CommandType.INTEGER, required = true, description = "the duration for which the conditions have to be true before action is taken")
+    private int 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, required = true, description = "the list of IDs of the conditions that are being evaluated on every interval")
+    private List<Long> conditionIds;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    private Long conditionDomainId;
+    private Long conditionAccountId;
+
+    @Override
+    public String getEntityTable() {
+        return "autoscale_policies";
+    }
+
+    public int getDuration() {
+        return duration;
+    }
+
+    public Integer getQuietTime() {
+        return quietTime;
+    }
+
+    public String getAction() {
+        return action;
+    }
+
+    public List<Long> getConditionIds() {
+        return conditionIds;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "autoscalepolicy";
+    }
+
+    public long getAccountId()
+    {
+        if (conditionAccountId == null)
+            getEntityOwnerId();
+        return conditionAccountId;
+    }
+
+    public long getDomainId()
+    {
+        if (conditionDomainId == null) {
+            getEntityOwnerId();
+        }
+
+        return conditionDomainId;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        if (conditionAccountId != null) {
+            return conditionAccountId;
+        }
+        long conditionId = getConditionIds().get(0);
+        Condition condition = _entityMgr.findById(Condition.class, conditionId);
+        if(condition == null) {
+            // it is an invalid condition, return system acccount, error will be thrown later.
+            conditionDomainId = Domain.ROOT_DOMAIN;
+            conditionAccountId = Account.ACCOUNT_ID_SYSTEM;
+        } else {
+            conditionDomainId = condition.getDomainId();
+            conditionAccountId = condition.getAccountId();
+        }
+
+        return conditionAccountId;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_AUTOSCALEPOLICY_CREATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "creating AutoScale Policy";
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.AutoScalePolicy;
+    }
+
+    @Override
+    public void execute() {
+        AutoScalePolicy result = _entityMgr.findById(AutoScalePolicy.class, getEntityId());
+        AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+    @Override
+    public void create() throws ResourceAllocationException {
+        AutoScalePolicy result = _autoScaleService.createAutoScalePolicy(this);
+        if (result != null) {
+            this.setEntityId(result.getId());
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create AutoScale Policy");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScaleVmGroupCmd.java
new file mode 100644
index 0000000..3404207
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScaleVmGroupCmd.java
@@ -0,0 +1,194 @@
+// 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.BaseAsyncCreateCmd;
+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.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.network.as.AutoScaleVmGroup;
+import com.cloud.network.rules.LoadBalancer;
+
+@Implementation(description = "Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.", responseObject = AutoScaleVmGroupResponse.class)
+public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateAutoScaleVmGroupCmd.class.getName());
+
+    private static final String s_name = "autoscalevmgroupresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "firewall_rules")
+    @Parameter(name = ApiConstants.LBID, type = CommandType.LONG, required = true, description = "the ID of the load balancer rule")
+    private long lbRuleId;
+
+    @Parameter(name = ApiConstants.MIN_MEMBERS, type = CommandType.INTEGER, required = true, 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 int minMembers;
+
+    @Parameter(name = ApiConstants.MAX_MEMBERS, type = CommandType.INTEGER, required = true, 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 int 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, required = true, 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, required = true, description = "list of scaledown autoscale policies")
+    private List<Long> scaleDownPolicyIds;
+
+    @IdentityMapper(entityTableName = "autoscale_vmprofiles")
+    @Parameter(name = ApiConstants.VMPROFILE_ID, type = CommandType.LONG, required = true, description = "the autoscale profile that contains information about the vms in the vm group.")
+    private long profileId;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getEntityTable() {
+        return "autoscale_vmgroups";
+    }
+
+    public int getMinMembers() {
+        return minMembers;
+    }
+
+    public int getMaxMembers() {
+        return maxMembers;
+    }
+
+    public Integer getInterval() {
+        return interval;
+    }
+
+    public long getProfileId() {
+        return profileId;
+    }
+
+    public List<Long> getScaleUpPolicyIds() {
+        return scaleUpPolicyIds;
+    }
+
+    public List<Long> getScaleDownPolicyIds() {
+        return scaleDownPolicyIds;
+    }
+
+    public long getLbRuleId() {
+        return lbRuleId;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "autoscalevmgroup";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getLbRuleId());
+        if (lb == null) {
+            throw new InvalidParameterValueException("Unable to find loadbalancer by lbRuleId");
+        }
+        return lb.getAccountId();
+    }
+
+    public void setLbRuleId(Long lbRuleId) {
+        this.lbRuleId = lbRuleId;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_AUTOSCALEVMGROUP_CREATE;
+    }
+
+    @Override
+    public String getCreateEventType() {
+        return EventTypes.EVENT_AUTOSCALEVMGROUP_CREATE;
+    }
+
+    @Override
+    public String getCreateEventDescription() {
+        return "creating AutoScale Vm Group";
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "configuring AutoScale Vm Group. Vm Group Id: " + getEntityId();
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.AutoScaleVmGroup;
+    }
+
+    @Override
+    public void create() throws ResourceAllocationException {
+        AutoScaleVmGroup result = _autoScaleService.createAutoScaleVmGroup(this);
+        if (result != null) {
+            this.setEntityId(result.getId());
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Group");
+        }
+    }
+
+    @Override
+    public void execute() {
+        boolean success = false;
+        AutoScaleVmGroup vmGroup = null;
+        try
+        {
+            success = _autoScaleService.configureAutoScaleVmGroup(this);
+            if (success) {
+                vmGroup = _entityMgr.findById(AutoScaleVmGroup.class, getEntityId());
+                AutoScaleVmGroupResponse responseObject = _responseGenerator.createAutoScaleVmGroupResponse(vmGroup);
+                setResponseObject(responseObject);
+                responseObject.setResponseName(getCommandName());
+            }
+        } catch (Exception ex) {
+            // TODO what will happen if Resource Layer fails in a step inbetween
+            s_logger.warn("Failed to create autoscale vm group", ex);
+        } finally {
+            if (!success || vmGroup == null) {
+                _autoScaleService.deleteAutoScaleVmGroup(getEntityId());
+                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Group");
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScaleVmProfileCmd.java
new file mode 100644
index 0000000..74c08df
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateAutoScaleVmProfileCmd.java
@@ -0,0 +1,236 @@
+// 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.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+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.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.network.as.AutoScaleVmProfile;
+import com.cloud.user.Account;
+import com.cloud.user.User;
+import com.cloud.user.UserContext;
+
+@Implementation(description = "Creates a profile that contains information about the virtual machine which will be provisioned automatically by autoscale feature.", responseObject = AutoScaleVmProfileResponse.class)
+@SuppressWarnings("rawtypes")
+public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateAutoScaleVmProfileCmd.class.getName());
+
+    private static final String s_name = "autoscalevmprofileresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "data_center")
+    @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.LONG, required = true, description = "availability zone for the auto deployed virtual machine")
+    private Long zoneId;
+
+    @IdentityMapper(entityTableName = "disk_offering")
+    @Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.LONG, required = true, description = "the service offering of the auto deployed virtual machine")
+    private Long serviceOfferingId;
+
+    @IdentityMapper(entityTableName = "vm_template")
+    @Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.LONG, required = true, description = "the template of the auto deployed virtual machine")
+    private Long templateId;
+
+    @Parameter(name = ApiConstants.OTHER_DEPLOY_PARAMS, type = CommandType.STRING, description = "parameters other than zoneId/serviceOfferringId/templateId of the auto deployed virtual machine")
+    private String otherDeployParams;
+
+    @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;
+
+    private Map<String, String> otherDeployParamMap;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    private Long domainId;
+    private Long accountId;
+
+    @Override
+    public String getEntityTable() {
+        return "autoscale_vmprofiles";
+    }
+
+    public Long getDomainId() {
+        if (domainId == null) {
+            getAccountId();
+        }
+        return domainId;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public Long getServiceOfferingId() {
+        return serviceOfferingId;
+    }
+
+    public Long getTemplateId() {
+        return templateId;
+    }
+
+    public Map getCounterParamList() {
+        return counterParamList;
+    }
+
+    public String getOtherDeployParams() {
+        return otherDeployParams;
+    }
+
+    public Long getAutoscaleUserId() {
+        if (autoscaleUserId != null) {
+            return autoscaleUserId;
+        } else {
+            return UserContext.current().getCaller().getId();
+        }
+    }
+
+    public Integer getDestroyVmGraceperiod() {
+        return destroyVmGraceperiod;
+    }
+
+    public long getAccountId() {
+        if (accountId != null) {
+            return accountId;
+        }
+        Account account = null;
+        if (autoscaleUserId != null) {
+            User user = _entityMgr.findById(User.class, autoscaleUserId);
+            account = _entityMgr.findById(Account.class, user.getAccountId());
+        } else {
+            account = UserContext.current().getCaller();
+        }
+        accountId = account.getAccountId();
+        domainId = account.getDomainId();
+        return accountId;
+    }
+
+    private void createOtherDeployParamMap()
+    {
+        if (otherDeployParamMap == null) {
+            otherDeployParamMap = new HashMap<String, String>();
+        }
+        if (otherDeployParams == null)
+            return;
+        String[] keyValues = otherDeployParams.split("&"); // hostid=123, hypervisor=xenserver
+        for (String keyValue : keyValues) { // keyValue == "hostid=123"
+            String[] keyAndValue = keyValue.split("="); // keyValue = hostid, 123
+            if (keyAndValue.length != 2) {
+                throw new InvalidParameterValueException("Invalid parameter in otherDeployParam : " + keyValue);
+            }
+            String paramName = keyAndValue[0]; // hostid
+            String paramValue = keyAndValue[1]; // 123
+            otherDeployParamMap.put(paramName, paramValue);
+        }
+    }
+
+    public HashMap<String, String> getDeployParamMap()
+    {
+        createOtherDeployParamMap();
+        HashMap<String, String> deployParams = new HashMap<String, String>(otherDeployParamMap);
+        deployParams.put("command", "deployVirtualMachine");
+        deployParams.put("zoneId", zoneId.toString());
+        deployParams.put("serviceOfferingId", serviceOfferingId.toString());
+        deployParams.put("templateId", templateId.toString());
+        return deployParams;
+    }
+
+    public String getOtherDeployParam(String param)
+    {
+        if (param == null) {
+            return null;
+        }
+        createOtherDeployParamMap();
+        return otherDeployParamMap.get(param);
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "autoscalevmprofile";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return getAccountId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_AUTOSCALEVMPROFILE_CREATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "creating AutoScale Vm Profile";
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.AutoScaleVmProfile;
+    }
+
+    @Override
+    public void execute() {
+        AutoScaleVmProfile result = _entityMgr.findById(AutoScaleVmProfile.class, getEntityId());
+        AutoScaleVmProfileResponse response = _responseGenerator.createAutoScaleVmProfileResponse(result);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+    @Override
+    public void create() throws ResourceAllocationException {
+
+        AutoScaleVmProfile result = _autoScaleService.createAutoScaleVmProfile(this);
+        if (result != null) {
+            this.setEntityId(result.getId());
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Profile");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateConditionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateConditionCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateConditionCmd.java
new file mode 100644
index 0000000..2884f8e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/CreateConditionCmd.java
@@ -0,0 +1,152 @@
+// 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 org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+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.ConditionResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.network.as.Condition;
+import com.cloud.user.UserContext;
+
+@Implementation(description = "Creates a condition", responseObject = ConditionResponse.class)
+public class CreateConditionCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateConditionCmd.class.getName());
+    private static final String s_name = "conditionresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "counter")
+    @Parameter(name = ApiConstants.COUNTER_ID, type = CommandType.LONG, required = true, description = "ID of the Counter.")
+    private long counterId;
+
+    @Parameter(name = ApiConstants.RELATIONAL_OPERATOR, type = CommandType.STRING, required = true, description = "Relational Operator to be used with threshold.")
+    private String relationalOperator;
+
+    @Parameter(name = ApiConstants.THRESHOLD, type = CommandType.LONG, required = true, description = "Threshold value.")
+    private Long threshold;
+
+    @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the account of the condition. " +
+    "Must be used with the domainId parameter.")
+    private String accountName;
+
+    @IdentityMapper(entityTableName = "domain")
+    @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.LONG, description = "the domain ID of the account.")
+    private Long domainId;
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public void create() throws ResourceAllocationException {
+        Condition condition = null;
+        condition = _autoScaleService.createCondition(this);
+
+        if (condition != null) {
+            this.setEntityId(condition.getId());
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create condition.");
+        }
+    }
+
+    @Override
+    public void execute() {
+        Condition condition  = _entityMgr.findById(Condition.class, getEntityId());
+        ConditionResponse response = _responseGenerator.createConditionResponse(condition);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+    // /////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public Long getCounterId() {
+        return counterId;
+    }
+
+    public String getRelationalOperator() {
+        return relationalOperator;
+    }
+
+    public String getAccountName() {
+        if (accountName == null) {
+            return UserContext.current().getCaller().getAccountName();
+        }
+
+        return accountName;
+    }
+
+    public Long getDomainId() {
+        if (domainId == null) {
+            return UserContext.current().getCaller().getDomainId();
+        }
+        return domainId;
+    }
+
+    public Long getThreshold() {
+        return threshold;
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Condition;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "creating a condition";
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_CONDITION_CREATE;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Long accountId = finalyzeAccountId(accountName, domainId, null, true);
+        if (accountId == null) {
+            return UserContext.current().getCaller().getId();
+        }
+
+        return accountId;
+    }
+
+    @Override
+    public String getEntityTable() {
+        return "conditions";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScalePolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScalePolicyCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScalePolicyCmd.java
new file mode 100644
index 0000000..a6228b4
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScalePolicyCmd.java
@@ -0,0 +1,103 @@
+// 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 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.SuccessResponse;
+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 = "Deletes a autoscale policy.", responseObject = SuccessResponse.class)
+public class DeleteAutoScalePolicyCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteAutoScalePolicyCmd.class.getName());
+    private static final String s_name = "deleteautoscalepolicyresponse";
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "autoscale_policies")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the autoscale policy")
+    private Long id;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @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_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "deleting AutoScale Policy: " + getId();
+    }
+
+    @Override
+    public void execute() {
+        UserContext.current().setEventDetails("AutoScale Policy Id: " + getId());
+        boolean result = _autoScaleService.deleteAutoScalePolicy(id);
+
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            s_logger.warn("Failed to delete autoscale policy " + getId());
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete AutoScale Policy");
+        }
+    }
+
+    @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/DeleteAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScaleVmGroupCmd.java
new file mode 100644
index 0000000..b1198c9
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScaleVmGroupCmd.java
@@ -0,0 +1,103 @@
+// 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 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.SuccessResponse;
+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 = "Deletes a autoscale vm group.", responseObject = SuccessResponse.class)
+public class DeleteAutoScaleVmGroupCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteAutoScaleVmGroupCmd.class.getName());
+    private static final String s_name = "deleteautoscalevmgroupresponse";
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "autoscale_vmgroups")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the autoscale group")
+    private Long id;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @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 String getEventType() {
+        return EventTypes.EVENT_AUTOSCALEVMGROUP_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "deleting autoscale vm group: " + getId();
+    }
+
+    @Override
+    public void execute() {
+        UserContext.current().setEventDetails("AutoScale Vm Group Id: " + getId());
+        boolean result = _autoScaleService.deleteAutoScaleVmGroup(id);
+
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            s_logger.warn("Failed to delete autoscale vm group " + getId());
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete autoscale vm group");
+        }
+    }
+
+    @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/DeleteAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScaleVmProfileCmd.java
new file mode 100644
index 0000000..a8565dc
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteAutoScaleVmProfileCmd.java
@@ -0,0 +1,102 @@
+// 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 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.SuccessResponse;
+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 = "Deletes a autoscale vm profile.", responseObject = SuccessResponse.class)
+public class DeleteAutoScaleVmProfileCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteAutoScaleVmProfileCmd.class.getName());
+    private static final String s_name = "deleteautoscalevmprofileresponse";
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "autoscale_vmprofiles")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the autoscale profile")
+    private Long id;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        AutoScaleVmProfile autoScaleVmProfile = _entityMgr.findById(AutoScaleVmProfile.class, getId());
+        if (autoScaleVmProfile != null) {
+            return autoScaleVmProfile.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_AUTOSCALEVMPROFILE_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "deleting autoscale vm profile: " + getId();
+    }
+
+    @Override
+    public void execute() {
+        UserContext.current().setEventDetails("AutoScale VM Profile Id: " + getId());
+        boolean result = _autoScaleService.deleteAutoScaleVmProfile(id);
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            s_logger.warn("Failed to delete autoscale vm profile " + getId());
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete autoscale vm profile");
+        }
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.AutoScaleVmProfile;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteConditionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteConditionCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteConditionCmd.java
new file mode 100644
index 0000000..26c23a5
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/DeleteConditionCmd.java
@@ -0,0 +1,109 @@
+// 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 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.SuccessResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceInUseException;
+import com.cloud.network.as.Condition;
+import com.cloud.user.Account;
+
+@Implementation(description = "Removes a condition", responseObject = SuccessResponse.class)
+public class DeleteConditionCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteConditionCmd.class.getName());
+    private static final String s_name = "deleteconditionresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "conditions")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the condition.")
+    private Long id;
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public void execute() {
+        boolean result = false;
+        try {
+            result = _autoScaleService.deleteCondition(getId());
+        } catch (ResourceInUseException ex) {
+            s_logger.warn("Exception: ", ex);
+            throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex.getMessage());
+        }
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            s_logger.warn("Failed to delete condition " + getId());
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete condition.");
+        }
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Condition;
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Condition condition = _entityMgr.findById(Condition.class, getId());
+        if (condition != null) {
+            return condition.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_CONDITION_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Deleting a condition.";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/DisableAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/DisableAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/DisableAutoScaleVmGroupCmd.java
new file mode 100644
index 0000000..ba87c58
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/DisableAutoScaleVmGroupCmd.java
@@ -0,0 +1,102 @@
+// 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 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;
+
+@Implementation(description = "Disables an AutoScale Vm Group", responseObject = AutoScaleVmGroupResponse.class)
+public class DisableAutoScaleVmGroupCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DisableAutoScaleVmGroupCmd.class.getName());
+    private static final String s_name = "disableautoscalevmGroupresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @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() {
+        AutoScaleVmGroup result = _autoScaleService.disableAutoScaleVmGroup(getId());
+        if (result != null) {
+            AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to disable AutoScale Vm Group");
+        }
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    @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 String getEventType() {
+        return EventTypes.EVENT_AUTOSCALEVMGROUP_DISABLE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Disabling AutoScale Vm Group. Vm Group Id: " + getId();
+    }
+
+    @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/EnableAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/EnableAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/EnableAutoScaleVmGroupCmd.java
new file mode 100644
index 0000000..93039b0
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/EnableAutoScaleVmGroupCmd.java
@@ -0,0 +1,102 @@
+// 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 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;
+
+@Implementation(description = "Enables an AutoScale Vm Group", responseObject = AutoScaleVmGroupResponse.class)
+public class EnableAutoScaleVmGroupCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(EnableAutoScaleVmGroupCmd.class.getName());
+    private static final String s_name = "enableautoscalevmGroupresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @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() {
+        AutoScaleVmGroup result = _autoScaleService.enableAutoScaleVmGroup(getId());
+        if (result != null) {
+            AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable AutoScale Vm Group");
+        }
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    @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 String getEventType() {
+        return EventTypes.EVENT_AUTOSCALEVMGROUP_ENABLE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Enabling AutoScale Vm Group. Vm Group Id: "+getId();
+    }
+
+    @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/ListAutoScalePoliciesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScalePoliciesCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScalePoliciesCmd.java
new file mode 100644
index 0000000..57db5be
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScalePoliciesCmd.java
@@ -0,0 +1,103 @@
+// 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.AutoScalePolicyResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.network.as.AutoScalePolicy;
+
+@Implementation(description = "Lists autoscale policies.", responseObject = AutoScalePolicyResponse.class)
+public class ListAutoScalePoliciesCmd extends BaseListAccountResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListAutoScalePoliciesCmd.class.getName());
+
+    private static final String s_name = "listautoscalepoliciesresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "autoscale_policies")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "the ID of the autoscale policy")
+    private Long id;
+
+    @IdentityMapper(entityTableName = "conditions")
+    @Parameter(name = ApiConstants.CONDITION_ID, type = CommandType.LONG, description = "the ID of the condition of the policy")
+    private Long conditionId;
+
+    @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, description = "the action to be executed if all the conditions evaluate to true for the specified duration.")
+    private String action;
+
+    @IdentityMapper(entityTableName="autoscale_vmgroups")
+    @Parameter(name = ApiConstants.VMGROUP_ID, type = CommandType.LONG, description = "the ID of the autoscale vm group")
+    private Long vmGroupId;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Long getConditionId() {
+        return conditionId;
+    }
+
+    public String getAction() {
+        return action;
+    }
+
+    public Long getVmGroupId() {
+        return vmGroupId;
+    }
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute() {
+        List<? extends AutoScalePolicy> autoScalePolicies = _autoScaleService.listAutoScalePolicies(this);
+        ListResponse<AutoScalePolicyResponse> response = new ListResponse<AutoScalePolicyResponse>();
+        List<AutoScalePolicyResponse> responses = new ArrayList<AutoScalePolicyResponse>();
+        if (autoScalePolicies != null) {
+            for (AutoScalePolicy autoScalePolicy : autoScalePolicies) {
+                AutoScalePolicyResponse autoScalePolicyResponse = _responseGenerator.createAutoScalePolicyResponse(autoScalePolicy);
+                autoScalePolicyResponse.setObjectName("autoscalepolicy");
+                responses.add(autoScalePolicyResponse);
+            }
+        }
+        response.setResponses(responses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScaleVmGroupsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScaleVmGroupsCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScaleVmGroupsCmd.java
new file mode 100644
index 0000000..adea921
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScaleVmGroupsCmd.java
@@ -0,0 +1,115 @@
+// 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.BaseListProjectAndAccountResourcesCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.AutoScaleVmGroupResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.network.as.AutoScaleVmGroup;
+
+@Implementation(description = "Lists autoscale vm groups.", responseObject = AutoScaleVmGroupResponse.class)
+public class ListAutoScaleVmGroupsCmd extends BaseListProjectAndAccountResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListAutoScaleVmGroupsCmd.class.getName());
+
+    private static final String s_name = "listautoscalevmgroupsresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="autoscale_vmgroups")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "the ID of the autoscale vm group")
+    private Long id;
+
+    @IdentityMapper(entityTableName="firewall_rules")
+    @Parameter(name = ApiConstants.LBID, type = CommandType.LONG, description = "the ID of the loadbalancer")
+    private Long loadBalancerId;
+
+    @IdentityMapper(entityTableName="autoscale_vmprofiles")
+    @Parameter(name = ApiConstants.VMPROFILE_ID, type = CommandType.LONG, description = "the ID of the profile")
+    private Long profileId;
+
+    @IdentityMapper(entityTableName="autoscale_policies")
+    @Parameter(name = ApiConstants.POLICY_ID, type = CommandType.LONG, description = "the ID of the policy")
+    private Long policyId;
+
+    @IdentityMapper(entityTableName="data_center")
+    @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.LONG, description = "the availability zone ID")
+    private Long zoneId;
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Long getLoadBalancerId() {
+        return loadBalancerId;
+    }
+
+
+    public Long getProfileId() {
+        return profileId;
+    }
+
+    public Long getPolicyId() {
+        return policyId;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute() {
+        if(id != null && (loadBalancerId != null || profileId != null || policyId != null))
+            throw new InvalidParameterValueException("When id is specified other parameters need not be specified");
+
+        List<? extends AutoScaleVmGroup> autoScaleGroups = _autoScaleService.listAutoScaleVmGroups(this);
+        ListResponse<AutoScaleVmGroupResponse> response = new ListResponse<AutoScaleVmGroupResponse>();
+        List<AutoScaleVmGroupResponse> responses = new ArrayList<AutoScaleVmGroupResponse>();
+        if (autoScaleGroups != null) {
+            for (AutoScaleVmGroup autoScaleVmGroup : autoScaleGroups) {
+                AutoScaleVmGroupResponse autoScaleVmGroupResponse = _responseGenerator.createAutoScaleVmGroupResponse(autoScaleVmGroup);
+                autoScaleVmGroupResponse.setObjectName("autoscalevmgroup");
+                responses.add(autoScaleVmGroupResponse);
+            }
+        }
+        response.setResponses(responses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScaleVmProfilesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScaleVmProfilesCmd.java b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScaleVmProfilesCmd.java
new file mode 100644
index 0000000..aae7376
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/autoscale/command/ListAutoScaleVmProfilesCmd.java
@@ -0,0 +1,95 @@
+// 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.BaseListProjectAndAccountResourcesCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.AutoScaleVmProfileResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.network.as.AutoScaleVmProfile;
+
+@Implementation(description = "Lists autoscale vm profiles.", responseObject = AutoScaleVmProfileResponse.class)
+public class ListAutoScaleVmProfilesCmd extends BaseListProjectAndAccountResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListAutoScaleVmProfilesCmd.class.getName());
+
+    private static final String s_name = "listautoscalevmprofilesresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="autoscale_vmprofiles")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, 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 templateid of the autoscale vm profile")
+    private Long templateId;
+
+    @Parameter(name=ApiConstants.OTHER_DEPLOY_PARAMS, type=CommandType.STRING, description="the otherdeployparameters of the autoscale vm profile")
+    private String otherDeployParams;
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Long getTemplateId() {
+        return templateId;
+    }
+
+    public String getOtherDeployParams() {
+        return otherDeployParams;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute() {
+        List<? extends AutoScaleVmProfile> autoScaleProfiles = _autoScaleService.listAutoScaleVmProfiles(this);
+        ListResponse<AutoScaleVmProfileResponse> response = new ListResponse<AutoScaleVmProfileResponse>();
+        List<AutoScaleVmProfileResponse> responses = new ArrayList<AutoScaleVmProfileResponse>();
+        if (autoScaleProfiles != null) {
+            for (AutoScaleVmProfile autoScaleVmProfile : autoScaleProfiles) {
+                AutoScaleVmProfileResponse autoScaleVmProfileResponse = _responseGenerator.createAutoScaleVmProfileResponse(autoScaleVmProfile);
+                autoScaleVmProfileResponse.setObjectName("autoscalevmprofile");
+                responses.add(autoScaleVmProfileResponse);
+            }
+        }
+        response.setResponses(responses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+}


Mime
View raw message