Remove IdentityProxy from AutoScale responses.

Signed-off-by: Min Chen <min.chen@citrix.com>
This commit is contained in:
Min Chen 2012-12-18 11:19:36 -08:00
parent a390b273ae
commit 1aa30f03e7
12 changed files with 148 additions and 114 deletions

View File

@ -29,6 +29,8 @@ public interface AutoScaleVmProfile extends ControlledEntity {
public long getId();
public String getUuid();
public Long getZoneId();
public Long getServiceOfferingId();

View File

@ -26,6 +26,8 @@ import java.util.Date;
public interface DiskOffering {
long getId();
String getUuid();
String getUniqueName();
boolean getUseLocalStorage();

View File

@ -34,6 +34,8 @@ public interface ServiceOffering {
long getId();
String getUuid();
String getDisplayText();
Date getCreated();

View File

@ -28,15 +28,15 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled
@SerializedName(ApiConstants.ID)
@Param(description = "the autoscale vm group ID")
private IdentityProxy id = new IdentityProxy("autoscale_vmgroups");
private String id;
@SerializedName(ApiConstants.LBID)
@Param(description = "the load balancer rule ID")
private IdentityProxy loadBalancerId = new IdentityProxy("firewall_rules");
private String loadBalancerId;
@SerializedName(ApiConstants.VMPROFILE_ID)
@Param(description = "the autoscale profile that contains information about the vms in the vm group.")
private IdentityProxy profileId = new IdentityProxy("autoscale_vmprofiles");
private String profileId;
@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.")
@ -81,16 +81,16 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setLoadBalancerId(Long loadBalancerId) {
this.loadBalancerId.setValue(loadBalancerId);
public void setLoadBalancerId(String loadBalancerId) {
this.loadBalancerId = loadBalancerId;
}
public void setProfileId(Long profileId) {
this.profileId.setValue(profileId);
public void setProfileId(String profileId) {
this.profileId = profileId;
}
public void setMinMembers(int minMembers) {

View File

@ -25,7 +25,6 @@ import org.apache.cloudstack.api.BaseCmd.CommandType;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.Parameter;
import com.cloud.serializer.Param;
import com.cloud.utils.IdentityProxy;
import com.cloud.utils.Pair;
import com.google.gson.annotations.SerializedName;
@ -33,20 +32,20 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
@SerializedName(ApiConstants.ID)
@Param(description = "the autoscale vm profile ID")
private IdentityProxy id = new IdentityProxy("autoscale_vmprofiles");
private String id;
/* 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");
private String zoneId;
@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");
private String serviceOfferingId;
@SerializedName(ApiConstants.TEMPLATE_ID)
@Param(description = "the template to be used while deploying a virtual machine")
private IdentityProxy templateId = new IdentityProxy("vm_template");
private String templateId;
@SerializedName(ApiConstants.OTHER_DEPLOY_PARAMS)
@Param(description = "parameters other than zoneId/serviceOfferringId/templateId to be used while deploying a virtual machine")
@ -64,7 +63,7 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
@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");
private String autoscaleUserId;
@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;
@ -93,20 +92,20 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setZoneId(Long zoneId) {
this.zoneId.setValue(zoneId);
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId.setValue(serviceOfferingId);
public void setServiceOfferingId(String serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public void setTemplateId(Long templateId) {
this.templateId.setValue(templateId);
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public void setOtherDeployParams(String otherDeployParams) {
@ -147,8 +146,8 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
this.projectName = projectName;
}
public void setAutoscaleUserId(Long autoscaleUserId) {
this.autoscaleUserId.setValue(autoscaleUserId);
public void setAutoscaleUserId(String autoscaleUserId) {
this.autoscaleUserId = autoscaleUserId;
}
public void setDestroyVmGraceperiod(Integer destroyVmGraceperiod) {

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.api.response;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.utils.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse;
@ -25,7 +24,7 @@ import org.apache.cloudstack.api.BaseResponse;
public class CloudIdentifierResponse extends BaseResponse {
@SerializedName(ApiConstants.USER_ID) @Param(description="the user ID for the cloud identifier")
private IdentityProxy userId = new IdentityProxy("user");
private String userId;
@SerializedName("cloudidentifier") @Param(description="the cloud identifier")
private String cloudIdentifier;
@ -33,12 +32,12 @@ public class CloudIdentifierResponse extends BaseResponse {
@SerializedName("signature") @Param(description="the signed response for the cloud identifier")
private String signature;
public Long getUserId() {
return userId.getValue();
public String getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId.setValue(userId);
public void setUserId(String userId) {
this.userId = userId;
}
public String getCloudIdentifier() {

View File

@ -21,7 +21,6 @@ import java.util.List;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.serializer.Param;
import com.cloud.utils.IdentityProxy;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse;
@ -29,7 +28,7 @@ import org.apache.cloudstack.api.BaseResponse;
public class ConditionResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName("id")
@Param(description = "the id of the Condition")
private final IdentityProxy id = new IdentityProxy("conditions");
private String id;
@SerializedName(value = ApiConstants.THRESHOLD)
@Param(description = "Threshold Value for the counter.")
@ -53,7 +52,7 @@ public class ConditionResponse extends BaseResponse implements ControlledEntityR
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "zone id of counter")
private final IdentityProxy zoneId = new IdentityProxy("data_center");
private String zoneId;
@SerializedName(ApiConstants.PROJECT_ID)
@Param(description = "the project id of the Condition.")
@ -71,8 +70,8 @@ public class ConditionResponse extends BaseResponse implements ControlledEntityR
// ///////////////// Setters ///////////////////////
// ///////////////////////////////////////////////////
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setThreshold(long threshold) {
@ -97,8 +96,8 @@ public class ConditionResponse extends BaseResponse implements ControlledEntityR
this.projectId = projectId;
}
public void setZoneId(Long zoneId) {
this.zoneId.setValue(zoneId);
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
@Override

View File

@ -22,7 +22,6 @@ import org.apache.cloudstack.api.Entity;
import com.cloud.network.as.Counter;
import com.cloud.serializer.Param;
import com.cloud.utils.IdentityProxy;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse;
@ -31,7 +30,7 @@ import org.apache.cloudstack.api.BaseResponse;
public class CounterResponse extends BaseResponse {
@SerializedName("id")
@Param(description = "the id of the Counter")
private final IdentityProxy id = new IdentityProxy("counter");
private String id;
@SerializedName(value = ApiConstants.NAME)
@Param(description = "Name of the counter.")
@ -47,10 +46,10 @@ public class CounterResponse extends BaseResponse {
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "zone id of counter")
private final IdentityProxy zoneId = new IdentityProxy("data_center");
private String zoneId;
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setName(String name) {

View File

@ -42,12 +42,12 @@ import com.cloud.utils.db.GenericDao;
@Table(name="disk_offering")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
public class DiskOfferingVO implements DiskOffering, Identity {
public class DiskOfferingVO implements DiskOffering {
public enum Type {
Disk,
Service
};
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
@ -58,7 +58,7 @@ public class DiskOfferingVO implements DiskOffering, Identity {
@Column(name="unique_name")
private String uniqueName;
@Column(name="name")
private String name = null;
@ -70,39 +70,39 @@ public class DiskOfferingVO implements DiskOffering, Identity {
@Column(name="tags", length=4096)
String tags;
@Column(name="type")
Type type;
@Column(name=GenericDao.REMOVED)
@Temporal(TemporalType.TIMESTAMP)
private Date removed;
@Column(name=GenericDao.CREATED_COLUMN)
private Date created;
@Column(name="recreatable")
private boolean recreatable;
@Column(name="use_local_storage")
private boolean useLocalStorage;
@Column(name="system_use")
private boolean systemUse;
@Column(name="customized")
private boolean customized;
@Column(name="uuid")
private String uuid;
@Column(name="sort_key")
int sortKey;
public DiskOfferingVO() {
this.uuid = UUID.randomUUID().toString();
}
public DiskOfferingVO(Long domainId, String name, String displayText, long diskSize, String tags, boolean isCustomized) {
this.domainId = domainId;
this.name = name;
@ -115,7 +115,7 @@ public class DiskOfferingVO implements DiskOffering, Identity {
this.customized = isCustomized;
this.uuid = UUID.randomUUID().toString();
}
public DiskOfferingVO(String name, String displayText, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage, boolean systemUse, boolean customized) {
this.domainId = null;
this.type = Type.Service;
@ -147,7 +147,7 @@ public class DiskOfferingVO implements DiskOffering, Identity {
public long getId() {
return id;
}
@Override
public boolean isCustomized() {
return customized;
@ -161,25 +161,25 @@ public class DiskOfferingVO implements DiskOffering, Identity {
public String getUniqueName() {
return uniqueName;
}
@Override
public boolean getUseLocalStorage() {
return useLocalStorage;
}
@Override
public Long getDomainId() {
return domainId;
}
public Type getType() {
return type;
}
public boolean isRecreatable() {
return recreatable;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
@ -188,17 +188,17 @@ public class DiskOfferingVO implements DiskOffering, Identity {
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean getSystemUse() {
return systemUse;
}
public void setSystemUse(boolean systemUse) {
this.systemUse = systemUse;
}
@ -215,7 +215,7 @@ public class DiskOfferingVO implements DiskOffering, Identity {
public long getDiskSize(){
return diskSize;
}
@Override
public void setDiskSize(long diskSize) {
this.diskSize = diskSize;
@ -224,21 +224,21 @@ public class DiskOfferingVO implements DiskOffering, Identity {
public Date getRemoved() {
return removed;
}
@Override
public Date getCreated() {
return created;
}
protected void setTags(String tags) {
this.tags = tags;
}
@Override
public String getTags() {
return tags;
}
public void setUniqueName(String name) {
this.uniqueName = name;
}
@ -250,7 +250,7 @@ public class DiskOfferingVO implements DiskOffering, Identity {
if (tags == null || tags.isEmpty()) {
return new String[0];
}
return tags.split(",");
}
@ -259,30 +259,30 @@ public class DiskOfferingVO implements DiskOffering, Identity {
if (this.tags == null) {
return false;
}
for (String tag : tags) {
if (!this.tags.matches(tag)) {
return false;
}
}
return true;
}
@Transient
public void setTagsArray(List<String> newTags) {
if (newTags.isEmpty()) {
setTags(null);
return;
}
StringBuilder buf = new StringBuilder();
for (String tag : newTags) {
buf.append(tag).append(",");
}
buf.delete(buf.length() - 1, buf.length());
setTags(buf.toString());
}
@ -293,12 +293,12 @@ public class DiskOfferingVO implements DiskOffering, Identity {
public void setRemoved(Date removed) {
this.removed = removed;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
@ -306,7 +306,7 @@ public class DiskOfferingVO implements DiskOffering, Identity {
public void setSortKey(int key) {
sortKey = key;
}
public int getSortKey() {
return sortKey;
}

View File

@ -3282,7 +3282,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public CounterResponse createCounterResponse(Counter counter) {
CounterResponse response = new CounterResponse();
response.setId(counter.getId());
response.setId(counter.getUuid());
response.setSource(counter.getSource().toString());
response.setName(counter.getName());
response.setValue(counter.getValue());
@ -3293,7 +3293,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public ConditionResponse createConditionResponse(Condition condition) {
ConditionResponse response = new ConditionResponse();
response.setId(condition.getId());
response.setId(condition.getUuid());
List<CounterResponse> counterResponseList = new ArrayList<CounterResponse>();
counterResponseList.add(createCounterResponse(ApiDBUtils.getCounter(condition.getCounterid())));
response.setCounterResponse(counterResponseList);
@ -3307,14 +3307,32 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public AutoScaleVmProfileResponse createAutoScaleVmProfileResponse(AutoScaleVmProfile profile) {
AutoScaleVmProfileResponse response = new AutoScaleVmProfileResponse();
response.setId(profile.getId());
response.setZoneId(profile.getZoneId());
response.setServiceOfferingId(profile.getServiceOfferingId());
response.setTemplateId(profile.getTemplateId());
response.setId(profile.getUuid());
if (profile.getZoneId() != null) {
DataCenterVO zone = ApiDBUtils.findZoneById(profile.getZoneId());
if (zone != null) {
response.setZoneId(zone.getUuid());
}
}
if (profile.getServiceOfferingId() != null) {
ServiceOffering so = ApiDBUtils.findServiceOfferingById(profile.getServiceOfferingId());
if (so != null) {
response.setServiceOfferingId(so.getUuid());
}
}
if (profile.getTemplateId() != null) {
VMTemplateVO template = ApiDBUtils.findTemplateById(profile.getTemplateId());
if (template != null) {
response.setTemplateId(template.getUuid());
}
}
response.setOtherDeployParams(profile.getOtherDeployParams());
response.setCounterParams(profile.getCounterParams());
response.setDestroyVmGraceperiod(profile.getDestroyVmGraceperiod());
response.setAutoscaleUserId(profile.getAutoScaleUserId());
User user = ApiDBUtils.findUserById(profile.getAutoScaleUserId());
if (user != null) {
response.setAutoscaleUserId(user.getUuid());
}
response.setObjectName("autoscalevmprofile");
// Populates the account information in the response
@ -3346,13 +3364,19 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public AutoScaleVmGroupResponse createAutoScaleVmGroupResponse(AutoScaleVmGroup vmGroup) {
AutoScaleVmGroupResponse response = new AutoScaleVmGroupResponse();
response.setId(vmGroup.getId());
response.setId(vmGroup.getUuid());
response.setMinMembers(vmGroup.getMinMembers());
response.setMaxMembers(vmGroup.getMaxMembers());
response.setState(vmGroup.getState());
response.setInterval(vmGroup.getInterval());
response.setProfileId(vmGroup.getProfileId());
response.setLoadBalancerId(vmGroup.getProfileId());
AutoScaleVmProfileVO profile = ApiDBUtils.findAutoScaleVmProfileById(vmGroup.getProfileId());
if (profile != null) {
response.setProfileId(profile.getUuid());
}
FirewallRuleVO fw = ApiDBUtils.findFirewallRuleById(vmGroup.getProfileId());
if (fw != null) {
response.setLoadBalancerId(fw.getUuid());
}
List<AutoScalePolicyResponse> scaleUpPoliciesResponse = new ArrayList<AutoScalePolicyResponse>();
List<AutoScalePolicyResponse> scaleDownPoliciesResponse = new ArrayList<AutoScalePolicyResponse>();

View File

@ -32,25 +32,25 @@ import com.cloud.offering.ServiceOffering;
public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffering {
@Column(name="cpu")
private int cpu;
@Column(name="speed")
private int speed;
@Column(name="ram_size")
private int ramSize;
@Column(name="nw_rate")
private Integer rateMbps;
@Column(name="mc_rate")
private Integer multicastRateMbps;
@Column(name="ha_enabled")
private boolean offerHA;
@Column(name="host_tag")
private String hostTag;
private String hostTag;
protected ServiceOffering21VO() {
super();
}
@ -64,19 +64,19 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
this.multicastRateMbps = multicastRateMbps;
this.offerHA = offerHA;
}
public ServiceOffering21VO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, boolean useLocalStorage, boolean recreatable, String tags, String hostTag) {
this(name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, useLocalStorage, recreatable, tags);
this.hostTag = hostTag;
}
@Override
public boolean getOfferHA() {
return offerHA;
}
@Override
@Override
public boolean getLimitCpuUse() {
return false;
}
@ -84,7 +84,7 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
public void setOfferHA(boolean offerHA) {
this.offerHA = offerHA;
}
@Override
@Transient
public String[] getTagsArray() {
@ -92,15 +92,15 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
if (tags == null || tags.length() == 0) {
return new String[0];
}
return tags.split(",");
}
@Override
public int getCpu() {
return cpu;
}
public void setCpu(int cpu) {
this.cpu = cpu;
}
@ -112,17 +112,17 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
public void setRamSize(int ramSize) {
this.ramSize = ramSize;
}
@Override
public int getSpeed() {
return speed;
}
@Override
public int getRamSize() {
return ramSize;
}
public void setRateMbps(Integer rateMbps) {
this.rateMbps = rateMbps;
}
@ -135,7 +135,7 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
public void setMulticastRateMbps(Integer multicastRateMbps) {
this.multicastRateMbps = multicastRateMbps;
}
@Override
public Integer getMulticastRateMbps() {
return multicastRateMbps;
@ -147,8 +147,8 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
public void setHostTag(String hostTag) {
this.hostTag = hostTag;
}
}
public String getHostTag() {
return hostTag;
}
@ -156,10 +156,18 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
@Override
public boolean getDefaultUse() {
return false;
}
}
@Override
public String getSystemVmType() {
return null;
}
}
@Override
public String getUuid() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -41,7 +41,7 @@ import com.cloud.utils.net.NetUtils;
@Entity
@Table(name = "autoscale_vmprofiles")
@Inheritance(strategy = InheritanceType.JOINED)
public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
public class AutoScaleVmProfileVO implements AutoScaleVmProfile{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)