Remove IdentityProxy from Response classes.

Signed-off-by: Min Chen <min.chen@citrix.com>
This commit is contained in:
Min Chen 2012-12-18 23:16:38 -08:00
parent fc56e29a3e
commit 1d729578d4
19 changed files with 222 additions and 167 deletions

View File

@ -26,6 +26,8 @@ public interface Vlan {
public long getId();
public String getUuid();
public String getVlanTag();
public String getVlanGateway();

View File

@ -27,6 +27,8 @@ public interface VirtualRouterProvider {
public long getId();
public String getUuid();
public boolean isEnabled();
public long getNspId();

View File

@ -27,6 +27,8 @@ public interface VpnUser extends ControlledEntity {
long getId();
String getUuid();
String getUsername();
String getPassword();

View File

@ -126,7 +126,7 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
}
VpnUsersResponse vpnResponse = new VpnUsersResponse();
vpnResponse.setId(vpnUser.getId());
vpnResponse.setId(vpnUser.getUuid());
vpnResponse.setUserName(vpnUser.getUsername());
vpnResponse.setAccountName(account.getAccountName());

View File

@ -29,6 +29,7 @@ import org.apache.cloudstack.api.response.VolumeResponse;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Volume;
import com.cloud.user.UserContext;
@ -165,7 +166,18 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
if (volume != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
//FIXME - have to be moved to ApiResponseHelper
response.setSnapshotId(getSnapshotId()); // if the volume was created from a snapshot, snapshotId will be set so we pass it back in the response
if (getSnapshotId() != null) {
Snapshot snap = _queryService.findSnapshotById(getSnapshotId());
if (snap != null) {
response.setSnapshotId(snap.getUuid()); // if the volume was
// created from a
// snapshot,
// snapshotId will
// be set so we pass
// it back in the
// response
}
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {

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;
@ -31,7 +30,7 @@ public class TrafficTypeResponse extends BaseResponse {
private String trafficType;
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network this belongs to")
private IdentityProxy physicalNetworkId = new IdentityProxy("physical_network");
private String physicalNetworkId;
@SerializedName(ApiConstants.XEN_NETWORK_LABEL) @Param(description="The network name label of the physical device dedicated to this traffic on a XenServer host")
private String xenNetworkLabel;
@ -42,12 +41,12 @@ public class TrafficTypeResponse extends BaseResponse {
@SerializedName(ApiConstants.VMWARE_NETWORK_LABEL) @Param(description="The network name label of the physical device dedicated to this traffic on a VMware host")
private String vmwareNetworkLabel;
public void setPhysicalNetworkId(long physicalNetworkId) {
this.physicalNetworkId.setValue(physicalNetworkId);
public void setPhysicalNetworkId(String physicalNetworkId) {
this.physicalNetworkId = physicalNetworkId;
}
public long getphysicalNetworkId() {
return physicalNetworkId.getValue();
public String getphysicalNetworkId() {
return physicalNetworkId;
}
public void setId(String uuid) {

View File

@ -19,14 +19,13 @@ package org.apache.cloudstack.api.response;
import java.util.Date;
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;
public class UpgradeVmResponse extends BaseResponse {
@SerializedName("id")
private IdentityProxy id = new IdentityProxy("vm_instance");
private String id;
public String getName() {
return name;
@ -68,12 +67,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.account = account;
}
public Long getDomainId() {
return domainId.getValue();
public String getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId.setValue(domainId);
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public String getDomain() {
@ -92,12 +91,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.haEnable = haEnable;
}
public Long getZoneId() {
return zoneId.getValue();
public String getZoneId() {
return zoneId;
}
public void setZoneId(Long zoneId) {
this.zoneId.setValue(zoneId);
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getDisplayName() {
@ -116,12 +115,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.zoneName = zoneName;
}
public Long getHostId() {
return hostId.getValue();
public String getHostId() {
return hostId;
}
public void setHostId(Long hostId) {
this.hostId.setValue(hostId);
public void setHostId(String hostId) {
this.hostId = hostId;
}
public String getHostName() {
@ -132,12 +131,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.hostName = hostName;
}
public Long getTemplateId() {
return templateId.getValue();
public String getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId.setValue(templateId);
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public String getTemplateName() {
@ -164,12 +163,12 @@ public class UpgradeVmResponse extends BaseResponse {
this.passwordEnabled = passwordEnabled;
}
public Long getServiceOfferingId() {
return serviceOfferingId.getValue();
public String getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId.setValue(serviceOfferingId);
public void setServiceOfferingId(String serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public String getServiceOfferingName() {
@ -220,8 +219,8 @@ public class UpgradeVmResponse extends BaseResponse {
this.networkKbsWrite = networkKbsWrite;
}
public Long isId() {
return id.getValue();
public String isId() {
return id;
}
@SerializedName("name") @Param(description="the ID of the virtual machine")
@ -240,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 IdentityProxy domainId = new IdentityProxy("domain");
private String domainId;
@SerializedName("domain") @Param(description="the name of the domain in which the virtual machine exists")
private String domain;
@ -249,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 IdentityProxy zoneId = new IdentityProxy("data_center");
private String zoneId;
@SerializedName("displayname") @Param(description="user generated name. The name of the virtual machine is returned if no displayname exists.")
private String displayName;
@ -258,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 IdentityProxy hostId = new IdentityProxy("host");
private String hostId;
@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 IdentityProxy templateId = new IdentityProxy("vm_template");
private String templateId;
@SerializedName("templatename") @Param(description="the name of the template for the virtual machine")
private String templateName;
@ -276,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 IdentityProxy serviceOfferingId = new IdentityProxy("disk_offering");
private String serviceOfferingId;
@SerializedName("serviceofferingname") @Param(description="the name of the service offering of the virtual machine")
private String serviceOfferingName;

View File

@ -17,17 +17,16 @@
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;
public class VirtualRouterProviderResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID) @Param(description="the id of the router")
private IdentityProxy id = new IdentityProxy("virtual_router_providers");
private String id;
@SerializedName(ApiConstants.NSP_ID) @Param(description="the physical network service provider id of the provider")
private IdentityProxy nspId = new IdentityProxy("physical_network_service_providers");
private String nspId;
@SerializedName(ApiConstants.ENABLED) @Param(description="Enabled/Disabled the service provider")
private Boolean enabled;
@ -52,8 +51,8 @@ public class VirtualRouterProviderResponse extends BaseResponse implements Contr
this.accountName = accountName;
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
@Override
@ -76,8 +75,8 @@ public class VirtualRouterProviderResponse extends BaseResponse implements Contr
this.projectName = projectName;
}
public void setNspId(Long nspId) {
this.nspId.setValue(nspId);
public void setNspId(String nspId) {
this.nspId = nspId;
}
public void setEnabled(Boolean enabled) {

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,13 +24,13 @@ import org.apache.cloudstack.api.BaseResponse;
@SuppressWarnings("unused")
public class VlanIpRangeResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName(ApiConstants.ID) @Param(description="the ID of the VLAN IP range")
private IdentityProxy id = new IdentityProxy("vlan");
private String id;
@SerializedName("forvirtualnetwork") @Param(description="the virtual network for the VLAN IP range")
private Boolean forVirtualNetwork;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID of the VLAN IP range")
private IdentityProxy zoneId = new IdentityProxy("data_center");
private String zoneId;
@SerializedName(ApiConstants.VLAN) @Param(description="the ID or VID of the VLAN.")
private String vlan;
@ -46,7 +45,7 @@ public class VlanIpRangeResponse extends BaseResponse implements ControlledEntit
private String domainName;
@SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID for the VLAN IP range")
private IdentityProxy podId = new IdentityProxy("host_pod_ref");
private String podId;
@SerializedName("podname") @Param(description="the Pod name for the VLAN IP range")
private String podName;
@ -67,7 +66,7 @@ public class VlanIpRangeResponse extends BaseResponse implements ControlledEntit
private String endIp;
@SerializedName(ApiConstants.NETWORK_ID) @Param(description="the network id of vlan range")
private IdentityProxy networkId = new IdentityProxy("networks");
private String networkId;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the vlan range")
private String projectId;
@ -76,18 +75,18 @@ public class VlanIpRangeResponse extends BaseResponse implements ControlledEntit
private String projectName;
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network this belongs to")
private IdentityProxy physicalNetworkId = new IdentityProxy("physical_network");
private String physicalNetworkId;
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setForVirtualNetwork(Boolean forVirtualNetwork) {
this.forVirtualNetwork = forVirtualNetwork;
}
public void setZoneId(Long zoneId) {
this.zoneId.setValue(zoneId);
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setVlan(String vlan) {
@ -106,8 +105,8 @@ public class VlanIpRangeResponse extends BaseResponse implements ControlledEntit
this.domainName = domainName;
}
public void setPodId(Long podId) {
this.podId.setValue(podId);
public void setPodId(String podId) {
this.podId = podId;
}
public void setPodName(String podName) {
@ -134,8 +133,8 @@ public class VlanIpRangeResponse extends BaseResponse implements ControlledEntit
this.endIp = endIp;
}
public void setNetworkId(Long networkId) {
this.networkId.setValue(networkId);
public void setNetworkId(String networkId) {
this.networkId = networkId;
}
@Override
@ -148,11 +147,11 @@ public class VlanIpRangeResponse extends BaseResponse implements ControlledEntit
this.projectName = projectName;
}
public void setPhysicalNetworkId(long physicalNetworkId) {
this.physicalNetworkId.setValue(physicalNetworkId);
public void setPhysicalNetworkId(String physicalNetworkId) {
this.physicalNetworkId = physicalNetworkId;
}
public long getphysicalNetworkId() {
return physicalNetworkId.getValue();
public String getphysicalNetworkId() {
return physicalNetworkId;
}
}

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 VolumeResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName(ApiConstants.ID)
@Param(description = "ID of the disk volume")
private IdentityProxy id = new IdentityProxy("volumes");
private String id;
@SerializedName(ApiConstants.NAME)
@Param(description = "name of the disk volume")
@ -37,7 +36,7 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "ID of the availability zone")
private IdentityProxy zoneId = new IdentityProxy("data_center");
private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME)
@Param(description = "name of the availability zone")
@ -53,7 +52,7 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID)
@Param(description = "id of the virtual machine")
private IdentityProxy virtualMachineId = new IdentityProxy("vm_instance");
private String virtualMachineId;
@SerializedName("vmname")
@Param(description = "name of the virtual machine")
@ -107,7 +106,7 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
@SerializedName(ApiConstants.DISK_OFFERING_ID)
@Param(description = "ID of the disk offering")
private IdentityProxy diskOfferingId = new IdentityProxy("disk_offering");
private String diskOfferingId;
@SerializedName("diskofferingname")
@Param(description = "name of the disk offering")
@ -123,7 +122,7 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
@SerializedName(ApiConstants.SNAPSHOT_ID)
@Param(description = "ID of the snapshot from which this volume was created")
private IdentityProxy snapshotId = new IdentityProxy("snapshots");
private String snapshotId;
@SerializedName("attached")
@Param(description = "the date the volume was attached to a VM instance")
@ -135,7 +134,7 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
@SerializedName(ApiConstants.SERVICE_OFFERING_ID)
@Param(description = "ID of the service offering for root disk")
private IdentityProxy serviceOfferingId = new IdentityProxy("disk_offering");
private String serviceOfferingId;
@SerializedName("serviceofferingname")
@Param(description = "name of the service offering for root disk")
@ -156,10 +155,7 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with volume", responseObject = ResourceTagResponse.class)
private List<ResourceTagResponse> tags;
@Override
public Long getObjectId() {
return getId();
}
public Boolean getDestroyed() {
return destroyed;
@ -169,20 +165,20 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
this.destroyed = destroyed;
}
public Long getId() {
return id.getValue();
public String getId() {
return id;
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setZoneId(Long zoneId) {
this.zoneId.setValue(zoneId);
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setZoneName(String zoneName) {
@ -197,8 +193,8 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
this.deviceId = deviceId;
}
public void setVirtualMachineId(Long virtualMachineId) {
this.virtualMachineId.setValue(virtualMachineId);
public void setVirtualMachineId(String virtualMachineId) {
this.virtualMachineId = virtualMachineId;
}
public void setVirtualMachineName(String virtualMachineName) {
@ -242,8 +238,8 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
this.hypervisor = hypervisor;
}
public void setDiskOfferingId(Long diskOfferingId) {
this.diskOfferingId.setValue(diskOfferingId);
public void setDiskOfferingId(String diskOfferingId) {
this.diskOfferingId = diskOfferingId;
}
public void setDiskOfferingName(String diskOfferingName) {
@ -258,16 +254,16 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
this.storagePoolName = storagePoolName;
}
public void setSnapshotId(Long snapshotId) {
this.snapshotId.setValue(snapshotId);
public void setSnapshotId(String snapshotId) {
this.snapshotId = snapshotId;
}
public void setAttached(Date attached) {
this.attached = attached;
}
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId.setValue(serviceOfferingId);
public void setServiceOfferingId(String serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public void setServiceOfferingName(String serviceOfferingName) {

View File

@ -21,14 +21,13 @@ 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;
@SuppressWarnings("unused")
public class VpcOfferingResponse extends BaseResponse {
@SerializedName("id") @Param(description="the id of the vpc offering")
private final IdentityProxy id = new IdentityProxy("vpc_offerings");
private String id;
@SerializedName(ApiConstants.NAME) @Param(description="the name of the vpc offering")
private String name;
@ -49,8 +48,8 @@ public class VpcOfferingResponse extends BaseResponse {
private List<ServiceResponse> services;
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setName(String name) {

View File

@ -22,7 +22,6 @@ import java.util.List;
import com.cloud.network.vpc.Vpc;
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;
import org.apache.cloudstack.api.Entity;
@ -31,7 +30,7 @@ import org.apache.cloudstack.api.Entity;
@SuppressWarnings("unused")
public class VpcResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName("id") @Param(description="the id of the VPC")
private final IdentityProxy id = new IdentityProxy("vpc");
private String id;
@SerializedName(ApiConstants.NAME) @Param(description="the name of the VPC")
private String name;
@ -43,7 +42,7 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
private String state;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone id of the vpc")
private IdentityProxy zoneId = new IdentityProxy("data_center");
private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the zone the VPC belongs to")
private String zoneName;
@ -55,7 +54,7 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
private String cidr;
@SerializedName(ApiConstants.VPC_OFF_ID) @Param(description="vpc offering id the VPC is created from")
private IdentityProxy vpcOfferingId = new IdentityProxy("vpc_offerings");
private String vpcOfferingId;
@SerializedName(ApiConstants.CREATED) @Param(description="the date this VPC was created")
private Date created;
@ -87,8 +86,8 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with the project", responseObject = ResourceTagResponse.class)
private List<ResourceTagResponse> tags;
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
@ -136,16 +135,16 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
this.domain = domainName;
}
public void setZoneId(Long zoneId) {
this.zoneId.setValue(zoneId);
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setCidr(String cidr) {
this.cidr = cidr;
}
public void setVpcOfferingId(Long vpcOfferingId) {
this.vpcOfferingId.setValue(vpcOfferingId);
public void setVpcOfferingId(String vpcOfferingId) {
this.vpcOfferingId = vpcOfferingId;
}
public List<NetworkResponse> getNetworks() {

View File

@ -18,7 +18,6 @@ package org.apache.cloudstack.api.response;
import com.cloud.network.VpnUser;
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;
@ -28,7 +27,7 @@ import org.apache.cloudstack.api.Entity;
@SuppressWarnings("unused")
public class VpnUsersResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName(ApiConstants.ID) @Param(description="the vpn userID")
private IdentityProxy id = new IdentityProxy("vpn_users");
private String id;
@SerializedName(ApiConstants.USERNAME) @Param(description="the username of the vpn user")
private String userName;
@ -49,8 +48,8 @@ public class VpnUsersResponse extends BaseResponse implements ControlledEntityRe
private String projectName;
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setUserName(String name) {

View File

@ -40,6 +40,7 @@ import org.apache.cloudstack.api.response.UserVmResponse;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.Snapshot;
/**
* Service used for list api query.
@ -68,4 +69,6 @@ public interface QueryService {
public ListResponse<ProjectAccountResponse> listProjectAccounts(ListProjectAccountsCmd cmd);
public Snapshot findSnapshotById(long snapshotId);
}

View File

@ -32,7 +32,7 @@ import com.cloud.utils.db.Encrypt;
@Entity
@Table(name=("vpn_users"))
public class VpnUserVO implements VpnUser, Identity {
public class VpnUserVO implements VpnUser {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")

View File

@ -137,9 +137,11 @@ import com.cloud.network.security.dao.SecurityGroupDao;
import com.cloud.network.vpc.StaticRouteVO;
import com.cloud.network.vpc.VpcGatewayVO;
import com.cloud.network.vpc.VpcManager;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.network.vpc.VpcVO;
import com.cloud.network.vpc.dao.StaticRouteDao;
import com.cloud.network.vpc.dao.VpcGatewayDao;
import com.cloud.network.vpc.dao.VpcOfferingDao;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.offerings.NetworkOfferingVO;
@ -307,6 +309,7 @@ public class ApiDBUtils {
private static StaticRouteDao _staticRouteDao;
private static VpcGatewayDao _vpcGatewayDao;
private static VpcDao _vpcDao;
private static VpcOfferingDao _vpcOfferingDao;
private static SnapshotPolicyDao _snapshotPolicyDao;
static {
@ -392,6 +395,7 @@ public class ApiDBUtils {
_asVmProfileDao = locator.getDao(AutoScaleVmProfileDao.class);
_asVmGroupDao = locator.getDao(AutoScaleVmGroupDao.class);
_vpcDao = locator.getDao(VpcDao.class);
_vpcOfferingDao = locator.getDao(VpcOfferingDao.class);
_snapshotPolicyDao = locator.getDao(SnapshotPolicyDao.class);
// Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
@ -1037,6 +1041,9 @@ public class ApiDBUtils {
return _snapshotPolicyDao.findById(policyId);
}
public static VpcOffering findVpcOfferingById(long offeringId){
return _vpcOfferingDao.findById(offeringId);
}
///////////////////////////////////////////////////////////////////////
// Newly Added Utility Methods for List API refactoring //
///////////////////////////////////////////////////////////////////////

View File

@ -776,15 +776,20 @@ public class ApiResponseHelper implements ResponseGenerator {
Long podId = ApiDBUtils.getPodIdForVlan(vlan.getId());
VlanIpRangeResponse vlanResponse = new VlanIpRangeResponse();
vlanResponse.setId(vlan.getId());
vlanResponse.setForVirtualNetwork(vlan.getVlanType().equals(VlanType.VirtualNetwork));
vlanResponse.setId(vlan.getUuid());
if (vlan.getVlanType() != null) {
vlanResponse.setForVirtualNetwork(vlan.getVlanType().equals(VlanType.VirtualNetwork));
}
vlanResponse.setVlan(vlan.getVlanTag());
vlanResponse.setZoneId(vlan.getDataCenterId());
DataCenter zone = ApiDBUtils.findZoneById(vlan.getDataCenterId());
if (zone != null) {
vlanResponse.setZoneId(zone.getUuid());
}
if (podId != null) {
HostPodVO pod = ApiDBUtils.findPodById(podId);
vlanResponse.setPodId(podId);
if (pod != null) {
vlanResponse.setPodId(pod.getUuid());
vlanResponse.setPodName(pod.getName());
}
}
@ -798,15 +803,24 @@ public class ApiResponseHelper implements ResponseGenerator {
vlanResponse.setStartIp(range[0]);
vlanResponse.setEndIp(range[1]);
vlanResponse.setNetworkId(vlan.getNetworkId());
if (vlan.getNetworkId() != null) {
Network nw = ApiDBUtils.findNetworkById(vlan.getNetworkId());
if (nw != null) {
vlanResponse.setNetworkId(nw.getUuid());
}
}
Account owner = ApiDBUtils.getVlanAccount(vlan.getId());
if (owner != null) {
populateAccount(vlanResponse, owner.getId());
populateDomain(vlanResponse, owner.getDomainId());
}
vlanResponse.setPhysicalNetworkId(vlan.getPhysicalNetworkId());
if (vlan.getPhysicalNetworkId() != null) {
PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(vlan.getPhysicalNetworkId());
if (pnw != null) {
vlanResponse.setPhysicalNetworkId(pnw.getUuid());
}
}
vlanResponse.setObjectName("vlan");
return vlanResponse;
}
@ -1131,7 +1145,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public VolumeResponse createVolumeResponse(Volume volume) {
VolumeResponse volResponse = new VolumeResponse();
volResponse.setId(volume.getId());
volResponse.setId(volume.getUuid());
if (volume.getName() != null) {
volResponse.setName(volume.getName());
@ -1139,8 +1153,11 @@ public class ApiResponseHelper implements ResponseGenerator {
volResponse.setName("");
}
volResponse.setZoneId(volume.getDataCenterId());
volResponse.setZoneName(ApiDBUtils.findZoneById(volume.getDataCenterId()).getName());
DataCenter zone = ApiDBUtils.findZoneById(volume.getDataCenterId());
if (zone != null) {
volResponse.setZoneId(zone.getUuid());
volResponse.setZoneName(zone.getName());
}
if (volume.getVolumeType() != null) {
volResponse.setVolumeType(volume.getVolumeType().toString());
@ -1151,7 +1168,7 @@ public class ApiResponseHelper implements ResponseGenerator {
if (instanceId != null && volume.getState() != Volume.State.Destroy) {
VMInstanceVO vm = ApiDBUtils.findVMInstanceById(instanceId);
if (vm != null) {
volResponse.setVirtualMachineId(vm.getId());
volResponse.setVirtualMachineId(vm.getUuid());
volResponse.setVirtualMachineName(vm.getHostName());
if (vm.getState() != null) {
volResponse.setVirtualMachineState(vm.getState().toString());
@ -1214,22 +1231,24 @@ public class ApiResponseHelper implements ResponseGenerator {
populateOwner(volResponse, volume);
if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
volResponse.setServiceOfferingId(volume.getDiskOfferingId());
} else {
volResponse.setDiskOfferingId(volume.getDiskOfferingId());
}
DiskOfferingVO diskOffering = ApiDBUtils.findDiskOfferingById(volume.getDiskOfferingId());
if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
volResponse.setServiceOfferingName(diskOffering.getName());
volResponse.setServiceOfferingDisplayText(diskOffering.getDisplayText());
} else {
volResponse.setDiskOfferingName(diskOffering.getName());
volResponse.setDiskOfferingDisplayText(diskOffering.getDisplayText());
}
volResponse.setStorageType(diskOffering.getUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
if (diskOffering != null) {
if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
volResponse.setServiceOfferingId(diskOffering.getUuid());
} else {
volResponse.setDiskOfferingId(diskOffering.getUuid());
}
if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
volResponse.setServiceOfferingName(diskOffering.getName());
volResponse.setServiceOfferingDisplayText(diskOffering.getDisplayText());
} else {
volResponse.setDiskOfferingName(diskOffering.getName());
volResponse.setDiskOfferingDisplayText(diskOffering.getDisplayText());
}
volResponse.setStorageType(diskOffering.getUseLocalStorage() ? ServiceOffering.StorageType.local.toString()
: ServiceOffering.StorageType.shared.toString());
}
Long poolId = volume.getPoolId();
String poolName = (poolId == null) ? "none" : ApiDBUtils.findStoragePoolById(poolId).getName();
volResponse.setStoragePoolName(poolName);
@ -1615,7 +1634,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public VpnUsersResponse createVpnUserResponse(VpnUser vpnUser) {
VpnUsersResponse vpnResponse = new VpnUsersResponse();
vpnResponse.setId(vpnUser.getId());
vpnResponse.setId(vpnUser.getUuid());
vpnResponse.setUserName(vpnUser.getUsername());
populateOwner(vpnResponse, vpnUser);
@ -3247,7 +3266,10 @@ public class ApiResponseHelper implements ResponseGenerator {
public TrafficTypeResponse createTrafficTypeResponse(PhysicalNetworkTrafficType result) {
TrafficTypeResponse response = new TrafficTypeResponse();
response.setId(result.getUuid());
response.setPhysicalNetworkId(result.getPhysicalNetworkId());
PhysicalNetwork pnet = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId());
if (pnet != null) {
response.setPhysicalNetworkId(pnet.getUuid());
}
if (result.getTrafficType() != null) {
response.setTrafficType(result.getTrafficType().toString());
}
@ -3262,8 +3284,11 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result) {
VirtualRouterProviderResponse response = new VirtualRouterProviderResponse();
response.setId(result.getId());
response.setNspId(result.getNspId());
response.setId(result.getUuid());
PhysicalNetworkServiceProvider nsp = ApiDBUtils.findPhysicalNetworkServiceProviderById(result.getNspId());
if (nsp != null) {
response.setNspId(nsp.getUuid());
}
response.setEnabled(result.isEnabled());
response.setObjectName("virtualrouterelement");
@ -3373,7 +3398,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering) {
VpcOfferingResponse response = new VpcOfferingResponse();
response.setId(offering.getId());
response.setId(offering.getUuid());
response.setName(offering.getName());
response.setDisplayText(offering.getDisplayText());
response.setIsDefault(offering.isDefault());
@ -3409,11 +3434,14 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public VpcResponse createVpcResponse(Vpc vpc) {
VpcResponse response = new VpcResponse();
response.setId(vpc.getId());
response.setId(vpc.getUuid());
response.setName(vpc.getName());
response.setDisplayText(vpc.getDisplayText());
response.setState(vpc.getState().name());
response.setVpcOfferingId(vpc.getVpcOfferingId());
VpcOffering voff = ApiDBUtils.findVpcOfferingById(vpc.getVpcOfferingId());
if (voff != null) {
response.setVpcOfferingId(voff.getUuid());
}
response.setCidr(vpc.getCidr());
response.setRestartRequired(vpc.isRestartRequired());
response.setNetworkDomain(vpc.getNetworkDomain());
@ -3448,8 +3476,10 @@ public class ApiResponseHelper implements ResponseGenerator {
}
DataCenter zone = ApiDBUtils.findZoneById(vpc.getZoneId());
response.setZoneId(vpc.getZoneId());
response.setZoneName(zone.getName());
if (zone != null) {
response.setZoneId(zone.getUuid());
response.setZoneName(zone.getName());
}
response.setNetworks(networkResponses);
response.setServices(serviceResponses);

View File

@ -51,6 +51,7 @@ import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.query.QueryService;
import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.ApiResponseHelper;
import com.cloud.api.query.dao.DomainRouterJoinDao;
import com.cloud.api.query.dao.InstanceGroupJoinDao;
@ -87,6 +88,7 @@ import com.cloud.projects.ProjectService;
import com.cloud.projects.dao.ProjectAccountDao;
import com.cloud.projects.dao.ProjectDao;
import com.cloud.server.Criteria;
import com.cloud.storage.Snapshot;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.AccountManagerImpl;
@ -1306,4 +1308,10 @@ public class QueryManagerImpl implements QueryService, Manager {
return _projectAccountJoinDao.searchAndCount(sc, searchFilter);
}
@Override
public Snapshot findSnapshotById(long snapshotId) {
return ApiDBUtils.findSnapshotById(snapshotId);
}
}

View File

@ -31,41 +31,41 @@ import org.apache.cloudstack.api.Identity;
@Entity
@Table(name="vlan")
public class VlanVO implements Vlan, Identity {
public class VlanVO implements Vlan {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
@Column(name="id")
Long id;
@Column(name="vlan_id")
@Column(name="vlan_id")
String vlanTag;
@Column(name="vlan_gateway")
@Column(name="vlan_gateway")
String vlanGateway;
@Column(name="vlan_netmask")
@Column(name="vlan_netmask")
String vlanNetmask;
@Column(name="data_center_id")
@Column(name="data_center_id")
long dataCenterId;
@Column(name="description")
@Column(name="description")
String ipRange;
@Column(name="network_id")
Long networkId;
@Column(name="physical_network_id")
Long physicalNetworkId;
@Column(name="vlan_type")
@Enumerated(EnumType.STRING)
@Enumerated(EnumType.STRING)
VlanType vlanType;
@Column(name="uuid")
String uuid;
public VlanVO(VlanType vlanType, String vlanTag, String vlanGateway, String vlanNetmask, long dataCenterId, String ipRange, Long networkId, Long physicalNetworkId) {
this.vlanType = vlanType;
this.vlanTag = vlanTag;
@ -77,16 +77,16 @@ public class VlanVO implements Vlan, Identity {
this.uuid = UUID.randomUUID().toString();
this.physicalNetworkId = physicalNetworkId;
}
public VlanVO() {
this.uuid = UUID.randomUUID().toString();
}
@Override
public long getId() {
return id;
}
@Override
public String getVlanTag() {
return vlanTag;
@ -96,12 +96,12 @@ public class VlanVO implements Vlan, Identity {
public String getVlanGateway() {
return vlanGateway;
}
@Override
public String getVlanNetmask() {
return vlanNetmask;
}
@Override
public long getDataCenterId() {
return dataCenterId;
@ -125,12 +125,12 @@ public class VlanVO implements Vlan, Identity {
public void setNetworkId(Long networkId) {
this.networkId = networkId;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
@ -142,7 +142,7 @@ public class VlanVO implements Vlan, Identity {
public void setPhysicalNetworkId(Long physicalNetworkId) {
this.physicalNetworkId = physicalNetworkId;
}
transient String toString;
@Override
public String toString() {
@ -152,5 +152,5 @@ public class VlanVO implements Vlan, Identity {
}
return toString;
}
}