incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [41/57] api: move and group all under command, org.apache.cloudstack.command.*
Date Sat, 08 Dec 2012 03:29:53 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java
new file mode 100644
index 0000000..f889a9d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java
@@ -0,0 +1,179 @@
+// 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.command.user.address;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.IPAddressResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.network.IpAddress;
+import com.cloud.utils.Pair;
+
+
+@Implementation(description="Lists all public ip addresses", responseObject=IPAddressResponse.class)
+public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListPublicIpAddressesCmd.class.getName());
+
+    private static final String s_name = "listpublicipaddressesresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.ALLOCATED_ONLY, type=CommandType.BOOLEAN, description="limits search results to allocated public IP addresses")
+    private Boolean allocatedOnly;
+
+    @Parameter(name=ApiConstants.FOR_VIRTUAL_NETWORK, type=CommandType.BOOLEAN, description="the virtual network for the IP address")
+    private Boolean forVirtualNetwork;
+
+    @IdentityMapper(entityTableName="user_ip_address")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="lists ip address by id")
+    private Long id;
+
+    @Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="lists the specified IP address")
+    private String ipAddress;
+
+    @IdentityMapper(entityTableName="vlan")
+    @Parameter(name=ApiConstants.VLAN_ID, type=CommandType.LONG, description="lists all public IP addresses by VLAN ID")
+    private Long vlanId;
+
+    @IdentityMapper(entityTableName="data_center")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="lists all public IP addresses by Zone ID")
+    private Long zoneId;
+
+    @Parameter(name=ApiConstants.FOR_LOAD_BALANCING, type=CommandType.BOOLEAN, description="list only ips used for load balancing")
+    private Boolean forLoadBalancing;
+
+    @IdentityMapper(entityTableName="physical_network")
+    @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="lists all public IP addresses by physical network id")
+    private Long physicalNetworkId;
+
+    @IdentityMapper(entityTableName="networks")
+    @Parameter(name=ApiConstants.ASSOCIATED_NETWORK_ID, type=CommandType.LONG, description="lists all public IP addresses associated to the network specified")
+    private Long associatedNetworkId;
+
+    @Parameter(name=ApiConstants.IS_SOURCE_NAT, type=CommandType.BOOLEAN, description="list only source nat ip addresses")
+    private Boolean isSourceNat;
+
+    @Parameter(name=ApiConstants.IS_STATIC_NAT, type=CommandType.BOOLEAN, description="list only static nat ip addresses")
+    private Boolean isStaticNat;
+
+    @IdentityMapper(entityTableName="vpc")
+    @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="List ips belonging to the VPC")
+    private Long vpcId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+    public Long getId() {
+        return id;
+    }
+
+    public Boolean isAllocatedOnly() {
+        return allocatedOnly;
+    }
+
+    public Boolean isForVirtualNetwork() {
+        return forVirtualNetwork;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+    public Long getVlanId() {
+        return vlanId;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public Long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public Long getAssociatedNetworkId() {
+        return associatedNetworkId;
+    }
+
+    public Boolean getIsSourceNat() {
+        return isSourceNat;
+    }
+
+    public Boolean getIsStaticNat() {
+        return isStaticNat;
+    }
+
+    public Long getVpcId() {
+        return vpcId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends IpAddress>, Integer> result = _mgr.searchForIPAddresses(this);
+        ListResponse<IPAddressResponse> response = new ListResponse<IPAddressResponse>();
+        List<IPAddressResponse> ipAddrResponses = new ArrayList<IPAddressResponse>();
+        for (IpAddress ipAddress : result.first()) {
+            IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ipAddress);
+            ipResponse.setObjectName("publicipaddress");
+            ipAddrResponses.add(ipResponse);
+        }
+
+        response.setResponses(ipAddrResponses, result.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.IpAddress;
+    }
+
+
+    public Boolean isForLoadBalancing() {
+        return forLoadBalancing;
+    }
+
+    public Boolean getAllocatedOnly() {
+        return allocatedOnly;
+    }
+
+    public Boolean getForVirtualNetwork() {
+        return forVirtualNetwork;
+    }
+
+    public Boolean getForLoadBalancing() {
+        return forLoadBalancing;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScalePolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScalePolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScalePolicyCmd.java
new file mode 100644
index 0000000..d88fe4f
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java
new file mode 100644
index 0000000..411458c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java
new file mode 100644
index 0000000..d152c61
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
new file mode 100644
index 0000000..f48653d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScalePolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScalePolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScalePolicyCmd.java
new file mode 100644
index 0000000..d13783b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmGroupCmd.java
new file mode 100644
index 0000000..cb4de7f
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmProfileCmd.java
new file mode 100644
index 0000000..1d6caf2
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteConditionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteConditionCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteConditionCmd.java
new file mode 100644
index 0000000..43f0fc1
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/DisableAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DisableAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DisableAutoScaleVmGroupCmd.java
new file mode 100644
index 0000000..7552e41
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/EnableAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/EnableAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/EnableAutoScaleVmGroupCmd.java
new file mode 100644
index 0000000..9c63327
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScalePoliciesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScalePoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScalePoliciesCmd.java
new file mode 100644
index 0000000..e8bc831
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmGroupsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmGroupsCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmGroupsCmd.java
new file mode 100644
index 0000000..37d0945
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmProfilesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmProfilesCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmProfilesCmd.java
new file mode 100644
index 0000000..e8554d9
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/user/autoscale/ListConditionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListConditionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListConditionsCmd.java
new file mode 100644
index 0000000..be5b17e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/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.command.user.autoscale;
+
+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;
+    }
+
+}


Mime
View raw message