mirror of https://github.com/apache/cloudstack.git
Display flag support for autoscale vmGroup and vmProfile
This commit is contained in:
parent
27a790bdc1
commit
92064e347a
|
|
@ -53,4 +53,6 @@ public interface AutoScaleVmGroup extends ControlledEntity, InternalIdentity {
|
|||
|
||||
String getUuid();
|
||||
|
||||
boolean isDisplay();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,6 @@ public interface AutoScaleVmProfile extends ControlledEntity, InternalIdentity {
|
|||
|
||||
public long getAutoScaleUserId();
|
||||
|
||||
boolean isDisplay();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<String, String> otherDeployParamMap;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
@ -125,6 +128,10 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
return templateId;
|
||||
}
|
||||
|
||||
public Boolean getDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public Map getCounterParamList() {
|
||||
return counterParamList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class FirewallResponse extends BaseResponse {
|
|||
private List<ResourceTagResponse> 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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -370,6 +370,11 @@ public class AutoScaleManagerImpl<Type> 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<Type> extends ManagerBase implements AutoScale
|
|||
vmProfile.setUuid(cmd.getCustomId());
|
||||
}
|
||||
|
||||
if (cmd.getDisplay() != null) {
|
||||
vmProfile.setDisplay(cmd.getDisplay());
|
||||
}
|
||||
|
||||
List<AutoScaleVmGroupVO> vmGroupList = _autoScaleVmGroupDao.listByAll(null, profileId);
|
||||
for (AutoScaleVmGroupVO vmGroupVO : vmGroupList) {
|
||||
if (physicalParameterUpdate && !vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
|
||||
|
|
@ -739,6 +748,7 @@ public class AutoScaleManagerImpl<Type> 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<Type> 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<Type> extends ManagerBase implements AutoScale
|
|||
Integer minMembers = cmd.getMinMembers();
|
||||
Integer maxMembers = cmd.getMaxMembers();
|
||||
Integer interval = cmd.getInterval();
|
||||
Boolean forDisplay = cmd.getDisplay();
|
||||
|
||||
List<Long> scaleUpPolicyIds = cmd.getScaleUpPolicyIds();
|
||||
List<Long> scaleDownPolicyIds = cmd.getScaleDownPolicyIds();
|
||||
|
|
@ -998,6 +1013,10 @@ public class AutoScaleManagerImpl<Type> 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);
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue