You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/04 20:32:06 UTC
[2/18] git commit: api_refactor: refactor autoscale apis
api_refactor: refactor autoscale apis
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/feb342ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/feb342ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/feb342ad
Branch: refs/heads/api_refactoring
Commit: feb342ad2364a6237298e200d7eb9866cf004a2a
Parents: 456b852
Author: Rohit Yadav <bh...@apache.org>
Authored: Tue Dec 4 11:30:37 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Tue Dec 4 11:30:37 2012 -0800
----------------------------------------------------------------------
.../api/commands/CreateAutoScalePolicyCmd.java | 170 -----------
.../api/commands/CreateAutoScaleVmGroupCmd.java | 194 ------------
.../api/commands/CreateAutoScaleVmProfileCmd.java | 236 ---------------
.../com/cloud/api/commands/CreateConditionCmd.java | 152 ---------
.../api/commands/DeleteAutoScalePolicyCmd.java | 103 -------
.../api/commands/DeleteAutoScaleVmGroupCmd.java | 103 -------
.../api/commands/DeleteAutoScaleVmProfileCmd.java | 102 -------
.../com/cloud/api/commands/DeleteConditionCmd.java | 109 -------
.../api/commands/DisableAutoScaleVmGroupCmd.java | 102 -------
.../api/commands/EnableAutoScaleVmGroupCmd.java | 102 -------
.../api/commands/ListAutoScalePoliciesCmd.java | 103 -------
.../api/commands/ListAutoScaleVmGroupsCmd.java | 115 -------
.../api/commands/ListAutoScaleVmProfilesCmd.java | 95 ------
.../com/cloud/api/commands/ListConditionsCmd.java | 96 ------
.../com/cloud/api/commands/ListCountersCmd.java | 99 ------
.../api/commands/UpdateAutoScalePolicyCmd.java | 126 --------
.../api/commands/UpdateAutoScaleVmGroupCmd.java | 143 ---------
.../api/commands/UpdateAutoScaleVmProfileCmd.java | 136 ---------
api/src/com/cloud/network/as/AutoScaleService.java | 20 +-
.../command/CreateAutoScalePolicyCmd.java | 170 +++++++++++
.../command/CreateAutoScaleVmGroupCmd.java | 194 ++++++++++++
.../command/CreateAutoScaleVmProfileCmd.java | 236 +++++++++++++++
.../user/autoscale/command/CreateConditionCmd.java | 152 +++++++++
.../command/DeleteAutoScalePolicyCmd.java | 103 +++++++
.../command/DeleteAutoScaleVmGroupCmd.java | 103 +++++++
.../command/DeleteAutoScaleVmProfileCmd.java | 102 +++++++
.../user/autoscale/command/DeleteConditionCmd.java | 109 +++++++
.../command/DisableAutoScaleVmGroupCmd.java | 102 +++++++
.../command/EnableAutoScaleVmGroupCmd.java | 102 +++++++
.../command/ListAutoScalePoliciesCmd.java | 103 +++++++
.../command/ListAutoScaleVmGroupsCmd.java | 115 +++++++
.../command/ListAutoScaleVmProfilesCmd.java | 95 ++++++
.../user/autoscale/command/ListConditionsCmd.java | 96 ++++++
.../user/autoscale/command/ListCountersCmd.java | 99 ++++++
.../command/UpdateAutoScalePolicyCmd.java | 126 ++++++++
.../command/UpdateAutoScaleVmGroupCmd.java | 143 +++++++++
.../command/UpdateAutoScaleVmProfileCmd.java | 136 +++++++++
client/tomcatconf/commands.properties.in | 36 ++--
.../com/cloud/network/as/AutoScaleManagerImpl.java | 23 +-
39 files changed, 2323 insertions(+), 2328 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/com/cloud/api/commands/CreateAutoScalePolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateAutoScalePolicyCmd.java b/api/src/com/cloud/api/commands/CreateAutoScalePolicyCmd.java
deleted file mode 100644
index a921a9b..0000000
--- a/api/src/com/cloud/api/commands/CreateAutoScalePolicyCmd.java
+++ /dev/null
@@ -1,170 +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.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/com/cloud/api/commands/CreateAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateAutoScaleVmGroupCmd.java b/api/src/com/cloud/api/commands/CreateAutoScaleVmGroupCmd.java
deleted file mode 100644
index 30a7d01..0000000
--- a/api/src/com/cloud/api/commands/CreateAutoScaleVmGroupCmd.java
+++ /dev/null
@@ -1,194 +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.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/com/cloud/api/commands/CreateAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateAutoScaleVmProfileCmd.java b/api/src/com/cloud/api/commands/CreateAutoScaleVmProfileCmd.java
deleted file mode 100644
index 7d16973..0000000
--- a/api/src/com/cloud/api/commands/CreateAutoScaleVmProfileCmd.java
+++ /dev/null
@@ -1,236 +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.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/com/cloud/api/commands/CreateConditionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CreateConditionCmd.java b/api/src/com/cloud/api/commands/CreateConditionCmd.java
deleted file mode 100644
index 3c0cf29..0000000
--- a/api/src/com/cloud/api/commands/CreateConditionCmd.java
+++ /dev/null
@@ -1,152 +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 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/com/cloud/api/commands/DeleteAutoScalePolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteAutoScalePolicyCmd.java b/api/src/com/cloud/api/commands/DeleteAutoScalePolicyCmd.java
deleted file mode 100644
index 6cf22c5..0000000
--- a/api/src/com/cloud/api/commands/DeleteAutoScalePolicyCmd.java
+++ /dev/null
@@ -1,103 +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 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/com/cloud/api/commands/DeleteAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteAutoScaleVmGroupCmd.java b/api/src/com/cloud/api/commands/DeleteAutoScaleVmGroupCmd.java
deleted file mode 100644
index 852b351..0000000
--- a/api/src/com/cloud/api/commands/DeleteAutoScaleVmGroupCmd.java
+++ /dev/null
@@ -1,103 +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 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/com/cloud/api/commands/DeleteAutoScaleVmProfileCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteAutoScaleVmProfileCmd.java b/api/src/com/cloud/api/commands/DeleteAutoScaleVmProfileCmd.java
deleted file mode 100644
index f48112b..0000000
--- a/api/src/com/cloud/api/commands/DeleteAutoScaleVmProfileCmd.java
+++ /dev/null
@@ -1,102 +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 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/com/cloud/api/commands/DeleteConditionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteConditionCmd.java b/api/src/com/cloud/api/commands/DeleteConditionCmd.java
deleted file mode 100644
index d09ed6d..0000000
--- a/api/src/com/cloud/api/commands/DeleteConditionCmd.java
+++ /dev/null
@@ -1,109 +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 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/com/cloud/api/commands/DisableAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DisableAutoScaleVmGroupCmd.java b/api/src/com/cloud/api/commands/DisableAutoScaleVmGroupCmd.java
deleted file mode 100644
index 3ca52ed..0000000
--- a/api/src/com/cloud/api/commands/DisableAutoScaleVmGroupCmd.java
+++ /dev/null
@@ -1,102 +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 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/com/cloud/api/commands/EnableAutoScaleVmGroupCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/EnableAutoScaleVmGroupCmd.java b/api/src/com/cloud/api/commands/EnableAutoScaleVmGroupCmd.java
deleted file mode 100644
index 329998a..0000000
--- a/api/src/com/cloud/api/commands/EnableAutoScaleVmGroupCmd.java
+++ /dev/null
@@ -1,102 +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 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/com/cloud/api/commands/ListAutoScalePoliciesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListAutoScalePoliciesCmd.java b/api/src/com/cloud/api/commands/ListAutoScalePoliciesCmd.java
deleted file mode 100644
index 06424d0..0000000
--- a/api/src/com/cloud/api/commands/ListAutoScalePoliciesCmd.java
+++ /dev/null
@@ -1,103 +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.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/com/cloud/api/commands/ListAutoScaleVmGroupsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListAutoScaleVmGroupsCmd.java b/api/src/com/cloud/api/commands/ListAutoScaleVmGroupsCmd.java
deleted file mode 100644
index 6cb3d56..0000000
--- a/api/src/com/cloud/api/commands/ListAutoScaleVmGroupsCmd.java
+++ /dev/null
@@ -1,115 +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.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/com/cloud/api/commands/ListAutoScaleVmProfilesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListAutoScaleVmProfilesCmd.java b/api/src/com/cloud/api/commands/ListAutoScaleVmProfilesCmd.java
deleted file mode 100644
index 987c18c..0000000
--- a/api/src/com/cloud/api/commands/ListAutoScaleVmProfilesCmd.java
+++ /dev/null
@@ -1,95 +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.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/feb342ad/api/src/com/cloud/api/commands/ListConditionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListConditionsCmd.java b/api/src/com/cloud/api/commands/ListConditionsCmd.java
deleted file mode 100644
index c99d627..0000000
--- a/api/src/com/cloud/api/commands/ListConditionsCmd.java
+++ /dev/null
@@ -1,96 +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.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListAccountResourcesCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.ConditionResponse;
-import com.cloud.api.response.CounterResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.network.as.Condition;
-
-@Implementation(description = "List Conditions for the specific user", responseObject = CounterResponse.class)
-public class ListConditionsCmd extends BaseListAccountResourcesCmd {
- public static final Logger s_logger = Logger.getLogger(ListConditionsCmd.class.getName());
- private static final String s_name = "listconditionsresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName = "conditions")
- @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = false, description = "ID of the Condition.")
- private Long id;
-
- @IdentityMapper(entityTableName = "counter")
- @Parameter(name = ApiConstants.COUNTER_ID, type = CommandType.LONG, required = false, description = "Counter-id of the condition.")
- private Long counterId;
-
- @IdentityMapper(entityTableName="autoscale_policies")
- @Parameter(name = ApiConstants.POLICY_ID, type = CommandType.LONG, description = "the ID of the policy")
- private Long policyId;
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public void execute() {
- List<? extends Condition> conditions = null;
- conditions = _autoScaleService.listConditions(this);
- ListResponse<ConditionResponse> response = new ListResponse<ConditionResponse>();
- List<ConditionResponse> cndnResponses = new ArrayList<ConditionResponse>();
- for (Condition cndn : conditions) {
- ConditionResponse cndnResponse = _responseGenerator.createConditionResponse(cndn);
- cndnResponses.add(cndnResponse);
- }
-
- response.setResponses(cndnResponses);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }
-
- // /////////////////////////////////////////////////
- // ///////////////// Accessors ///////////////////////
- // ///////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- public Long getCounterId() {
- return counterId;
- }
-
- public Long getPolicyId() {
- return policyId;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/com/cloud/api/commands/ListCountersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListCountersCmd.java b/api/src/com/cloud/api/commands/ListCountersCmd.java
deleted file mode 100644
index b70a03f..0000000
--- a/api/src/com/cloud/api/commands/ListCountersCmd.java
+++ /dev/null
@@ -1,99 +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.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.CounterResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.network.as.Counter;
-import com.cloud.user.Account;
-
-@Implementation(description = "List the counters", responseObject = CounterResponse.class)
-public class ListCountersCmd extends BaseListCmd {
- public static final Logger s_logger = Logger.getLogger(ListCountersCmd.class.getName());
- private static final String s_name = "counterresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName = "counter")
- @Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "ID of the Counter.")
- private Long id;
-
- @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Name of the counter.")
- private String name;
-
- @Parameter(name = ApiConstants.SOURCE, type = CommandType.STRING, description = "Source of the counter.")
- private String source;
-
- // ///////////////////////////////////////////////////
- // ///////////// API Implementation///////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public void execute() {
- List<? extends Counter> counters = null;
- counters = _autoScaleService.listCounters(this);
- ListResponse<CounterResponse> response = new ListResponse<CounterResponse>();
- List<CounterResponse> ctrResponses = new ArrayList<CounterResponse>();
- for (Counter ctr : counters) {
- CounterResponse ctrResponse = _responseGenerator.createCounterResponse(ctr);
- ctrResponses.add(ctrResponse);
- }
-
- response.setResponses(ctrResponses);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- }
-
- // /////////////////////////////////////////////////
- // ///////////////// Accessors ///////////////////////
- // ///////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- public Long getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getSource() {
- return source;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/feb342ad/api/src/com/cloud/api/commands/UpdateAutoScalePolicyCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateAutoScalePolicyCmd.java b/api/src/com/cloud/api/commands/UpdateAutoScalePolicyCmd.java
deleted file mode 100644
index 0078126..0000000
--- a/api/src/com/cloud/api/commands/UpdateAutoScalePolicyCmd.java
+++ /dev/null
@@ -1,126 +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.AutoScalePolicyResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.network.as.AutoScalePolicy;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description = "Updates an existing autoscale policy.", responseObject = AutoScalePolicyResponse.class)
-public class UpdateAutoScalePolicyCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(UpdateAutoScalePolicyCmd.class.getName());
-
- private static final String s_name = "updateautoscalepolicyresponse";
-
- // ///////////////////////////////////////////////////
- // ////////////// API parameters /////////////////////
- // ///////////////////////////////////////////////////
-
- @Parameter(name = ApiConstants.DURATION, type = CommandType.INTEGER, description = "the duration for which the conditions have to be true before action is taken")
- private Integer duration;
-
- @Parameter(name = ApiConstants.QUIETTIME, type = CommandType.INTEGER, description = "the cool down period for which the policy should not be evaluated after the action has been taken")
- private Integer quietTime;
-
- @IdentityMapper(entityTableName = "conditions")
- @Parameter(name = ApiConstants.CONDITION_IDS, type = CommandType.LIST, collectionType = CommandType.LONG, description = "the list of IDs of the conditions that are being evaluated on every interval")
- private List<Long> conditionIds;
-
- @IdentityMapper(entityTableName = "autoscale_policies")
- @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the autoscale policy")
- private Long id;
-
- @Override
- public void execute() {
- UserContext.current().setEventDetails("AutoScale Policy Id: " + getId());
- AutoScalePolicy result = _autoScaleService.updateAutoScalePolicy(this);
- if (result != null) {
- AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update autoscale policy");
- }
- }
-
- // ///////////////////////////////////////////////////
- // ///////////////// Accessors ///////////////////////
- // ///////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- public Integer getDuration() {
- return duration;
- }
-
- public Integer getQuietTime() {
- return quietTime;
- }
-
-
- public List<Long> getConditionIds() {
- return conditionIds;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- AutoScalePolicy autoScalePolicy = _entityMgr.findById(AutoScalePolicy.class, getId());
- if (autoScalePolicy != null) {
- return autoScalePolicy.getAccountId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are
- // tracked
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_AUTOSCALEPOLICY_UPDATE;
- }
-
- @Override
- public String getEventDescription() {
- return "Updating Auto Scale Policy. Policy Id: " + getId();
- }
-
- @Override
- public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.AutoScalePolicy;
- }
-}