diff --git a/api/src/com/cloud/network/as/AutoScaleVmGroup.java b/api/src/com/cloud/network/as/AutoScaleVmGroup.java index e8b328fc267..14c761593b1 100644 --- a/api/src/com/cloud/network/as/AutoScaleVmGroup.java +++ b/api/src/com/cloud/network/as/AutoScaleVmGroup.java @@ -53,4 +53,6 @@ public interface AutoScaleVmGroup extends ControlledEntity, InternalIdentity { String getUuid(); + boolean isDisplay(); + } diff --git a/api/src/com/cloud/network/as/AutoScaleVmProfile.java b/api/src/com/cloud/network/as/AutoScaleVmProfile.java index 0577080a316..6e0b5ffb91b 100644 --- a/api/src/com/cloud/network/as/AutoScaleVmProfile.java +++ b/api/src/com/cloud/network/as/AutoScaleVmProfile.java @@ -48,4 +48,6 @@ public interface AutoScaleVmProfile extends ControlledEntity, InternalIdentity { public long getAutoScaleUserId(); + boolean isDisplay(); + } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java index 55479748990..ab6d8473c2c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java @@ -18,8 +18,7 @@ package org.apache.cloudstack.api.command.user.autoscale; import java.util.List; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -31,6 +30,7 @@ import org.apache.cloudstack.api.response.AutoScalePolicyResponse; import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse; import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse; import org.apache.cloudstack.api.response.FirewallRuleResponse; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; @@ -95,6 +95,9 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd { description = "the autoscale profile that contains information about the vms in the vm group.") private long profileId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the group to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -178,6 +181,10 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd { return ApiCommandJobType.AutoScaleVmGroup; } + public Boolean getDisplay() { + return display; + } + @Override public void create() throws ResourceAllocationException { AutoScaleVmGroup result = _autoScaleService.createAutoScaleVmGroup(this); diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java index bee1b22ea85..06d86ec9b7f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java @@ -19,8 +19,7 @@ package org.apache.cloudstack.api.command.user.autoscale; import java.util.HashMap; import java.util.Map; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -34,6 +33,7 @@ import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.UserResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; @@ -97,6 +97,9 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd { description = "the ID of the user used to launch and destroy the VMs") private Long autoscaleUserId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the profile to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + private Map otherDeployParamMap; // /////////////////////////////////////////////////// @@ -125,6 +128,10 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd { return templateId; } + public Boolean getDisplay() { + return display; + } + public Map getCounterParamList() { return counterParamList; } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java index 628bb8a1318..0c8dc1c63de 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java @@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.user.autoscale; import java.util.List; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -79,6 +80,9 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCustomIdCmd { description = "the ID of the autoscale group") private Long id; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the group to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////// API Implementation/////////////////// // /////////////////////////////////////////////////// @@ -124,6 +128,10 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCustomIdCmd { return scaleDownPolicyIds; } + public Boolean getDisplay() { + return display; + } + @Override public String getEventType() { return EventTypes.EVENT_AUTOSCALEVMGROUP_UPDATE; diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java index d6405c1d884..20d4d0ef4c2 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java @@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.user.autoscale; import java.util.Map; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -75,6 +76,9 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCustomIdCmd { description = "the ID of the user used to launch and destroy the VMs") private Long autoscaleUserId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the profile to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////// API Implementation/////////////////// // /////////////////////////////////////////////////// @@ -116,6 +120,10 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCustomIdCmd { return destroyVmGraceperiod; } + public Boolean getDisplay() { + return display; + } + @Override public String getEventType() { return EventTypes.EVENT_AUTOSCALEVMPROFILE_UPDATE; diff --git a/api/src/org/apache/cloudstack/api/response/AutoScaleVmGroupResponse.java b/api/src/org/apache/cloudstack/api/response/AutoScaleVmGroupResponse.java index a88325f98b0..572d4626fd9 100644 --- a/api/src/org/apache/cloudstack/api/response/AutoScaleVmGroupResponse.java +++ b/api/src/org/apache/cloudstack/api/response/AutoScaleVmGroupResponse.java @@ -18,14 +18,14 @@ package org.apache.cloudstack.api.response; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.as.AutoScaleVmGroup; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = AutoScaleVmGroup.class) public class AutoScaleVmGroupResponse extends BaseResponse implements ControlledEntityResponse { @@ -86,6 +86,10 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled @Param(description = "the domain name of the vm profile") private String domainName; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is group for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public AutoScaleVmGroupResponse() { } @@ -155,4 +159,8 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled public void setProjectName(String projectName) { this.projectName = projectName; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java b/api/src/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java index e1c33e7881b..2c219357150 100644 --- a/api/src/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java +++ b/api/src/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java @@ -20,8 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd.CommandType; import org.apache.cloudstack.api.BaseResponse; @@ -31,6 +30,7 @@ import org.apache.cloudstack.api.Parameter; import com.cloud.network.as.AutoScaleVmProfile; import com.cloud.serializer.Param; import com.cloud.utils.Pair; +import com.google.gson.annotations.SerializedName; @EntityReference(value = AutoScaleVmProfile.class) public class AutoScaleVmProfileResponse extends BaseResponse implements ControlledEntityResponse { @@ -97,8 +97,11 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll @Param(description = "the domain name of the vm profile") private String domainName; - public AutoScaleVmProfileResponse() { + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is profile for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public AutoScaleVmProfileResponse() { } @Override @@ -171,4 +174,8 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll public void setCsUrl(String csUrl) { this.csUrl = csUrl; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/FirewallResponse.java b/api/src/org/apache/cloudstack/api/response/FirewallResponse.java index 14fabfc7390..4c1342a7ecb 100644 --- a/api/src/org/apache/cloudstack/api/response/FirewallResponse.java +++ b/api/src/org/apache/cloudstack/api/response/FirewallResponse.java @@ -76,7 +76,7 @@ public class FirewallResponse extends BaseResponse { private List tags; @SerializedName(ApiConstants.FOR_DISPLAY) - @Param(description = "is vpc for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + @Param(description = "is rule for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) private Boolean forDisplay; public void setId(String id) { diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java index 96502497266..6694f64ec86 100644 --- a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java +++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java @@ -87,6 +87,9 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity { @Column(name = "state") private String state; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + public AutoScaleVmGroupVO() { } @@ -212,4 +215,13 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity { public void setUuid(String uuid) { this.uuid = uuid; } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } } diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java index 9a8fbd8ad59..40dbe905508 100644 --- a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java +++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java @@ -86,6 +86,9 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter @Column(name = GenericDao.CREATED_COLUMN) protected Date created; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + public AutoScaleVmProfileVO() { } @@ -220,4 +223,13 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter public void setUuid(String uuid) { this.uuid = uuid; } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index e802ec3902b..56e9d810600 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -2969,6 +2969,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setMaxMembers(vmGroup.getMaxMembers()); response.setState(vmGroup.getState()); response.setInterval(vmGroup.getInterval()); + response.setForDisplay(vmGroup.isDisplay()); AutoScaleVmProfileVO profile = ApiDBUtils.findAutoScaleVmProfileById(vmGroup.getProfileId()); if (profile != null) { response.setProfileId(profile.getUuid()); diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java index 21c38ce6683..ff2b2eabd31 100644 --- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java +++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java @@ -370,6 +370,11 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScale AutoScaleVmProfileVO profileVO = new AutoScaleVmProfileVO(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getServiceOfferingId(), cmd.getTemplateId(), cmd.getOtherDeployParams(), cmd.getCounterParamList(), cmd.getDestroyVmGraceperiod(), autoscaleUserId); + + if (cmd.getDisplay() != null) { + profileVO.setDisplay(cmd.getDisplay()); + } + profileVO = checkValidityAndPersist(profileVO); s_logger.info("Successfully create AutoScale Vm Profile with Id: " + profileVO.getId()); @@ -410,6 +415,10 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScale vmProfile.setUuid(cmd.getCustomId()); } + if (cmd.getDisplay() != null) { + vmProfile.setDisplay(cmd.getDisplay()); + } + List vmGroupList = _autoScaleVmGroupDao.listByAll(null, profileId); for (AutoScaleVmGroupVO vmGroupVO : vmGroupList) { if (physicalParameterUpdate && !vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) { @@ -739,6 +748,7 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScale int minMembers = cmd.getMinMembers(); int maxMembers = cmd.getMaxMembers(); Integer interval = cmd.getInterval(); + Boolean forDisplay = cmd.getDisplay(); if (interval == null) { interval = NetUtils.DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME; @@ -760,6 +770,10 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScale AutoScaleVmGroupVO vmGroupVO = new AutoScaleVmGroupVO(cmd.getLbRuleId(), zoneId, loadBalancer.getDomainId(), loadBalancer.getAccountId(), minMembers, maxMembers, loadBalancer.getDefaultPortStart(), interval, null, cmd.getProfileId(), AutoScaleVmGroup.State_New); + if (forDisplay != null) { + vmGroupVO.setDisplay(forDisplay); + } + vmGroupVO = checkValidityAndPersist(vmGroupVO, cmd.getScaleUpPolicyIds(), cmd.getScaleDownPolicyIds()); s_logger.info("Successfully created Autoscale Vm Group with Id: " + vmGroupVO.getId()); @@ -970,6 +984,7 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScale Integer minMembers = cmd.getMinMembers(); Integer maxMembers = cmd.getMaxMembers(); Integer interval = cmd.getInterval(); + Boolean forDisplay = cmd.getDisplay(); List scaleUpPolicyIds = cmd.getScaleUpPolicyIds(); List scaleDownPolicyIds = cmd.getScaleDownPolicyIds(); @@ -998,6 +1013,10 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScale vmGroupVO.setUuid(cmd.getCustomId()); } + if (forDisplay != null) { + vmGroupVO.setDisplay(forDisplay); + } + vmGroupVO = checkValidityAndPersist(vmGroupVO, scaleUpPolicyIds, scaleDownPolicyIds); if (vmGroupVO != null) { s_logger.debug("Updated Auto Scale VmGroup id:" + vmGroupId); diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql index 9c0cc2642b0..f1ec6f10bc7 100644 --- a/setup/db/db/schema-430to440.sql +++ b/setup/db/db/schema-430to440.sql @@ -532,6 +532,8 @@ UPDATE `cloud`.`vpc_gateway_details` set `display`=1 where id> 0; ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the ip address can be displayed to the end user'; ALTER TABLE `cloud`.`vpc` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the vpc can be displayed to the end user'; ALTER TABLE `cloud`.`firewall_rules` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the rule can be displayed to the end user'; +ALTER TABLE `cloud`.`autoscale_vmgroups` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the entry can be displayed to the end user'; +ALTER TABLE `cloud`.`autoscale_vmprofiles` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the entry can be displayed to the end user';