mirror of https://github.com/apache/cloudstack.git
AutoScale. AutoScaleVmGroup Response corrected. Responses tested for list commands of autoscale entities
This commit is contained in:
parent
3bee3fd4fd
commit
c826fa295b
|
|
@ -8,7 +8,7 @@
|
|||
// 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.
|
||||
//
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api;
|
||||
|
||||
|
|
@ -338,7 +338,7 @@ public class ApiConstants {
|
|||
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_NAME = "vsmdevicename";
|
||||
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_STATE = "vsmdevicestate";
|
||||
// Would we need to have a capacity field for Cisco N1KV VSM? Max hosts managed by it perhaps? May remove this
|
||||
// later.
|
||||
// later.
|
||||
public static final String EXTERNAL_SWITCH_MGMT_DEVICE_CAPACITY = "vsmdevicecapacity";
|
||||
public static final String CISCO_NEXUS_VSM_NAME = "vsmname";
|
||||
public static final String VSM_USERNAME = "vsmusername";
|
||||
|
|
@ -389,6 +389,8 @@ public class ApiConstants {
|
|||
public static final String CS_URL = "csurl";
|
||||
public static final String SCALEUP_POLICY_IDS = "scaleuppolicyids";
|
||||
public static final String SCALEDOWN_POLICY_IDS = "scaledownpolicyids";
|
||||
public static final String SCALEUP_POLICIES = "scaleuppolicies";
|
||||
public static final String SCALEDOWN_POLICIES = "scaledownpolicies";
|
||||
public static final String INTERVAL = "interval";
|
||||
public static final String QUIETTIME = "quiettime";
|
||||
public static final String ACTION = "action";
|
||||
|
|
|
|||
|
|
@ -39,15 +39,15 @@ public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd {
|
|||
// ////////////// 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;
|
||||
|
||||
@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;
|
||||
|
||||
@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;
|
||||
|
|
@ -139,6 +139,10 @@ public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
AutoScalePolicy result = _entityMgr.findById(AutoScalePolicy.class, getEntityId());
|
||||
AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -146,9 +150,6 @@ public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd {
|
|||
AutoScalePolicy result = _autoScaleService.createAutoScalePolicy(this);
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create AutoScale Policy");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
|||
private Integer interval;
|
||||
|
||||
@IdentityMapper(entityTableName="autoscale_policies")
|
||||
@Parameter(name=ApiConstants.SCALEUP_POLICY_IDS, type=CommandType.LIST, collectionType=CommandType.LONG, required=true, description="list of provision 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 de-provision 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")
|
||||
|
|
@ -72,7 +72,7 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public String getEntityTable() {
|
||||
return "autoscale_vm_groups";
|
||||
return "autoscale_vmgroups";
|
||||
}
|
||||
|
||||
public int getMinMembers() {
|
||||
|
|
@ -172,9 +172,7 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd {
|
|||
AutoScaleVmGroup vmGroup = null;
|
||||
try
|
||||
{
|
||||
// success = _autoScaleService.configureAutoScaleVmGroup(this);
|
||||
// TODO, this will be removed later, when above line is uncommented
|
||||
success = true;
|
||||
success = _autoScaleService.configureAutoScaleVmGroup(this);
|
||||
if(success) {
|
||||
vmGroup = _entityMgr.findById(AutoScaleVmGroup.class, getEntityId());
|
||||
AutoScaleVmGroupResponse responseObject = _responseGenerator.createAutoScaleVmGroupResponse(vmGroup);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
@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, required = true, description = "the time allowed for existing connections to get closed before a vm is destroyed")
|
||||
@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.SNMP_COMMUNITY, type = CommandType.STRING, description = "snmp community string to be used to contact a virtual machine deployed by this profile")
|
||||
|
|
@ -72,7 +72,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
@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;
|
||||
|
||||
@Parameter(name = ApiConstants.CS_URL, type = CommandType.STRING, description = "the URL including port of the CloudStack Management Server example: http://server.cloud.com:8080")
|
||||
@Parameter(name = ApiConstants.CS_URL, type = CommandType.STRING, description = "the API URL including port of the CloudStack Management Server example: http://server.cloud.com:8080/client/api?")
|
||||
private String csUrl;
|
||||
|
||||
private Map<String, String> otherDeployParamMap;
|
||||
|
|
@ -226,6 +226,10 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
AutoScaleVmProfile result = _entityMgr.findById(AutoScaleVmProfile.class, getEntityId());
|
||||
AutoScaleVmProfileResponse response = _responseGenerator.createAutoScaleVmProfileResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -234,9 +238,6 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
AutoScaleVmProfile result = _autoScaleService.createAutoScaleVmProfile(this);
|
||||
if (result != null) {
|
||||
this.setEntityId(result.getId());
|
||||
AutoScaleVmProfileResponse response = _responseGenerator.createAutoScaleVmProfileResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Autoscale Vm Profile");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,9 +71,6 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
if (condition != null) {
|
||||
this.setEntityId(condition.getId());
|
||||
ConditionResponse response = _responseGenerator.createConditionResponse(condition);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create condition.");
|
||||
}
|
||||
|
|
@ -81,6 +78,10 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
Condition condition = _entityMgr.findById(Condition.class, getEntityId());
|
||||
ConditionResponse response = _responseGenerator.createConditionResponse(condition);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
// /////////////////////////////////////////////////
|
||||
|
|
@ -101,10 +102,17 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// 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.
|
||||
//
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
|
|
@ -25,10 +25,6 @@ public class AutoScalePolicyResponse extends BaseResponse implements ControlledE
|
|||
@Param(description = "the autoscale policy ID")
|
||||
private IdentityProxy id = new IdentityProxy("autoscale_policies");
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID)
|
||||
@Param(description = "the availability zone of the autoscale policy")
|
||||
private IdentityProxy zoneId = new IdentityProxy("data_center");
|
||||
|
||||
@SerializedName(ApiConstants.ACTION)
|
||||
@Param(description = "the action to be executed if all the conditions evaluate to true for the specified duration.")
|
||||
private String action;
|
||||
|
|
@ -37,10 +33,6 @@ public class AutoScalePolicyResponse extends BaseResponse implements ControlledE
|
|||
@Param(description = "the duration for which the conditions have to be true before action is taken")
|
||||
private Integer duration;
|
||||
|
||||
@SerializedName(ApiConstants.INTERVAL)
|
||||
@Param(description = "the frequency at which the conditions have to be evaluated")
|
||||
private Integer interval;
|
||||
|
||||
@SerializedName(ApiConstants.QUIETTIME)
|
||||
@Param(description = "the cool down period for which the policy should not be evaluated after the action has been taken")
|
||||
private Integer quietTime;
|
||||
|
|
@ -68,32 +60,20 @@ public class AutoScalePolicyResponse extends BaseResponse implements ControlledE
|
|||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setZoneId(IdentityProxy zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public void setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public void setInterval(Integer interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
public void setQuietTime(Integer quietTime) {
|
||||
this.quietTime = quietTime;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public void setConditions(List<ConditionResponse> conditions) {
|
||||
this.conditions = conditions;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId.setValue(zoneId);
|
||||
public void setConditions(List<ConditionResponse> conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -33,28 +33,28 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled
|
|||
@Param(description = "the autoscale profile that contains information about the vms in the vm group.")
|
||||
private IdentityProxy profileId = new IdentityProxy("autoscale_vmprofiles");
|
||||
|
||||
@SerializedName(ApiConstants.DURATION)
|
||||
@Param(description = "the duration for which the conditions have to be true before action is taken")
|
||||
private Integer minMembers;
|
||||
@SerializedName(ApiConstants.MIN_MEMBERS)
|
||||
@Param(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;
|
||||
|
||||
@SerializedName(ApiConstants.MAX_MEMBERS)
|
||||
@Param(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;
|
||||
|
||||
@SerializedName(ApiConstants.INTERVAL)
|
||||
@Param(description = "the frequency at which the conditions have to be evaluated")
|
||||
private Integer maxMembers;
|
||||
private int interval;
|
||||
|
||||
@SerializedName(ApiConstants.INTERVAL)
|
||||
@Param(description = "the frequency at which the conditions have to be evaluated")
|
||||
private Integer interval;
|
||||
|
||||
@SerializedName(ApiConstants.INTERVAL)
|
||||
@SerializedName(ApiConstants.STATE)
|
||||
@Param(description = "the current state of the AutoScale Vm Group")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.SCALEUP_POLICY_IDS)
|
||||
@Param(description = "list of provision autoscale policies")
|
||||
@SerializedName(ApiConstants.SCALEUP_POLICIES)
|
||||
@Param(description = "list of scaleup autoscale policies")
|
||||
private List<AutoScalePolicyResponse> scaleUpPolicies;
|
||||
|
||||
@SerializedName(ApiConstants.SCALEDOWN_POLICY_IDS)
|
||||
@Param(description = "list of de-provision autoscale policies")
|
||||
@SerializedName(ApiConstants.SCALEDOWN_POLICIES)
|
||||
@Param(description = "list of scaledown autoscale policies")
|
||||
private List<AutoScalePolicyResponse> scaleDownPolicies;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account owning the instance group")
|
||||
|
|
@ -88,11 +88,11 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled
|
|||
this.profileId.setValue(profileId);
|
||||
}
|
||||
|
||||
public void setMinMembers(Integer minMembers) {
|
||||
public void setMinMembers(int minMembers) {
|
||||
this.minMembers = minMembers;
|
||||
}
|
||||
|
||||
public void setMaxMembers(Integer maxMembers) {
|
||||
public void setMaxMembers(int maxMembers) {
|
||||
this.maxMembers = maxMembers;
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled
|
|||
this.state = state;
|
||||
}
|
||||
|
||||
public void setInterval(Integer interval) {
|
||||
public void setInterval(int interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,153 +1,154 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by 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.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class AutoScaleVmProfileResponse extends BaseResponse implements ControlledEntityResponse {
|
||||
|
||||
@SerializedName(ApiConstants.ID)
|
||||
@Param(description = "the autoscale vm profile ID")
|
||||
private IdentityProxy id = new IdentityProxy("autoscale_vmprofiles");
|
||||
|
||||
/* Parameters related to deploy virtual machine */
|
||||
@SerializedName(ApiConstants.ZONE_ID)
|
||||
@Param(description = "the availability zone to be used while deploying a virtual machine")
|
||||
private IdentityProxy zoneId = new IdentityProxy("data_center");
|
||||
|
||||
@SerializedName(ApiConstants.SERVICE_OFFERING_ID)
|
||||
@Param(description = "the service offering to be used while deploying a virtual machine")
|
||||
private IdentityProxy serviceOfferingId = new IdentityProxy("disk_offering");
|
||||
|
||||
@SerializedName(ApiConstants.TEMPLATE_ID)
|
||||
@Param(description = "the template to be used while deploying a virtual machine")
|
||||
private IdentityProxy templateId = new IdentityProxy("vm_template");
|
||||
|
||||
@SerializedName(ApiConstants.OTHER_DEPLOY_PARAMS)
|
||||
@Param(description = "parameters other than zoneId/serviceOfferringId/templateId to be used while deploying a virtual machine")
|
||||
private String otherDeployParams;
|
||||
|
||||
@SerializedName(ApiConstants.CS_URL)
|
||||
@Param(description = "the URL including port of the CloudStack Management Server example: http://server.cloud.com:8080")
|
||||
private String csUrl;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT)
|
||||
@Param(description = "the account owning the instance group")
|
||||
private String accountName;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID)
|
||||
@Param(description = "the project id vm profile")
|
||||
private IdentityProxy projectId = new IdentityProxy("projects");
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT)
|
||||
@Param(description = "the project name of the vm profile")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
@Param(description = "the domain ID of the vm profile")
|
||||
private IdentityProxy domainId = new IdentityProxy("domain");
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN)
|
||||
@Param(description = "the domain name of the vm profile")
|
||||
private String domainName;
|
||||
|
||||
/* Parameters related to destroying a virtual machine */
|
||||
@SerializedName(ApiConstants.AUTOSCALE_VM_DESTROY_TIME)
|
||||
@Param(description = "the time allowed for existing connections to get closed before a vm is destroyed")
|
||||
private Integer destroyVmGraceperiod;
|
||||
|
||||
/* Parameters related to a running virtual machine - monitoring aspects */
|
||||
@SerializedName(ApiConstants.SNMP_COMMUNITY)
|
||||
@Param(description = "snmp community string to be used to contact a virtual machine deployed by this profile")
|
||||
private String snmpCommunity;
|
||||
|
||||
@SerializedName(ApiConstants.SNMP_PORT)
|
||||
@Param(description = "port at which the snmp agent is listening in a virtual machine deployed by this profile")
|
||||
private Integer snmpPort;
|
||||
|
||||
@SerializedName(ApiConstants.AUTOSCALE_USER_ID)
|
||||
@Param(description = "the ID of the user used to launch and destroy the VMs")
|
||||
private IdentityProxy autoscaleUserId = new IdentityProxy("user");
|
||||
|
||||
public AutoScaleVmProfileResponse() {
|
||||
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId.setValue(zoneId);
|
||||
}
|
||||
|
||||
public void setServiceOfferingId(Long serviceOfferingId) {
|
||||
this.serviceOfferingId.setValue(serviceOfferingId);
|
||||
}
|
||||
|
||||
public void setTemplateId(Long templateId) {
|
||||
this.templateId.setValue(templateId);
|
||||
}
|
||||
|
||||
public void setOtherDeployParams(String otherDeployParams) {
|
||||
this.otherDeployParams = otherDeployParams;
|
||||
}
|
||||
|
||||
public void setSnmpCommunity(String snmpCommunity) {
|
||||
this.snmpCommunity = snmpCommunity;
|
||||
}
|
||||
|
||||
public void setSnmpPort(Integer snmpPort) {
|
||||
this.snmpPort = snmpPort;
|
||||
}
|
||||
|
||||
public void setCsUrl(String csUrl) {
|
||||
this.csUrl = csUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId.setValue(domainId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectId(Long projectId) {
|
||||
this.projectId.setValue(projectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public void setAutoscaleUserId(Long autoscaleUserId) {
|
||||
this.autoscaleUserId.setValue(autoscaleUserId);
|
||||
}
|
||||
|
||||
public void setDestroyVmGraceperiod(Integer destroyVmGraceperiod) {
|
||||
this.destroyVmGraceperiod = destroyVmGraceperiod;
|
||||
}
|
||||
}
|
||||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by 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.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class AutoScaleVmProfileResponse extends BaseResponse implements ControlledEntityResponse {
|
||||
|
||||
@SerializedName(ApiConstants.ID)
|
||||
@Param(description = "the autoscale vm profile ID")
|
||||
private IdentityProxy id = new IdentityProxy("autoscale_vmprofiles");
|
||||
|
||||
/* Parameters related to deploy virtual machine */
|
||||
@SerializedName(ApiConstants.ZONE_ID)
|
||||
@Param(description = "the availability zone to be used while deploying a virtual machine")
|
||||
private IdentityProxy zoneId = new IdentityProxy("data_center");
|
||||
|
||||
@SerializedName(ApiConstants.SERVICE_OFFERING_ID)
|
||||
@Param(description = "the service offering to be used while deploying a virtual machine")
|
||||
private IdentityProxy serviceOfferingId = new IdentityProxy("disk_offering");
|
||||
|
||||
@SerializedName(ApiConstants.TEMPLATE_ID)
|
||||
@Param(description = "the template to be used while deploying a virtual machine")
|
||||
private IdentityProxy templateId = new IdentityProxy("vm_template");
|
||||
|
||||
@SerializedName(ApiConstants.OTHER_DEPLOY_PARAMS)
|
||||
@Param(description = "parameters other than zoneId/serviceOfferringId/templateId to be used while deploying a virtual machine")
|
||||
private String otherDeployParams;
|
||||
|
||||
/* Parameters related to destroying a virtual machine */
|
||||
@SerializedName(ApiConstants.AUTOSCALE_VM_DESTROY_TIME)
|
||||
@Param(description = "the time allowed for existing connections to get closed before a vm is destroyed")
|
||||
private Integer destroyVmGraceperiod;
|
||||
|
||||
/* Parameters related to a running virtual machine - monitoring aspects */
|
||||
@SerializedName(ApiConstants.SNMP_COMMUNITY)
|
||||
@Param(description = "snmp community string to be used to contact a virtual machine deployed by this profile")
|
||||
private String snmpCommunity;
|
||||
|
||||
@SerializedName(ApiConstants.SNMP_PORT)
|
||||
@Param(description = "port at which the snmp agent is listening in a virtual machine deployed by this profile")
|
||||
private Integer snmpPort;
|
||||
|
||||
@SerializedName(ApiConstants.AUTOSCALE_USER_ID)
|
||||
@Param(description = "the ID of the user used to launch and destroy the VMs")
|
||||
private IdentityProxy autoscaleUserId = new IdentityProxy("user");
|
||||
|
||||
@Parameter(name = ApiConstants.CS_URL, type = CommandType.STRING, description = "the API URL including port of the CloudStack Management Server example: http://server.cloud.com:8080/client/api?")
|
||||
private String csUrl;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT)
|
||||
@Param(description = "the account owning the instance group")
|
||||
private String accountName;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID)
|
||||
@Param(description = "the project id vm profile")
|
||||
private IdentityProxy projectId = new IdentityProxy("projects");
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT)
|
||||
@Param(description = "the project name of the vm profile")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
@Param(description = "the domain ID of the vm profile")
|
||||
private IdentityProxy domainId = new IdentityProxy("domain");
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN)
|
||||
@Param(description = "the domain name of the vm profile")
|
||||
private String domainName;
|
||||
|
||||
public AutoScaleVmProfileResponse() {
|
||||
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setZoneId(Long zoneId) {
|
||||
this.zoneId.setValue(zoneId);
|
||||
}
|
||||
|
||||
public void setServiceOfferingId(Long serviceOfferingId) {
|
||||
this.serviceOfferingId.setValue(serviceOfferingId);
|
||||
}
|
||||
|
||||
public void setTemplateId(Long templateId) {
|
||||
this.templateId.setValue(templateId);
|
||||
}
|
||||
|
||||
public void setOtherDeployParams(String otherDeployParams) {
|
||||
this.otherDeployParams = otherDeployParams;
|
||||
}
|
||||
|
||||
public void setSnmpCommunity(String snmpCommunity) {
|
||||
this.snmpCommunity = snmpCommunity;
|
||||
}
|
||||
|
||||
public void setSnmpPort(Integer snmpPort) {
|
||||
this.snmpPort = snmpPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId.setValue(domainId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectId(Long projectId) {
|
||||
this.projectId.setValue(projectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public void setAutoscaleUserId(Long autoscaleUserId) {
|
||||
this.autoscaleUserId.setValue(autoscaleUserId);
|
||||
}
|
||||
|
||||
public void setDestroyVmGraceperiod(Integer destroyVmGraceperiod) {
|
||||
this.destroyVmGraceperiod = destroyVmGraceperiod;
|
||||
}
|
||||
|
||||
public void setCsUrl(String csUrl) {
|
||||
this.csUrl = csUrl;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3796,6 +3796,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setDestroyVmGraceperiod(profile.getDestroyVmGraceperiod());
|
||||
response.setAutoscaleUserId(profile.getAutoScaleUserId());
|
||||
response.setCsUrl(profile.getCsUrl());
|
||||
response.setObjectName("autoscalevmprofile");
|
||||
|
||||
// Populates the account information in the response
|
||||
populateOwner(response, profile);
|
||||
return response;
|
||||
|
|
@ -3814,6 +3816,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
conditions.add(createConditionResponse(vo));
|
||||
}
|
||||
response.setConditions(conditions);
|
||||
response.setObjectName("autoscalepolicy");
|
||||
|
||||
// Populates the account information in the response
|
||||
populateOwner(response, policy);
|
||||
|
|
@ -3836,6 +3839,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
List<AutoScalePolicyResponse> scaleDownPoliciesResponse = new ArrayList<AutoScalePolicyResponse>();
|
||||
response.setScaleUpPolicies(scaleUpPoliciesResponse);
|
||||
response.setScaleDownPolicies(scaleDownPoliciesResponse);
|
||||
response.setObjectName("autoscalevmgroup");
|
||||
|
||||
// Fetch policies for vmgroup
|
||||
List<AutoScalePolicy> scaleUpPolicies = new ArrayList<AutoScalePolicy>();
|
||||
|
|
@ -3848,6 +3852,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
for (AutoScalePolicy autoScalePolicy : scaleDownPolicies) {
|
||||
scaleDownPoliciesResponse.add(createAutoScalePolicyResponse(autoScalePolicy));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
@ -3947,64 +3952,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
return response;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* @Override
|
||||
* public CounterResponse createCounterResponse(Counter counter) {
|
||||
* CounterResponse response = new CounterResponse();
|
||||
* response.setId(counter.getId());
|
||||
* response.setSource(counter.getSource().toString());
|
||||
* response.setName(counter.getName());
|
||||
* response.setValue(counter.getValue());
|
||||
* response.setZoneId(counter.getZoneId());
|
||||
* response.setObjectName("counter");
|
||||
*
|
||||
* response.setVpnGatewayId(result.getVpnGatewayId());
|
||||
* Long vpnGatewayId = result.getVpnGatewayId();
|
||||
* if(vpnGatewayId != null) {
|
||||
* Site2SiteVpnGatewayVO vpnGateway = ApiDBUtils.findVpnGatewayById(vpnGatewayId);
|
||||
*
|
||||
* long ipId = vpnGateway.getAddrId();
|
||||
* IPAddressVO ipObj = ApiDBUtils.findIpAddressById(ipId);
|
||||
* response.setIp(ipObj.getAddress().addr());
|
||||
* }
|
||||
*
|
||||
* response.setCustomerGatewayId(result.getCustomerGatewayId());
|
||||
* Long customerGatewayId = result.getCustomerGatewayId();
|
||||
* if(customerGatewayId != null) {
|
||||
* Site2SiteCustomerGatewayVO customerGateway = ApiDBUtils.findCustomerGatewayById(customerGatewayId);
|
||||
* response.setGatewayIp(customerGateway.getGatewayIp());
|
||||
* response.setGuestCidrList(customerGateway.getGuestCidrList());
|
||||
* response.setIpsecPsk(customerGateway.getIpsecPsk());
|
||||
* response.setIkePolicy(customerGateway.getIkePolicy());
|
||||
* response.setEspPolicy(customerGateway.getEspPolicy());
|
||||
* response.setLifetime(customerGateway.getLifetime());
|
||||
* }
|
||||
*
|
||||
* response.setCreated(result.getCreated());
|
||||
* response.setRemoved(result.getRemoved());
|
||||
* response.setObjectName("vpnconnection");
|
||||
* return response;
|
||||
* }
|
||||
*/
|
||||
|
||||
// @Override
|
||||
// public ConditionResponse createConditionResponse(Condition condition) {
|
||||
// ConditionResponse response = new ConditionResponse();
|
||||
// response.setId(condition.getId());
|
||||
// CounterResponse counter;
|
||||
// counter = createCounterResponse(ApiDBUtils.getCounter(condition.getCounterid()));
|
||||
// response.setCounter(counter);
|
||||
// response.setRelationalOperator(condition.getRelationalOperator().toString());
|
||||
// response.setThreshold(condition.getThreshold());
|
||||
// Account account = ApiDBUtils.findAccountById(condition.getAccountId());
|
||||
// response.setZoneId(condition.getZoneId());
|
||||
// response.setObjectName("condition");
|
||||
//
|
||||
// populateOwner(response, condition);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public CounterResponse createCounterResponse(Counter counter) {
|
||||
CounterResponse response = new CounterResponse();
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
throw new InvalidParameterValueException("Unable to find " + paramName);
|
||||
}
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, (ControlledEntity) vo);
|
||||
_accountMgr.checkAccess(caller, null, false, (ControlledEntity) vo);
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
|
@ -301,9 +301,9 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
if (csUrl == null) {
|
||||
String mgmtIP = _configDao.getValue(Config.ManagementHostIPAdr.key());
|
||||
csUrl = "http://" + mgmtIP + ":8080/client/api?";
|
||||
}
|
||||
else {
|
||||
csUrl += "/client/api?";
|
||||
} else {
|
||||
if(!csUrl.endsWith("?"))
|
||||
csUrl += "?";
|
||||
}
|
||||
|
||||
AutoScaleVmProfileVO profileVO = new AutoScaleVmProfileVO(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getServiceOfferingId(), cmd.getTemplateId(), cmd.getOtherDeployParams(),
|
||||
|
|
@ -390,8 +390,8 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
}
|
||||
|
||||
private AutoScalePolicyVO checkValidityAndPersist(AutoScalePolicyVO autoScalePolicyVO, List<Long> conditionIds) {
|
||||
Integer duration = autoScalePolicyVO.getDuration();
|
||||
Integer quietTime = autoScalePolicyVO.getQuietTime();
|
||||
int duration = autoScalePolicyVO.getDuration();
|
||||
int quietTime = autoScalePolicyVO.getQuietTime();
|
||||
|
||||
if (duration < 0) {
|
||||
throw new InvalidParameterValueException("duration is an invalid value: " + duration);
|
||||
|
|
@ -447,7 +447,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEPOLICY_CREATE, eventDescription = "creating autoscale policy")
|
||||
public AutoScalePolicy createAutoScalePolicy(CreateAutoScalePolicyCmd cmd) {
|
||||
|
||||
Integer duration = cmd.getDuration();
|
||||
int duration = cmd.getDuration();
|
||||
Integer quietTime = cmd.getQuietTime();
|
||||
String action = cmd.getAction();
|
||||
|
||||
|
|
@ -503,7 +503,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
if (owner == null) {
|
||||
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
|
||||
}
|
||||
_accountMgr.checkAccess(caller, null, true, owner);
|
||||
_accountMgr.checkAccess(caller, null, false, owner);
|
||||
}
|
||||
|
||||
private class SearchWrapper<VO extends ControlledEntity> {
|
||||
|
|
@ -611,10 +611,10 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
if (!vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
|
||||
throw new InvalidParameterValueException("The AutoScale Policy can be updated only if the Vm Group it is associated with is disabled in state");
|
||||
}
|
||||
if(vmGroupVO.getInterval() < duration) {
|
||||
if(vmGroupVO.getInterval() < policy.getDuration()) {
|
||||
throw new InvalidParameterValueException("duration is less than the associated AutoScaleVmGroup's interval");
|
||||
}
|
||||
if(vmGroupVO.getInterval() < quietTime) {
|
||||
if(vmGroupVO.getInterval() < policy.getQuietTime()) {
|
||||
throw new InvalidParameterValueException("quietTime is less than the associated AutoScaleVmGroup's interval");
|
||||
}
|
||||
}
|
||||
|
|
@ -674,6 +674,11 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
public boolean configureAutoScaleVmGroup(long vmGroupid) {
|
||||
AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
|
||||
|
||||
/* TODO remove later */
|
||||
if(true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isLoadBalancerBasedAutoScaleVmGroup(vmGroup)) {
|
||||
return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue