diff --git a/api/src/com/cloud/api/response/AutoScaleVmGroupResponse.java b/api/src/com/cloud/api/response/AutoScaleVmGroupResponse.java index 5e495d16292..c5f25138981 100644 --- a/api/src/com/cloud/api/response/AutoScaleVmGroupResponse.java +++ b/api/src/com/cloud/api/response/AutoScaleVmGroupResponse.java @@ -23,7 +23,7 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled @SerializedName(ApiConstants.ID) @Param(description = "the autoscale vm group ID") - private IdentityProxy id = new IdentityProxy("autoscale_groups"); + private IdentityProxy id = new IdentityProxy("autoscale_vmgroups"); @SerializedName(ApiConstants.LBID) @Param(description = "the load balancer rule ID") diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java index 085f6de1699..7eaa09bd230 100644 --- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java +++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java @@ -205,12 +205,13 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { sc.setParameters("ids", policyIds.toArray(new Object[0])); List policies = _autoScalePolicyDao.search(sc, null); - Integer prevQuietTime = 0; + int prevQuietTime = 0; for (AutoScalePolicyVO policy : policies) { - Integer quietTime = policy.getQuietTime(); - if (prevQuietTime == 0) + int quietTime = policy.getQuietTime(); + if (prevQuietTime == 0) { prevQuietTime = quietTime; + } Integer duration = policy.getDuration(); if (interval != null && duration < interval) { throw new InvalidParameterValueException("duration - " + duration + " specified in a policy cannot be less than vm group's interval - " + interval); @@ -226,12 +227,12 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { if (scaleUpPolicies) { if (!isAutoScaleScaleUpPolicy(policy)) { - throw new InvalidParameterValueException("Only provision policies can be specified in scaleuppolicyids"); + throw new InvalidParameterValueException("Only scaleup policies can be specified in scaleuppolicyids"); } } else { if (isAutoScaleScaleUpPolicy(policy)) { - throw new InvalidParameterValueException("Only de-provision policies can be specified in scaledownpolicyids"); + throw new InvalidParameterValueException("Only scaledown policies can be specified in scaledownpolicyids"); } } List policyConditionMapVOs = _autoScalePolicyConditionMapDao.listByAll(policy.getId(), null); @@ -241,7 +242,6 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { Counter counter = _counterDao.findById(condition.getCounterid()); counters.add(counter); } - policies.add(policy); } return policies; } @@ -424,7 +424,7 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { action = action.toLowerCase(); if (!NetUtils.isValidAutoScaleAction(action)) { - throw new InvalidParameterValueException("action is invalid, only 'provision' and 'de-provision' is supported"); + throw new InvalidParameterValueException("action is invalid, only 'scaleup' and 'scaledown' is supported"); } AutoScalePolicyVO policyVO = new AutoScalePolicyVO(cmd.getDomainId(), cmd.getAccountId(), duration, quietTime, action); @@ -666,8 +666,7 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { Transaction txn = Transaction.currentTxn(); txn.start(); - if (success) - _autoScaleVmGroupDao.remove(id); + success = _autoScaleVmGroupDao.remove(id); if (success) success = _autoScaleVmGroupPolicyMapDao.removeByGroupId(id); diff --git a/server/src/com/cloud/network/as/AutoScaleVmGroupVO.java b/server/src/com/cloud/network/as/AutoScaleVmGroupVO.java index c34dba58e4a..40e7dca0419 100644 --- a/server/src/com/cloud/network/as/AutoScaleVmGroupVO.java +++ b/server/src/com/cloud/network/as/AutoScaleVmGroupVO.java @@ -81,6 +81,7 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup { public AutoScaleVmGroupVO(long lbRuleId, long zoneId, long domainId, long accountId, Integer minMembers, Integer maxMembers, Integer memberPort, Integer interval, long profileId, String state) { this.uuid = UUID.randomUUID().toString(); + this.loadBalancerId = lbRuleId; this.minMembers = minMembers; this.maxMembers = maxMembers; this.memberPort = memberPort; @@ -177,4 +178,7 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup { this.interval = interval; } + public void setLoadBalancerId(Long loadBalancerId) { + this.loadBalancerId = loadBalancerId; + } } diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index a9f1541a336..d74fc3cc247 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -2409,6 +2409,7 @@ CREATE TABLE `cloud`.`autoscale_vmgroups` ( `load_balancer_id` bigint unsigned NOT NULL, `min_members` int unsigned DEFAULT 1, `max_members` int unsigned NOT NULL, + `member_port` int unsigned NOT NULL, `interval` int unsigned NOT NULL, `profile_id` bigint unsigned NOT NULL, `state` varchar(255) NOT NULL COMMENT 'enabled or disabled, a vmgroup is disabled to stop autoscaling activity',