Conflicts:

api/src/org/apache/cloudstack/api/response/AccountResponse.java

Signed-off-by: Min Chen <min.chen@citrix.com>
This commit is contained in:
Min Chen 2012-12-17 15:41:56 -08:00
parent de8aa86542
commit 348d3ae448
18 changed files with 290 additions and 273 deletions

View File

@ -31,6 +31,8 @@ public interface DataCenter extends Grouping {
long getId(); long getId();
String getUuid();
String getDns1(); String getDns1();
String getDns2(); String getDns2();

View File

@ -33,6 +33,8 @@ public interface Domain extends OwnedBy {
long getId(); long getId();
String getUuid();
Long getParent(); Long getParent();
void setParent(Long parent); void setParent(Long parent);

View File

@ -66,6 +66,8 @@ public interface Host extends StateObject<Status> {
*/ */
long getId(); long getId();
String getUuid();
/** /**
* @return name of the machine. * @return name of the machine.
*/ */

View File

@ -27,6 +27,8 @@ public interface Cluster extends Grouping {
long getId(); long getId();
String getUuid();
String getName(); String getName();
long getDataCenterId(); long getDataCenterId();

View File

@ -51,6 +51,8 @@ public interface Account extends ControlledEntity {
public long getId(); public long getId();
public String getUuid();
public String getAccountName(); public String getAccountName();
public short getType(); public short getType();

View File

@ -25,7 +25,6 @@ import org.apache.cloudstack.api.Entity;
import com.cloud.domain.Domain; import com.cloud.domain.Domain;
import com.cloud.serializer.Param; import com.cloud.serializer.Param;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.utils.IdentityProxy;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.BaseResponse;
@ -33,7 +32,7 @@ import org.apache.cloudstack.api.BaseResponse;
@Entity(value = Account.class) @Entity(value = Account.class)
public class AccountResponse extends BaseResponse { public class AccountResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the id of the account") @SerializedName(ApiConstants.ID) @Param(description="the id of the account")
private IdentityProxy id = new IdentityProxy("account"); private String id;
@SerializedName(ApiConstants.NAME) @Param(description="the name of the account") @SerializedName(ApiConstants.NAME) @Param(description="the name of the account")
private String name; private String name;
@ -42,13 +41,13 @@ public class AccountResponse extends BaseResponse {
private Short accountType; private Short accountType;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="id of the Domain the account belongs too") @SerializedName(ApiConstants.DOMAIN_ID) @Param(description="id of the Domain the account belongs too")
private IdentityProxy domainId = new IdentityProxy("domain"); private String domainId;
@SerializedName(ApiConstants.DOMAIN) @Param(description="name of the Domain the account belongs too") @SerializedName(ApiConstants.DOMAIN) @Param(description="name of the Domain the account belongs too")
private String domainName; private String domainName;
@SerializedName(ApiConstants.DEFAULT_ZONE_ID) @Param(description="the default zone of the account") @SerializedName(ApiConstants.DEFAULT_ZONE_ID) @Param(description="the default zone of the account")
private IdentityProxy defaultZoneId = new IdentityProxy("data_center"); private String defaultZoneId;
@SerializedName(ApiConstants.RECEIVED_BYTES) @Param(description="the total number of network traffic bytes received") @SerializedName(ApiConstants.RECEIVED_BYTES) @Param(description="the total number of network traffic bytes received")
private Long bytesReceived; private Long bytesReceived;
@ -150,8 +149,8 @@ public class AccountResponse extends BaseResponse {
@SerializedName(ApiConstants.ACCOUNT_DETAILS) @Param(description="details for the account") @SerializedName(ApiConstants.ACCOUNT_DETAILS) @Param(description="details for the account")
private Map<String, String> details; private Map<String, String> details;
public void setId(Long id) { public void setId(String id) {
this.id.setValue(id); this.id = id;
} }
public void setName(String name) { public void setName(String name) {
@ -162,8 +161,8 @@ public class AccountResponse extends BaseResponse {
this.accountType = accountType; this.accountType = accountType;
} }
public void setDomainId(Long domainId) { public void setDomainId(String domainId) {
this.domainId.setValue(domainId); this.domainId = domainId;
} }
public void setDomainName(String domainName) { public void setDomainName(String domainName) {
@ -290,7 +289,7 @@ public class AccountResponse extends BaseResponse {
this.networkAvailable = networkAvailable; this.networkAvailable = networkAvailable;
} }
public void setDefaultZone(Long defaultZoneId) { public void setDefaultZone(String defaultZoneId) {
this.defaultZoneId.setValue(defaultZoneId); this.defaultZoneId = defaultZoneId;
} }
} }

View File

@ -27,19 +27,19 @@ public class CapacityResponse extends BaseResponse {
private Short capacityType; private Short capacityType;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID") @SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID")
private IdentityProxy zoneId = new IdentityProxy("data_center"); private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name") @SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name")
private String zoneName; private String zoneName;
@SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID") @SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID")
private IdentityProxy podId = new IdentityProxy("host_pod_ref"); private String podId;
@SerializedName("podname") @Param(description="the Pod name") @SerializedName("podname") @Param(description="the Pod name")
private String podName; private String podName;
@SerializedName(ApiConstants.CLUSTER_ID) @Param(description="the Cluster ID") @SerializedName(ApiConstants.CLUSTER_ID) @Param(description="the Cluster ID")
private IdentityProxy clusterId = new IdentityProxy("cluster"); private String clusterId;
@SerializedName("clustername") @Param(description="the Cluster name") @SerializedName("clustername") @Param(description="the Cluster name")
private String clusterName; private String clusterName;
@ -61,12 +61,12 @@ public class CapacityResponse extends BaseResponse {
this.capacityType = capacityType; this.capacityType = capacityType;
} }
public Long getZoneId() { public String getZoneId() {
return zoneId.getValue(); return zoneId;
} }
public void setZoneId(Long zoneId) { public void setZoneId(String zoneId) {
this.zoneId.setValue(zoneId); this.zoneId = zoneId;
} }
public String getZoneName() { public String getZoneName() {
@ -77,12 +77,12 @@ public class CapacityResponse extends BaseResponse {
this.zoneName = zoneName; this.zoneName = zoneName;
} }
public Long getPodId() { public String getPodId() {
return podId.getValue(); return podId;
} }
public void setPodId(Long podId) { public void setPodId(String podId) {
this.podId.setValue(podId); this.podId = podId;
} }
public String getPodName() { public String getPodName() {
@ -93,12 +93,12 @@ public class CapacityResponse extends BaseResponse {
this.podName = podName; this.podName = podName;
} }
public Long getClusterId() { public String getClusterId() {
return clusterId.getValue(); return clusterId;
} }
public void setClusterId(Long clusterId) { public void setClusterId(String clusterId) {
this.clusterId.setValue(clusterId); this.clusterId = clusterId;
} }
public String getClusterName() { public String getClusterName() {

View File

@ -32,19 +32,19 @@ import org.apache.cloudstack.api.BaseResponse;
@Entity(value = Cluster.class) @Entity(value = Cluster.class)
public class ClusterResponse extends BaseResponse { public class ClusterResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the cluster ID") @SerializedName(ApiConstants.ID) @Param(description="the cluster ID")
private IdentityProxy id = new IdentityProxy("cluster"); private String id;
@SerializedName(ApiConstants.NAME) @Param(description="the cluster name") @SerializedName(ApiConstants.NAME) @Param(description="the cluster name")
private String name; private String name;
@SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID of the cluster") @SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID of the cluster")
private IdentityProxy podId = new IdentityProxy("host_pod_ref"); private String podId;
@SerializedName("podname") @Param(description="the Pod name of the cluster") @SerializedName("podname") @Param(description="the Pod name of the cluster")
private String podName; private String podName;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID of the cluster") @SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID of the cluster")
private IdentityProxy zoneId = new IdentityProxy("data_center"); private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the cluster") @SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the cluster")
private String zoneName; private String zoneName;
@ -64,12 +64,12 @@ public class ClusterResponse extends BaseResponse {
@SerializedName("capacity") @Param(description="the capacity of the Cluster", responseObject = CapacityResponse.class) @SerializedName("capacity") @Param(description="the capacity of the Cluster", responseObject = CapacityResponse.class)
private List<CapacityResponse> capacitites; private List<CapacityResponse> capacitites;
public Long getId() { public String getId() {
return id.getValue(); return id;
} }
public void setId(Long id) { public void setId(String id) {
this.id.setValue(id); this.id = id;
} }
public String getName() { public String getName() {
@ -80,12 +80,12 @@ public class ClusterResponse extends BaseResponse {
this.name = name; this.name = name;
} }
public Long getPodId() { public String getPodId() {
return podId.getValue(); return podId;
} }
public void setPodId(Long podId) { public void setPodId(String podId) {
this.podId.setValue(podId); this.podId = podId;
} }
public String getPodName() { public String getPodName() {
@ -96,12 +96,12 @@ public class ClusterResponse extends BaseResponse {
this.podName = podName; this.podName = podName;
} }
public Long getZoneId() { public String getZoneId() {
return zoneId.getValue(); return zoneId;
} }
public void setZoneId(Long zoneId) { public void setZoneId(String zoneId) {
this.zoneId.setValue(zoneId); this.zoneId = zoneId;
} }
public String getZoneName() { public String getZoneName() {

View File

@ -27,7 +27,7 @@ import com.google.gson.annotations.SerializedName;
@Entity(value = Domain.class) @Entity(value = Domain.class)
public class DomainResponse extends BaseResponse { public class DomainResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the domain") @SerializedName(ApiConstants.ID) @Param(description="the ID of the domain")
private IdentityProxy id = new IdentityProxy("domain"); private String id;
@SerializedName(ApiConstants.NAME) @Param(description="the name of the domain") @SerializedName(ApiConstants.NAME) @Param(description="the name of the domain")
private String domainName; private String domainName;
@ -36,7 +36,7 @@ public class DomainResponse extends BaseResponse {
private Integer level; private Integer level;
@SerializedName("parentdomainid") @Param(description="the domain ID of the parent domain") @SerializedName("parentdomainid") @Param(description="the domain ID of the parent domain")
private IdentityProxy parentDomainId = new IdentityProxy("domain"); private String parentDomainId;
@SerializedName("parentdomainname") @Param(description="the domain name of the parent domain") @SerializedName("parentdomainname") @Param(description="the domain name of the parent domain")
private String parentDomainName; private String parentDomainName;
@ -50,12 +50,12 @@ public class DomainResponse extends BaseResponse {
@SerializedName(ApiConstants.PATH) @Param(description="the path of the domain") @SerializedName(ApiConstants.PATH) @Param(description="the path of the domain")
private String path; private String path;
public Long getId() { public String getId() {
return id.getValue(); return this.id;
} }
public void setId(Long id) { public void setId(String id) {
this.id.setValue(id); this.id = id;
} }
public String getDomainName() { public String getDomainName() {
@ -74,12 +74,12 @@ public class DomainResponse extends BaseResponse {
this.level = level; this.level = level;
} }
public Long getParentDomainId() { public String getParentDomainId() {
return parentDomainId.getValue(); return parentDomainId;
} }
public void setParentDomainId(Long parentDomainId) { public void setParentDomainId(String parentDomainId) {
this.parentDomainId.setValue(parentDomainId); this.parentDomainId = parentDomainId;
} }
public String getParentDomainName() { public String getParentDomainName() {

View File

@ -29,7 +29,7 @@ import org.apache.cloudstack.api.BaseResponse;
public class HostResponse extends BaseResponse { public class HostResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the host") @SerializedName(ApiConstants.ID) @Param(description="the ID of the host")
private IdentityProxy id = new IdentityProxy("host"); private String id;
@SerializedName(ApiConstants.NAME) @Param(description="the name of the host") @SerializedName(ApiConstants.NAME) @Param(description="the name of the host")
private String name; private String name;
@ -44,7 +44,7 @@ public class HostResponse extends BaseResponse {
private Host.Type hostType; private Host.Type hostType;
@SerializedName("oscategoryid") @Param(description="the OS category ID of the host") @SerializedName("oscategoryid") @Param(description="the OS category ID of the host")
private IdentityProxy osCategoryId = new IdentityProxy("guest_os_category"); private String osCategoryId;
@SerializedName("oscategoryname") @Param(description="the OS category name of the host") @SerializedName("oscategoryname") @Param(description="the OS category name of the host")
private String osCategoryName; private String osCategoryName;
@ -53,13 +53,13 @@ public class HostResponse extends BaseResponse {
private String ipAddress; private String ipAddress;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID of the host") @SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID of the host")
private IdentityProxy zoneId = new IdentityProxy("data_center"); private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the host") @SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the host")
private String zoneName; private String zoneName;
@SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID of the host") @SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID of the host")
private IdentityProxy podId = new IdentityProxy("host_pod_ref"); private String podId;
@SerializedName("podname") @Param(description="the Pod name of the host") @SerializedName("podname") @Param(description="the Pod name of the host")
private String podName; private String podName;
@ -119,7 +119,7 @@ public class HostResponse extends BaseResponse {
private Long managementServerId; private Long managementServerId;
@SerializedName("clusterid") @Param(description="the cluster ID of the host") @SerializedName("clusterid") @Param(description="the cluster ID of the host")
private IdentityProxy clusterId = new IdentityProxy("cluster"); private String clusterId;
@SerializedName("clustername") @Param(description="the cluster name of the host") @SerializedName("clustername") @Param(description="the cluster name of the host")
private String clusterName; private String clusterName;
@ -158,17 +158,12 @@ public class HostResponse extends BaseResponse {
private Boolean haHost; private Boolean haHost;
@Override public String getId() {
public Long getObjectId() { return id;
return getId();
} }
public Long getId() { public void setId(String id) {
return id.getValue(); this.id = id;
}
public void setId(Long id) {
this.id.setValue(id);
} }
public void setName(String name) { public void setName(String name) {
@ -187,8 +182,8 @@ public class HostResponse extends BaseResponse {
this.hostType = hostType; this.hostType = hostType;
} }
public void setOsCategoryId(Long osCategoryId) { public void setOsCategoryId(String osCategoryId) {
this.osCategoryId.setValue(osCategoryId); this.osCategoryId = osCategoryId;
} }
public void setOsCategoryName(String osCategoryName) { public void setOsCategoryName(String osCategoryName) {
@ -199,16 +194,16 @@ public class HostResponse extends BaseResponse {
this.ipAddress = ipAddress; this.ipAddress = ipAddress;
} }
public void setZoneId(Long zoneId) { public void setZoneId(String zoneId) {
this.zoneId.setValue(zoneId); this.zoneId = zoneId;
} }
public void setZoneName(String zoneName) { public void setZoneName(String zoneName) {
this.zoneName = zoneName; this.zoneName = zoneName;
} }
public void setPodId(Long podId) { public void setPodId(String podId) {
this.podId.setValue(podId); this.podId = podId;
} }
public void setPodName(String podName) { public void setPodName(String podName) {
@ -287,8 +282,8 @@ public class HostResponse extends BaseResponse {
this.managementServerId = managementServerId; this.managementServerId = managementServerId;
} }
public void setClusterId(Long clusterId) { public void setClusterId(String clusterId) {
this.clusterId.setValue(clusterId); this.clusterId = clusterId;
} }
public void setClusterName(String clusterName) { public void setClusterName(String clusterName) {
@ -348,22 +343,6 @@ public class HostResponse extends BaseResponse {
this.hypervisorVersion = hypervisorVersion; this.hypervisorVersion = hypervisorVersion;
} }
public void setOsCategoryId(IdentityProxy osCategoryId) {
this.osCategoryId = osCategoryId;
}
public void setZoneId(IdentityProxy zoneId) {
this.zoneId = zoneId;
}
public void setPodId(IdentityProxy podId) {
this.podId = podId;
}
public void setClusterId(IdentityProxy clusterId) {
this.clusterId = clusterId;
}
public void setHaHost(Boolean haHost) { public void setHaHost(Boolean haHost) {
this.haHost = haHost; this.haHost = haHost;
} }

View File

@ -22,7 +22,6 @@ import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.Entity; import org.apache.cloudstack.api.Entity;
import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter;
import com.cloud.utils.IdentityProxy;
import com.cloud.serializer.Param; import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ -30,7 +29,7 @@ import com.google.gson.annotations.SerializedName;
@Entity(value = DataCenter.class) @Entity(value = DataCenter.class)
public class ZoneResponse extends BaseResponse { public class ZoneResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="Zone id") @SerializedName(ApiConstants.ID) @Param(description="Zone id")
private IdentityProxy id = new IdentityProxy("data_center"); private String id;
@SerializedName(ApiConstants.NAME) @Param(description="Zone name") @SerializedName(ApiConstants.NAME) @Param(description="Zone name")
private String name; private String name;
@ -93,8 +92,8 @@ public class ZoneResponse extends BaseResponse {
@SerializedName(ApiConstants.LOCAL_STORAGE_ENABLED) @Param(description="true if local storage offering enabled, false otherwise") @SerializedName(ApiConstants.LOCAL_STORAGE_ENABLED) @Param(description="true if local storage offering enabled, false otherwise")
private boolean localStorageEnabled; private boolean localStorageEnabled;
public void setId(Long id) { public void setId(String id) {
this.id.setValue(id); this.id = id;
} }
public void setName(String name) { public void setName(String name) {

View File

@ -43,6 +43,12 @@ public class CheckOnHostCommandTest {
return 101L; return 101L;
}; };
@Override
public String getUuid() {
return "101";
}
public String getName() { public String getName() {
return "hostName"; return "hostName";
}; };

View File

@ -48,7 +48,7 @@ import com.cloud.utils.db.GenericDao;
@Table(name="host") @Table(name="host")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32) @DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
public class HostVO implements Host, Identity { public class HostVO implements Host {
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")

View File

@ -33,7 +33,7 @@ import com.cloud.utils.db.GenericDao;
@Entity @Entity
@Table(name="account") @Table(name="account")
public class AccountVO implements Account, Identity { public class AccountVO implements Account {
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")

View File

@ -259,14 +259,20 @@ public class ApiResponseHelper implements ResponseGenerator {
public AccountResponse createAccountResponse(Account account) { public AccountResponse createAccountResponse(Account account) {
boolean accountIsAdmin = (account.getType() == Account.ACCOUNT_TYPE_ADMIN); boolean accountIsAdmin = (account.getType() == Account.ACCOUNT_TYPE_ADMIN);
AccountResponse accountResponse = new AccountResponse(); AccountResponse accountResponse = new AccountResponse();
accountResponse.setId(account.getId()); accountResponse.setId(account.getUuid());
accountResponse.setName(account.getAccountName()); accountResponse.setName(account.getAccountName());
accountResponse.setAccountType(account.getType()); accountResponse.setAccountType(account.getType());
accountResponse.setDomainId(account.getDomainId()); Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
accountResponse.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName()); if (domain != null) {
accountResponse.setDomainId(domain.getUuid());
accountResponse.setDomainName(domain.getName());
}
accountResponse.setState(account.getState().toString()); accountResponse.setState(account.getState().toString());
accountResponse.setNetworkDomain(account.getNetworkDomain()); accountResponse.setNetworkDomain(account.getNetworkDomain());
accountResponse.setDefaultZone(account.getDefaultZoneId()); DataCenterVO dc = ApiDBUtils.findZoneById(account.getDefaultZoneId());
if (dc != null) {
accountResponse.setDefaultZone(dc.getUuid());
}
// get network stat // get network stat
List<UserStatisticsVO> stats = ApiDBUtils.listUserStatsBy(account.getId()); List<UserStatisticsVO> stats = ApiDBUtils.listUserStatsBy(account.getId());
@ -415,10 +421,10 @@ public class ApiResponseHelper implements ResponseGenerator {
public DomainResponse createDomainResponse(Domain domain) { public DomainResponse createDomainResponse(Domain domain) {
DomainResponse domainResponse = new DomainResponse(); DomainResponse domainResponse = new DomainResponse();
domainResponse.setDomainName(domain.getName()); domainResponse.setDomainName(domain.getName());
domainResponse.setId(domain.getId()); domainResponse.setId(domain.getUuid());
domainResponse.setLevel(domain.getLevel()); domainResponse.setLevel(domain.getLevel());
domainResponse.setNetworkDomain(domain.getNetworkDomain()); domainResponse.setNetworkDomain(domain.getNetworkDomain());
domainResponse.setParentDomainId(domain.getParent()); domainResponse.setParentDomainId(ApiDBUtils.findDomainById(domain.getParent()).getUuid());
StringBuilder domainPath = new StringBuilder("ROOT"); StringBuilder domainPath = new StringBuilder("ROOT");
(domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1); (domainPath.append(domain.getPath())).deleteCharAt(domainPath.length() - 1);
domainResponse.setPath(domainPath.toString()); domainResponse.setPath(domainPath.toString());
@ -583,18 +589,30 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override @Override
public HostResponse createHostResponse(Host host, EnumSet<HostDetails> details) { public HostResponse createHostResponse(Host host, EnumSet<HostDetails> details) {
HostResponse hostResponse = new HostResponse(); HostResponse hostResponse = new HostResponse();
hostResponse.setId(host.getId()); hostResponse.setId(host.getUuid());
hostResponse.setCapabilities(host.getCapabilities()); hostResponse.setCapabilities(host.getCapabilities());
hostResponse.setClusterId(host.getClusterId()); ClusterVO cluster = null;
if (host.getClusterId() != null) {
cluster = ApiDBUtils.findClusterById(host.getClusterId());
if (cluster != null) {
hostResponse.setClusterId(cluster.getUuid());
}
}
hostResponse.setCpuNumber(host.getCpus()); hostResponse.setCpuNumber(host.getCpus());
hostResponse.setZoneId(host.getDataCenterId()); DataCenterVO zone = ApiDBUtils.findZoneById(host.getDataCenterId());
if (zone != null) {
hostResponse.setZoneId(zone.getUuid());
}
hostResponse.setDisconnectedOn(host.getDisconnectedOn()); hostResponse.setDisconnectedOn(host.getDisconnectedOn());
hostResponse.setHypervisor(host.getHypervisorType()); hostResponse.setHypervisor(host.getHypervisorType());
hostResponse.setHostType(host.getType()); hostResponse.setHostType(host.getType());
hostResponse.setLastPinged(new Date(host.getLastPinged())); hostResponse.setLastPinged(new Date(host.getLastPinged()));
hostResponse.setManagementServerId(host.getManagementServerId()); hostResponse.setManagementServerId(host.getManagementServerId());
hostResponse.setName(host.getName()); hostResponse.setName(host.getName());
hostResponse.setPodId(host.getPodId()); HostPodVO pod = ApiDBUtils.findPodById(host.getPodId());
if (pod != null) {
hostResponse.setPodId(pod.getUuid());
}
hostResponse.setRemoved(host.getRemoved()); hostResponse.setRemoved(host.getRemoved());
hostResponse.setCpuSpeed(host.getSpeed()); hostResponse.setCpuSpeed(host.getSpeed());
hostResponse.setState(host.getStatus()); hostResponse.setState(host.getStatus());
@ -607,20 +625,18 @@ public class ApiResponseHelper implements ResponseGenerator {
GuestOSCategoryVO guestOSCategory = ApiDBUtils.getHostGuestOSCategory(host.getId()); GuestOSCategoryVO guestOSCategory = ApiDBUtils.getHostGuestOSCategory(host.getId());
if (guestOSCategory != null) { if (guestOSCategory != null) {
hostResponse.setOsCategoryId(guestOSCategory.getId()); hostResponse.setOsCategoryId(guestOSCategory.getUuid());
hostResponse.setOsCategoryName(guestOSCategory.getName()); hostResponse.setOsCategoryName(guestOSCategory.getName());
} }
hostResponse.setZoneName(ApiDBUtils.findZoneById(host.getDataCenterId()).getName()); if (zone != null) {
hostResponse.setZoneName(zone.getName());
if (host.getPodId() != null) {
HostPodVO pod = ApiDBUtils.findPodById(host.getPodId());
if (pod != null) {
hostResponse.setPodName(pod.getName());
}
} }
if (host.getClusterId() != null) { if (pod != null) {
ClusterVO cluster = ApiDBUtils.findClusterById(host.getClusterId()); hostResponse.setPodName(pod.getName());
}
if (cluster != null) {
hostResponse.setClusterName(cluster.getName()); hostResponse.setClusterName(cluster.getName());
hostResponse.setClusterType(cluster.getClusterType().toString()); hostResponse.setClusterType(cluster.getClusterType().toString());
} }
@ -935,7 +951,7 @@ public class ApiResponseHelper implements ResponseGenerator {
public ZoneResponse createZoneResponse(DataCenter dataCenter, Boolean showCapacities) { public ZoneResponse createZoneResponse(DataCenter dataCenter, Boolean showCapacities) {
Account account = UserContext.current().getCaller(); Account account = UserContext.current().getCaller();
ZoneResponse zoneResponse = new ZoneResponse(); ZoneResponse zoneResponse = new ZoneResponse();
zoneResponse.setId(dataCenter.getId()); zoneResponse.setId(dataCenter.getUuid());
zoneResponse.setName(dataCenter.getName()); zoneResponse.setName(dataCenter.getName());
zoneResponse.setSecurityGroupsEnabled(ApiDBUtils.isSecurityGroupEnabledInZone(dataCenter.getId())); zoneResponse.setSecurityGroupsEnabled(ApiDBUtils.isSecurityGroupEnabledInZone(dataCenter.getId()));
zoneResponse.setLocalStorageEnabled(dataCenter.isLocalStorageEnabled()); zoneResponse.setLocalStorageEnabled(dataCenter.isLocalStorageEnabled());
@ -1216,20 +1232,24 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override @Override
public ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapacities) { public ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapacities) {
ClusterResponse clusterResponse = new ClusterResponse(); ClusterResponse clusterResponse = new ClusterResponse();
clusterResponse.setId(cluster.getId()); clusterResponse.setId(cluster.getUuid());
clusterResponse.setName(cluster.getName()); clusterResponse.setName(cluster.getName());
clusterResponse.setPodId(cluster.getPodId()); HostPodVO pod = ApiDBUtils.findPodById(cluster.getPodId());
clusterResponse.setZoneId(cluster.getDataCenterId()); if (pod != null) {
clusterResponse.setPodId(pod.getUuid());
clusterResponse.setPodName(pod.getName());
}
DataCenterVO dc = ApiDBUtils.findZoneById(cluster.getDataCenterId());
if (dc != null) {
clusterResponse.setZoneId(dc.getUuid());
clusterResponse.setZoneName(dc.getName());
}
clusterResponse.setHypervisorType(cluster.getHypervisorType().toString()); clusterResponse.setHypervisorType(cluster.getHypervisorType().toString());
clusterResponse.setClusterType(cluster.getClusterType().toString()); clusterResponse.setClusterType(cluster.getClusterType().toString());
clusterResponse.setAllocationState(cluster.getAllocationState().toString()); clusterResponse.setAllocationState(cluster.getAllocationState().toString());
clusterResponse.setManagedState(cluster.getManagedState().toString()); clusterResponse.setManagedState(cluster.getManagedState().toString());
HostPodVO pod = ApiDBUtils.findPodById(cluster.getPodId());
if (pod != null) {
clusterResponse.setPodName(pod.getName());
}
DataCenterVO zone = ApiDBUtils.findZoneById(cluster.getDataCenterId());
clusterResponse.setZoneName(zone.getName());
if (showCapacities != null && showCapacities) { if (showCapacities != null && showCapacities) {
List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(null, null, cluster.getId()); List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(null, null, cluster.getId());
Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>(); Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>();
@ -2196,26 +2216,30 @@ public class ApiResponseHelper implements ResponseGenerator {
capacityResponse.setCapacityType(summedCapacity.getCapacityType()); capacityResponse.setCapacityType(summedCapacity.getCapacityType());
capacityResponse.setCapacityUsed(summedCapacity.getUsedCapacity()); capacityResponse.setCapacityUsed(summedCapacity.getUsedCapacity());
if (summedCapacity.getPodId() != null) { if (summedCapacity.getPodId() != null) {
capacityResponse.setPodId(summedCapacity.getPodId()); capacityResponse.setPodId(ApiDBUtils.findPodById(summedCapacity.getPodId()).getUuid());
HostPodVO pod = ApiDBUtils.findPodById(summedCapacity.getPodId()); HostPodVO pod = ApiDBUtils.findPodById(summedCapacity.getPodId());
if (pod != null) { if (pod != null) {
capacityResponse.setPodId(pod.getUuid());
capacityResponse.setPodName(pod.getName()); capacityResponse.setPodName(pod.getName());
} }
} }
if (summedCapacity.getClusterId() != null) { if (summedCapacity.getClusterId() != null) {
capacityResponse.setClusterId(summedCapacity.getClusterId());
ClusterVO cluster = ApiDBUtils.findClusterById(summedCapacity.getClusterId()); ClusterVO cluster = ApiDBUtils.findClusterById(summedCapacity.getClusterId());
if (cluster != null) { if (cluster != null) {
capacityResponse.setClusterId(cluster.getUuid());
capacityResponse.setClusterName(cluster.getName()); capacityResponse.setClusterName(cluster.getName());
if (summedCapacity.getPodId() == null) { if (summedCapacity.getPodId() == null) {
long podId = cluster.getPodId(); HostPodVO pod = ApiDBUtils.findPodById(cluster.getPodId());
capacityResponse.setPodId(podId); capacityResponse.setPodId(pod.getUuid());
capacityResponse.setPodName(ApiDBUtils.findPodById(podId).getName()); capacityResponse.setPodName(pod.getName());
} }
} }
} }
capacityResponse.setZoneId(summedCapacity.getDataCenterId()); DataCenterVO zone = ApiDBUtils.findZoneById(summedCapacity.getDataCenterId());
capacityResponse.setZoneName(ApiDBUtils.findZoneById(summedCapacity.getDataCenterId()).getName()); if (zone != null) {
capacityResponse.setZoneId(zone.getUuid());
capacityResponse.setZoneName(zone.getName());
}
if (summedCapacity.getUsedPercentage() != null){ if (summedCapacity.getUsedPercentage() != null){
capacityResponse.setPercentUsed(format.format(summedCapacity.getUsedPercentage() * 100f)); capacityResponse.setPercentUsed(format.format(summedCapacity.getUsedPercentage() * 100f));
} else if (summedCapacity.getTotalCapacity() != 0) { } else if (summedCapacity.getTotalCapacity() != 0) {

View File

@ -38,7 +38,7 @@ import com.cloud.utils.db.GenericDao;
@Entity @Entity
@Table(name="cluster") @Table(name="cluster")
public class ClusterVO implements Cluster, Identity { public class ClusterVO implements Cluster {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)

View File

@ -39,7 +39,7 @@ import com.cloud.utils.db.GenericDao;
@Entity @Entity
@Table(name="data_center") @Table(name="data_center")
public class DataCenterVO implements DataCenter, Identity { public class DataCenterVO implements DataCenter {
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)

View File

@ -33,7 +33,7 @@ import com.cloud.utils.db.GenericDao;
@Entity @Entity
@Table(name="domain") @Table(name="domain")
public class DomainVO implements Domain, Identity { public class DomainVO implements Domain {
public static final Logger s_logger = Logger.getLogger(DomainVO.class.getName()); public static final Logger s_logger = Logger.getLogger(DomainVO.class.getName());
@Id @Id