UUID support for XML responses

This commit is contained in:
Kelven Yang 2011-11-04 17:37:33 -07:00
parent 92f4a88c68
commit 2b6f3d458e
32 changed files with 216 additions and 395 deletions

View File

@ -26,11 +26,6 @@ import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class AsyncJobResponse extends BaseResponse {
/*
@SerializedName(ApiConstants.JOB_ID) @Param(description="async job ID")
private IdentityProxy id = new IdentityProxy("async_job");
*/
@SerializedName("accountid") @Param(description="the account that executed the async command")
private IdentityProxy accountId = new IdentityProxy("account");

View File

@ -18,6 +18,7 @@
package com.cloud.api.response;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@ -26,19 +27,19 @@ public class CapacityResponse extends BaseResponse {
private Short capacityType;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID")
private Long zoneId;
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the Zone name")
private String zoneName;
@SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID")
private Long podId;
private IdentityProxy podId = new IdentityProxy("host_pod_ref");
@SerializedName("podname") @Param(description="the Pod name")
private String podName;
@SerializedName(ApiConstants.CLUSTER_ID) @Param(description="the Cluster ID")
private Long clusterId;
private IdentityProxy clusterId = new IdentityProxy("cluster");
@SerializedName("clustername") @Param(description="the Cluster name")
private String clusterName;
@ -61,11 +62,11 @@ public class CapacityResponse extends BaseResponse {
}
public Long getZoneId() {
return zoneId;
return zoneId.getValue();
}
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
this.zoneId.setValue(zoneId);
}
public String getZoneName() {
@ -77,11 +78,11 @@ public class CapacityResponse extends BaseResponse {
}
public Long getPodId() {
return podId;
return podId.getValue();
}
public void setPodId(Long podId) {
this.podId = podId;
this.podId.setValue(podId);
}
public String getPodName() {
@ -93,11 +94,11 @@ public class CapacityResponse extends BaseResponse {
}
public Long getClusterId() {
return clusterId;
return clusterId.getValue();
}
public void setClusterId(Long clusterId) {
this.clusterId = clusterId;
this.clusterId.setValue(clusterId);
}
public String getClusterName() {

View File

@ -23,24 +23,9 @@ import com.cloud.api.IdentityProxy;
import com.google.gson.annotations.SerializedName;
public class CreateCmdResponse extends BaseResponse {
/*
@SerializedName(ApiConstants.JOB_ID)
private Long jobId;
*/
@SerializedName(ApiConstants.ID)
private IdentityProxy id = new IdentityProxy();
/*
public Long getJobId() {
return super.getJobId();
}
public void setJobId(Long jobId) {
super.setJobId(jobId);
}
*/
public Long getId() {
return id.getValue();
}

View File

@ -70,7 +70,7 @@ public class DomainRouterResponse extends BaseResponse implements ControlledEnti
private String linkLocalNetmask;
@SerializedName(ApiConstants.LINK_LOCAL_NETWORK_ID) @Param(description="the ID of the corresponding link local network")
private Long linkLocalNetworkId;
private IdentityProxy linkLocalNetworkId = new IdentityProxy("networks");
@SerializedName(ApiConstants.PUBLIC_IP) @Param(description="the public IP address for the router")
private String publicIp;
@ -263,7 +263,7 @@ public class DomainRouterResponse extends BaseResponse implements ControlledEnti
}
public void setLinkLocalNetworkId(Long linkLocalNetworkId) {
this.linkLocalNetworkId = linkLocalNetworkId;
this.linkLocalNetworkId.setValue(linkLocalNetworkId);
}
public void setServiceOfferingId(Long serviceOfferingId) {

View File

@ -18,12 +18,13 @@
package com.cloud.api.response;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class EgressRuleResponse extends BaseResponse {
@SerializedName("ruleid") @Param(description="the id of the ingress rule")
private Long ruleId;
private IdentityProxy ruleId = new IdentityProxy("security_egress_rule");
@SerializedName("protocol") @Param(description="the protocol of the ingress rule")
private String protocol;
@ -50,11 +51,11 @@ public class EgressRuleResponse extends BaseResponse {
private String cidr;
public Long getRuleId() {
return ruleId;
return ruleId.getValue();
}
public void setRuleId(Long ruleId) {
this.ruleId = ruleId;
this.ruleId.setValue(ruleId);
}
public String getProtocol() {

View File

@ -139,14 +139,6 @@ public class HostResponse extends BaseResponse {
@SerializedName("events") @Param(description="events available for the host")
private String events;
/*
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the host")
private IdentityProxy jobId = new IdentityProxy("async_job");
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
private Integer jobStatus;
*/
@SerializedName("hosttags") @Param(description="comma-separated list of tags for the host")
private String hostTags;
@ -168,28 +160,6 @@ public class HostResponse extends BaseResponse {
return getId();
}
/*
@Override
public Long getJobId() {
return super.getJobId();
}
@Override
public void setJobId(Long jobId) {
super.setJobId(jobId);
}
@Override
public Integer getJobStatus() {
return jobStatus;
}
@Override
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
*/
public Long getId() {
return id.getValue();
}

View File

@ -18,18 +18,19 @@
package com.cloud.api.response;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class IpForwardingRuleResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the port forwarding rule")
private Long id;
private IdentityProxy id = new IdentityProxy("firewall_rules");
@SerializedName(ApiConstants.PROTOCOL) @Param(description="the protocol of the port forwarding rule")
private String protocol;
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID) @Param(description="the VM ID for the port forwarding rule")
private Long virtualMachineId;
private IdentityProxy virtualMachineId = new IdentityProxy("vm_instance");
@SerializedName("virtualmachinename") @Param(description="the VM name for the port forwarding rule")
private String virtualMachineName;
@ -53,11 +54,11 @@ public class IpForwardingRuleResponse extends BaseResponse {
private String state;
public Long getId() {
return id;
return id.getValue();
}
public void setId(Long id) {
this.id = id;
this.id.setValue(id);
}
public String getProtocol() {
@ -69,11 +70,11 @@ public class IpForwardingRuleResponse extends BaseResponse {
}
public Long getVirtualMachineId() {
return virtualMachineId;
return virtualMachineId.getValue();
}
public void setVirtualMachineId(Long virtualMachineId) {
this.virtualMachineId = virtualMachineId;
this.virtualMachineId.setValue(virtualMachineId);
}
public String getVirtualMachineName() {

View File

@ -17,12 +17,13 @@
*/
package com.cloud.api.response;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class IsoVmResponse extends BaseResponse {
@SerializedName("id") @Param(description="the ISO ID")
private long id;
private IdentityProxy id = new IdentityProxy("vm_template");
@SerializedName("name") @Param(description="the ISO name")
private String name;
@ -37,13 +38,13 @@ public class IsoVmResponse extends BaseResponse {
private Boolean featured;
@SerializedName("ostypeid") @Param(description="the ID of the OS type for this template.")
private Long osTypeId;
private IdentityProxy osTypeId = new IdentityProxy("guest_os");
@SerializedName("ostypename") @Param(description="the name of the OS type for this template.")
private String osTypeName;
@SerializedName("virtualmachineid") @Param(description="id of the virtual machine")
private Long virtualMachineId;
private IdentityProxy virtualMachineId = new IdentityProxy("vm_instance");
@SerializedName("vmname") @Param(description="name of the virtual machine")
private String virtualMachineName;
@ -56,11 +57,11 @@ public class IsoVmResponse extends BaseResponse {
public Long getOsTypeId() {
return osTypeId;
return osTypeId.getValue();
}
public void setOsTypeId(Long osTypeId) {
this.osTypeId = osTypeId;
this.osTypeId.setValue(osTypeId);
}
public String getOsTypeName() {
@ -71,12 +72,12 @@ public class IsoVmResponse extends BaseResponse {
this.osTypeName = osTypeName;
}
public long getId() {
return id;
public Long getId() {
return id.getValue();
}
public void setId(long id) {
this.id = id;
public void setId(Long id) {
this.id.setValue(id);
}
public String getName() {
@ -112,11 +113,11 @@ public class IsoVmResponse extends BaseResponse {
}
public Long getVirtualMachineId() {
return virtualMachineId;
return virtualMachineId.getValue();
}
public void setVirtualMachineId(Long virtualMachineId) {
this.virtualMachineId = virtualMachineId;
this.virtualMachineId.setValue(virtualMachineId);
}
public String getVirtualMachineName() {

View File

@ -17,16 +17,17 @@
*/
package com.cloud.api.response;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class NicResponse extends BaseResponse {
@SerializedName("id") @Param(description="the ID of the nic")
private Long id;
private IdentityProxy id = new IdentityProxy("nics");
@SerializedName("networkid") @Param(description="the ID of the corresponding network")
private Long networkid;
private IdentityProxy networkid = new IdentityProxy("networks");
@SerializedName("netmask") @Param(description="the netmask of the nic")
private String netmask;
@ -56,19 +57,19 @@ public class NicResponse extends BaseResponse {
private String macAddress;
public Long getId() {
return id;
return id.getValue();
}
public void setId(Long id) {
this.id = id;
this.id.setValue(id);
}
public Long getNetworkid() {
return networkid;
return networkid.getValue();
}
public void setNetworkid(Long networkid) {
this.networkid = networkid;
this.networkid.setValue(networkid);
}
public String getNetmask() {

View File

@ -1,100 +0,0 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.api.response;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class PortForwardingServiceRuleResponse extends BaseResponse {
@SerializedName("id") @Param(description="the ID of the port forwarding service rule")
private long ruleId;
@SerializedName("publicport") @Param(description="the public port of the port forwarding service rule")
private String publicPort;
@SerializedName("privateport") @Param(description="the private port of the port forwarding service rule")
private String privatePort;
@SerializedName("protocol") @Param(description="the protocol (TCP/UDP) of the port forwarding service rule")
private String protocol;
@SerializedName("portforwardingserviceid") @Param(description="the id of port forwarding service where the rule belongs to")
private Long portForwardingServiceId;
@SerializedName("jobid") @Param(description="the job ID associated with the port forwarding rule. This is only displayed if the rule listed is part of a currently running asynchronous job.")
private Long jobId;
@SerializedName("jobstatus") @Param(description="the job status associated with the port forwarding rule. This is only displayed if the rule listed is part of a currently running asynchronous job.")
private Integer jobStatus;
public Long getPortForwardingServiceId() {
return portForwardingServiceId;
}
public void setPortForwardingServiceId(Long portForwardingServiceId) {
this.portForwardingServiceId = portForwardingServiceId;
}
public long getRuleId() {
return ruleId;
}
public void setRuleId(long ruleId) {
this.ruleId = ruleId;
}
public String getPublicPort() {
return publicPort;
}
public void setPublicPort(String publicPort) {
this.publicPort = publicPort;
}
public String getPrivatePort() {
return privatePort;
}
public void setPrivatePort(String privatePort) {
this.privatePort = privatePort;
}
public String getProtocol() {
return protocol;
}
public void setProtocol(String protocol) {
this.protocol = protocol;
}
public Long getJobId() {
return jobId;
}
public void setJobId(Long jobId) {
this.jobId = jobId;
}
public Integer getJobStatus() {
return jobStatus;
}
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
}

View File

@ -20,19 +20,20 @@ package com.cloud.api.response;
import java.util.List;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
public class ProjectAccountResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="project id")
private Long projectId;
private IdentityProxy projectId = new IdentityProxy("projects");
@SerializedName(ApiConstants.PROJECT) @Param(description="project name")
private String projectName;
@SerializedName(ApiConstants.ACCOUNT_ID) @Param(description="the id of the account")
private Long id;
private IdentityProxy id = new IdentityProxy("account");
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the name of the account")
private String accountName;
@ -44,7 +45,7 @@ public class ProjectAccountResponse extends BaseResponse implements ControlledEn
private String role;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="id of the Domain the account belongs too")
private Long domainId;
private IdentityProxy domainId = new IdentityProxy("domain");
@SerializedName(ApiConstants.DOMAIN) @Param(description="name of the Domain the account belongs too")
private String domainName;
@ -53,7 +54,7 @@ public class ProjectAccountResponse extends BaseResponse implements ControlledEn
private List<UserResponse> users;
public void setProjectId(Long projectId) {
this.projectId = projectId;
this.projectId.setValue(projectId);
}
public void setProjectName(String projectName) {
@ -61,7 +62,7 @@ public class ProjectAccountResponse extends BaseResponse implements ControlledEn
}
public void setId(Long id) {
this.id = id;
this.id.setValue(id);
}
public void setAccountName(String accountName) {
@ -73,7 +74,7 @@ public class ProjectAccountResponse extends BaseResponse implements ControlledEn
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
this.domainId.setValue(domainId);
}
public void setDomainName(String domainName) {

View File

@ -50,14 +50,6 @@ public class SecurityGroupResponse extends BaseResponse implements ControlledEnt
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the security group")
private String domainName;
/*
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume")
private IdentityProxy jobId = new IdentityProxy("async_job");
@SerializedName(ApiConstants.JOB_STATUS) @Param(description="shows the current pending asynchronous job status")
private Integer jobStatus;
*/
@SerializedName("ingressrule") @Param(description="the list of ingress rules associated with the security group", responseObject = IngressRuleResponse.class)
private List<IngressRuleResponse> ingressRules;
@ -105,28 +97,6 @@ public class SecurityGroupResponse extends BaseResponse implements ControlledEnt
return getId();
}
/*
@Override
public Long getJobId() {
return super.getJobId();
}
@Override
public void setJobId(Long jobId) {
super.setJobId(jobId);
}
@Override
public Integer getJobStatus() {
return jobStatus;
}
@Override
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
*/
@Override
public int hashCode() {
final int prime = 31;

View File

@ -73,15 +73,6 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
@Param(description = "name of the snapshot")
private String name;
/*
@SerializedName(ApiConstants.JOB_ID)
@Param(description = "the job ID associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.")
private IdentityProxy jobId = new IdentityProxy("async_job");
@SerializedName(ApiConstants.JOB_STATUS)
@Param(description = "the job status associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.")
private Integer jobStatus;
*/
@SerializedName(ApiConstants.INTERVAL_TYPE)
@Param(description = "valid types are hourly, daily, weekly, monthy, template, and none.")
private String intervalType;
@ -147,28 +138,6 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
this.name = name;
}
/*
@Override
public Long getJobId() {
return super.getJobId();
}
@Override
public void setJobId(Long jobId) {
super.setJobId(jobId);
}
@Override
public Integer getJobStatus() {
return jobStatus;
}
@Override
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
*/
public void setIntervalType(String intervalType) {
this.intervalType = intervalType;
}

View File

@ -19,44 +19,45 @@ package com.cloud.api.response;
import java.util.Date;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class SnapshotScheduleResponse extends BaseResponse {
@SerializedName("id") @Param(description="the ID of the snapshot schedule")
private Long id;
private IdentityProxy id = new IdentityProxy("snapshot_schedule");
@SerializedName("volumeid") @Param(description="the volume ID the snapshot schedule applied for")
private Long volumeId;
private IdentityProxy volumeId = new IdentityProxy("volumes");
@SerializedName("snapshotpolicyid") @Param(description="the snapshot policy ID used by the snapshot schedule")
private Long snapshotPolicyId;
private IdentityProxy snapshotPolicyId = new IdentityProxy("snapshot_policy");
@SerializedName("scheduled") @Param(description="time the snapshot is scheduled to be taken")
private Date scheduled;
public Long getId() {
return id;
return id.getValue();
}
public void setId(Long id) {
this.id = id;
this.id.setValue(id);
}
public Long getVolumeId() {
return volumeId;
return volumeId.getValue();
}
public void setVolumeId(Long volumeId) {
this.volumeId = volumeId;
this.volumeId.setValue(volumeId);
}
public Long getSnapshotPolicyId() {
return snapshotPolicyId;
return snapshotPolicyId.getValue();
}
public void setSnapshotPolicyId(Long snapshotPolicyId) {
this.snapshotPolicyId = snapshotPolicyId;
this.snapshotPolicyId.setValue(snapshotPolicyId);
}
public Date getScheduled() {

View File

@ -77,41 +77,11 @@ public class StoragePoolResponse extends BaseResponse {
@SerializedName(ApiConstants.STATE) @Param(description="the state of the storage pool")
private StoragePoolStatus state;
/*
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the storage pool")
private IdentityProxy jobId = new IdentityProxy("async_job");
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
private Integer jobStatus;
*/
@Override
public Long getObjectId() {
return getId();
}
/*
@Override
public Long getJobId() {
return super.getJobId();
}
@Override
public void setJobId(Long jobId) {
super.setJobId(jobId);
}
@Override
public Integer getJobStatus() {
return jobStatus;
}
@Override
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
*/
public Long getId() {
return id.getValue();
}

View File

@ -20,13 +20,14 @@ package com.cloud.api.response;
import java.util.Date;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class SwiftResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "the ID of swift")
private Long id;
private IdentityProxy id = new IdentityProxy("swift");
@SerializedName(ApiConstants.URL)
@Param(description = "url for swift")
@ -38,11 +39,11 @@ public class SwiftResponse extends BaseResponse {
@Override
public Long getObjectId() {
return id;
return id.getValue();
}
public void setId(Long id) {
this.id = id;
this.id.setValue(id);
}
public String getUrl() {

View File

@ -19,12 +19,13 @@ package com.cloud.api.response;
import java.util.Date;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class UpgradeVmResponse extends BaseResponse {
@SerializedName("id")
private long id;
private IdentityProxy id = new IdentityProxy("vm_instance");
public String getName() {
return name;
@ -66,12 +67,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.account = account;
}
public long getDomainId() {
return domainId;
public Long getDomainId() {
return domainId.getValue();
}
public void setDomainId(long domainId) {
this.domainId = domainId;
public void setDomainId(Long domainId) {
this.domainId.setValue(domainId);
}
public String getDomain() {
@ -90,12 +91,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.haEnable = haEnable;
}
public long getZoneId() {
return zoneId;
public Long getZoneId() {
return zoneId.getValue();
}
public void setZoneId(long zoneId) {
this.zoneId = zoneId;
public void setZoneId(Long zoneId) {
this.zoneId.setValue(zoneId);
}
public String getDisplayName() {
@ -114,12 +115,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.zoneName = zoneName;
}
public long getHostId() {
return hostId;
public Long getHostId() {
return hostId.getValue();
}
public void setHostId(long hostId) {
this.hostId = hostId;
public void setHostId(Long hostId) {
this.hostId.setValue(hostId);
}
public String getHostName() {
@ -130,12 +131,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.hostName = hostName;
}
public long getTemplateId() {
return templateId;
public Long getTemplateId() {
return templateId.getValue();
}
public void setTemplateId(long templateId) {
this.templateId = templateId;
public void setTemplateId(Long templateId) {
this.templateId.setValue(templateId);
}
public String getTemplateName() {
@ -162,12 +163,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.passwordEnabled = passwordEnabled;
}
public long getServiceOfferingId() {
return serviceOfferingId;
public Long getServiceOfferingId() {
return serviceOfferingId.getValue();
}
public void setServiceOfferingId(long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId.setValue(serviceOfferingId);
}
public String getServiceOfferingName() {
@ -218,8 +219,8 @@ public class UpgradeVmResponse extends BaseResponse {
this.networkKbsWrite = networkKbsWrite;
}
public long isId() {
return id;
public Long isId() {
return id.getValue();
}
@SerializedName("name") @Param(description="the ID of the virtual machine")
@ -238,7 +239,7 @@ public class UpgradeVmResponse extends BaseResponse {
private String account;
@SerializedName("domainid") @Param(description="the ID of the domain in which the virtual machine exists")
private long domainId;
private IdentityProxy domainId = new IdentityProxy("domain");
@SerializedName("domain") @Param(description="the name of the domain in which the virtual machine exists")
private String domain;
@ -247,7 +248,7 @@ public class UpgradeVmResponse extends BaseResponse {
private boolean haEnable;
@SerializedName("zoneid") @Param(description="the ID of the availablility zone for the virtual machine")
private long zoneId;
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("displayname") @Param(description="user generated name. The name of the virtual machine is returned if no displayname exists.")
private String displayName;
@ -256,13 +257,13 @@ public class UpgradeVmResponse extends BaseResponse {
private String zoneName;
@SerializedName("hostid") @Param(description="the ID of the host for the virtual machine")
private long hostId;
private IdentityProxy hostId = new IdentityProxy("host");
@SerializedName("hostname") @Param(description="the name of the host for the virtual machine")
private String hostName;
@SerializedName("templateid") @Param(description="the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file.")
private long templateId;
private IdentityProxy templateId = new IdentityProxy("vm_template");
@SerializedName("templatename") @Param(description="the name of the template for the virtual machine")
private String templateName;
@ -274,7 +275,7 @@ public class UpgradeVmResponse extends BaseResponse {
private boolean passwordEnabled;
@SerializedName("serviceofferingid") @Param(description="the ID of the service offering of the virtual machine")
private long serviceOfferingId;
private IdentityProxy serviceOfferingId = new IdentityProxy("disk_offering");
@SerializedName("serviceofferingname") @Param(description="the name of the service offering of the virtual machine")
private String serviceOfferingName;

View File

@ -144,14 +144,6 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
@SerializedName(ApiConstants.PASSWORD) @Param(description="the password (if exists) of the virtual machine")
private String password;
/*
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the virtual machine")
private IdentityProxy jobId = new IdentityProxy("async_job");
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
private Integer jobStatus;
*/
@SerializedName("nic") @Param(description="the list of nics associated with vm", responseObject = NicResponse.class)
private List<NicResponse> nics;

View File

@ -30,16 +30,6 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
@Param(description = "ID of the disk volume")
private IdentityProxy id = new IdentityProxy("volumes");
/*
@SerializedName(ApiConstants.JOB_ID)
@Param(description = "shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume")
private IdentityProxy jobId = new IdentityProxy("async_job");
@SerializedName(ApiConstants.JOB_STATUS)
@Param(description = "shows the current pending asynchronous job status")
private Integer jobStatus;
*/
@SerializedName(ApiConstants.NAME)
@Param(description = "name of the disk volume")
private String name;
@ -163,27 +153,6 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
return getId();
}
/*
@Override
public Long getJobId() {
return super.getJobId();
}
@Override
public void setJobId(Long jobId) {
super.setJobId(jobId);
}
@Override
public Integer getJobStatus() {
return jobStatus;
}
@Override
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
*/
public Boolean getDestroyed() {
return destroyed;
}

View File

@ -18,6 +18,8 @@
package com.cloud.network.security;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@ -27,12 +29,13 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.api.Identity;
import com.cloud.async.AsyncInstanceCreateStatus;
import com.google.gson.annotations.Expose;
@Entity
@Table(name = ("security_egress_rule"))
public class EgressRuleVO implements EgressRule {
public class EgressRuleVO implements EgressRule, Identity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
@ -61,6 +64,9 @@ public class EgressRuleVO implements EgressRule {
@Enumerated(value = EnumType.STRING)
private AsyncInstanceCreateStatus createStatus;
@Column(name = "uuid")
private String uuid = UUID.randomUUID().toString();
public EgressRuleVO() {
}
@ -123,4 +129,13 @@ public class EgressRuleVO implements EgressRule {
public String getAllowedDestinationIpCidr() {
return allowedDestinationIpCidr;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
}

View File

@ -19,6 +19,7 @@
package com.cloud.storage;
import java.util.Date;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -29,11 +30,12 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import com.cloud.api.Identity;
import com.cloud.storage.snapshot.SnapshotSchedule;
@Entity
@Table(name="snapshot_schedule")
public class SnapshotScheduleVO implements SnapshotSchedule {
public class SnapshotScheduleVO implements SnapshotSchedule, Identity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@ -56,7 +58,10 @@ public class SnapshotScheduleVO implements SnapshotSchedule {
@Column(name="snapshot_id")
Long snapshotId;
@Column(name="uuid")
String uuid = UUID.randomUUID().toString();
public SnapshotScheduleVO() { }
public SnapshotScheduleVO(long volumeId, long policyId, Date scheduledTimestamp) {
@ -108,5 +113,14 @@ public class SnapshotScheduleVO implements SnapshotSchedule {
public void setSnapshotId(Long snapshotId) {
this.snapshotId = snapshotId;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
}
}

View File

@ -19,6 +19,7 @@
package com.cloud.storage;
import java.util.Date;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -28,11 +29,12 @@ import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.agent.api.to.SwiftTO;
import com.cloud.api.Identity;
import com.cloud.utils.db.GenericDao;
@Entity
@Table(name="swift")
public class SwiftVO implements Swift {
public class SwiftVO implements Swift, Identity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@ -51,6 +53,9 @@ public class SwiftVO implements Swift {
@Column(name="key")
String key;
@Column(name="uuid")
String uuid = UUID.randomUUID().toString();
@Column(name = GenericDao.CREATED_COLUMN)
private Date created;
@ -92,4 +97,13 @@ public class SwiftVO implements Swift {
public SwiftTO toSwiftTO() {
return new SwiftTO(getId(), getUrl(), getAccount(), getUserName(), getKey());
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
}

View File

@ -34,10 +34,13 @@ import com.cloud.api.ApiDBUtils;
import com.cloud.api.ApiResponseGsonHelper;
import com.cloud.api.ApiServer;
import com.cloud.api.BaseCmd;
import com.cloud.api.IdentityProxy;
import com.cloud.api.ResponseObject;
import com.cloud.api.ResponseObjectTypeAdapter;
import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.identity.dao.IdentityDao;
import com.cloud.identity.dao.IdentityDaoImpl;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.encoding.URLEncoder;
import com.cloud.utils.exception.CloudRuntimeException;
@ -204,6 +207,14 @@ public class ApiResponseSerializer {
} else if (fieldValue instanceof Date) {
sb.append("<" + serializedName.value() + ">" + BaseCmd.getDateString((Date) fieldValue) + "</" + serializedName.value() + ">");
} else if (fieldValue instanceof IdentityProxy) {
IdentityProxy idProxy = (IdentityProxy)fieldValue;
String id = (idProxy.getValue() != null ? String.valueOf(idProxy.getValue()) : "");
if(!id.isEmpty()) {
IdentityDao identityDao = new IdentityDaoImpl();
id = identityDao.getIdentityUuid(idProxy.getTableName(), id);
}
sb.append("<" + serializedName.value() + ">" + id + "</" + serializedName.value() + ">");
} else {
String resultString = escapeSpecialXmlChars(fieldValue.toString());
if (!(obj instanceof ExceptionResponse)) {

View File

@ -20,19 +20,20 @@
package com.cloud.baremetal;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.api.response.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class DhcpServerResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the Dhcp server")
private Long id;
private IdentityProxy id = new IdentityProxy("host");
public Long getId() {
return id;
return id.getValue();
}
public void setId(Long id) {
this.id = id;
this.id.setValue(id);
}
}

View File

@ -20,19 +20,20 @@
package com.cloud.baremetal;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.api.response.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class PxeServerResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the PXE server")
private Long id;
private IdentityProxy id = new IdentityProxy("host");
public Long getId() {
return id;
return id.getValue();
}
public void setId(Long id) {
this.id = id;
this.id.setValue(id);
}
}

View File

@ -74,6 +74,8 @@ public class IdentityDaoImpl extends GenericDaoBase<IdentityVO, Long> implements
ResultSet rs = pstmt.executeQuery();
if(rs.next()) {
return rs.getLong(1);
} else {
throw new InvalidParameterValueException("Object " + tableName + "(uuid: " + identityString + ") does not exist.");
}
} catch (SQLException e) {
s_logger.error("Unexpected exception ", e);
@ -123,6 +125,6 @@ public class IdentityDaoImpl extends GenericDaoBase<IdentityVO, Long> implements
txn.close();
}
throw new InvalidParameterValueException("Object(uuid: " + identityString + ") does not exist");
return identityString;
}
}

View File

@ -1,18 +1,19 @@
package com.cloud.server.api.response;
import com.cloud.api.IdentityProxy;
import com.cloud.api.response.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class BaremetalTemplateResponse extends BaseResponse {
@SerializedName("id") @Param(description="the template ID")
private long id;
private IdentityProxy id = new IdentityProxy("vm_template");
public long getId() {
return id;
public Long getId() {
return id.getValue();
}
public void setId(long id) {
this.id = id;
public void setId(Long id) {
this.id.setValue(id);
}
}

View File

@ -1,16 +1,17 @@
package com.cloud.server.api.response;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class NwDevicePxeServerResponse extends NetworkDeviceResponse {
@SerializedName(ApiConstants.ZONE_ID) @Param(description="Zone where to add PXE server")
private Long zoneId;
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName(ApiConstants.POD_ID) @Param(description="Pod where to add PXE server")
private Long podId;
private IdentityProxy podId = new IdentityProxy("host_pod_ref");
@SerializedName(ApiConstants.URL) @Param(description="Ip of PXE server")
private String url;
@ -19,17 +20,17 @@ public class NwDevicePxeServerResponse extends NetworkDeviceResponse {
private String type;
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
this.zoneId.setValue(zoneId);
}
public Long getZoneId() {
return zoneId;
return zoneId.getValue();
}
public void setPodId(Long podId) {
this.podId = podId;
this.podId.setValue(podId);
}
public Long getPodId() {
return podId;
return podId.getValue();
}
public void setUrl(String url) {

View File

@ -20,6 +20,7 @@
package com.cloud.server.api.response;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.api.response.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@ -27,10 +28,10 @@ import com.google.gson.annotations.SerializedName;
public class TrafficMonitorResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the external firewall")
private Long id;
private IdentityProxy id = new IdentityProxy("host");
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the zone ID of the external firewall")
private Long zoneId;
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the management IP address of the external firewall")
private String ipAddress;
@ -42,19 +43,19 @@ public class TrafficMonitorResponse extends BaseResponse {
private String timeout;
public Long getId() {
return id;
return id.getValue();
}
public void setId(Long id) {
this.id = id;
this.id.setValue(id);
}
public Long getZoneId() {
return zoneId;
return zoneId.getValue();
}
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
this.zoneId.setValue(zoneId);
}
public String getIpAddress() {

View File

@ -19,6 +19,7 @@ package com.cloud.vm;
import java.net.URI;
import java.util.Date;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -29,13 +30,14 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.api.Identity;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.Mode;
import com.cloud.utils.db.GenericDao;
@Entity
@Table(name = "nics")
public class NicVO implements Nic {
public class NicVO implements Nic, Identity {
protected NicVO() {
}
@ -110,6 +112,9 @@ public class NicVO implements Nic {
@Column(name = GenericDao.CREATED_COLUMN)
Date created;
@Column(name = "uuid")
String uuid = UUID.randomUUID().toString();
public NicVO(String reserver, Long instanceId, long configurationId, VirtualMachine.Type vmType) {
this.reserver = reserver;
@ -310,4 +315,13 @@ public class NicVO implements Nic {
public VirtualMachine.Type getVmType() {
return vmType;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
}

View File

@ -219,6 +219,7 @@ CREATE TABLE `cloud`.`account_network_ref` (
CREATE TABLE `cloud`.`nics` (
`id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
`uuid` varchar(40),
`instance_id` bigint unsigned COMMENT 'vm instance id',
`mac_address` varchar(17) COMMENT 'mac address',
`ip4_address` char(40) COMMENT 'ip4 address',
@ -243,6 +244,7 @@ CREATE TABLE `cloud`.`nics` (
PRIMARY KEY (`id`),
CONSTRAINT `fk_nics__instance_id` FOREIGN KEY `fk_nics__instance_id`(`instance_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_nics__networks_id` FOREIGN KEY `fk_nics__networks_id`(`network_id`) REFERENCES `networks`(`id`),
CONSTRAINT `uc_nics__uuid` UNIQUE (`uuid`),
INDEX `i_nics__removed`(`removed`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -1472,12 +1474,14 @@ CREATE TABLE `cloud`.`snapshot_policy` (
CREATE TABLE `cloud`.`snapshot_schedule` (
`id` bigint unsigned NOT NULL auto_increment,
`uuid` varchar(40),
`volume_id` bigint unsigned NOT NULL COMMENT 'The volume for which this snapshot is being taken',
`policy_id` bigint unsigned NOT NULL COMMENT 'One of the policyIds for which this snapshot was taken',
`scheduled_timestamp` datetime NOT NULL COMMENT 'Time at which the snapshot was scheduled for execution',
`async_job_id` bigint unsigned COMMENT 'If this schedule is being executed, it is the id of the create aysnc_job. Before that it is null',
`snapshot_id` bigint unsigned COMMENT 'If this schedule is being executed, then the corresponding snapshot has this id. Before that it is null',
UNIQUE (volume_id, policy_id),
CONSTRAINT `uc_snapshot_schedule__uuid` UNIQUE (`uuid`),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -1519,6 +1523,7 @@ CREATE TABLE `cloud`.`security_ingress_rule` (
CREATE TABLE `cloud`.`security_egress_rule` (
`id` bigint unsigned NOT NULL auto_increment,
`uuid` varchar(40),
`security_group_id` bigint unsigned NOT NULL,
`start_port` varchar(10) default NULL,
`end_port` varchar(10) default NULL,
@ -1526,7 +1531,8 @@ CREATE TABLE `cloud`.`security_egress_rule` (
`allowed_network_id` bigint unsigned,
`allowed_ip_cidr` varchar(44),
`create_status` varchar(32) COMMENT 'rule creation status',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
CONSTRAINT `uc_security_egress_rule__uuid` UNIQUE (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`security_group_vm_map` (
@ -1725,12 +1731,14 @@ CREATE TABLE `cloud`.`keystore` (
CREATE TABLE `cloud`.`swift` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`uuid` varchar(40),
`url` varchar(255) NOT NULL,
`account` varchar(255) NOT NULL COMMENT ' account in swift',
`username` varchar(255) NOT NULL COMMENT ' username in swift',
`key` varchar(255) NOT NULL COMMENT 'token for this user',
`created` datetime COMMENT 'date the swift first signed on',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
CONSTRAINT `uc_swift__uuid` UNIQUE (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -169,6 +169,9 @@ ALTER TABLE `cloud`.`snapshots` ADD CONSTRAINT `uc_snapshots__uuid` UNIQUE (`uui
ALTER TABLE `cloud`.`snapshot_policy` ADD COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`snapshot_policy` ADD CONSTRAINT `uc_snapshot_policy__uuid` UNIQUE (`uuid`);
ALTER TABLE `cloud`.`snapshot_schedule` ADD COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`snapshot_schedule` ADD CONSTRAINT `uc_snapshot_schedule__uuid` UNIQUE (`uuid`);
ALTER TABLE `cloud`.`volumes` ADD COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`volumes` ADD CONSTRAINT `uc_volumes__uuid` UNIQUE (`uuid`);
@ -187,6 +190,9 @@ ALTER TABLE `cloud`.`cluster` ADD CONSTRAINT `uc_cluster__uuid` UNIQUE (`uuid`);
ALTER TABLE `cloud`.`security_ingress_rule` ADD COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`security_ingress_rule` ADD CONSTRAINT `uc_security_ingress_rule__uuid` UNIQUE (`uuid`);
ALTER TABLE `cloud`.`security_egress_rule` ADD COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`security_egress_rule` ADD CONSTRAINT `uc_security_egress_rule__uuid` UNIQUE (`uuid`);
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`network_offerings` ADD CONSTRAINT `uc_network_offerings__uuid` UNIQUE (`uuid`);
@ -208,3 +214,6 @@ ALTER TABLE `cloud`.`guest_os` ADD CONSTRAINT `uc_guest_os__uuid` UNIQUE (`uuid`
ALTER TABLE `cloud`.`guest_os_category` ADD COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`guest_os_category` ADD CONSTRAINT `uc_guest_os_category__uuid` UNIQUE (`uuid`);
ALTER TABLE `cloud`.`nics` ADD COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`nics` ADD CONSTRAINT `uc_nics__uuid` UNIQUE (`uuid`);