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();
String getUuid();
String getDns1();
String getDns2();

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,6 @@ import org.apache.cloudstack.api.Entity;
import com.cloud.domain.Domain;
import com.cloud.serializer.Param;
import com.cloud.user.Account;
import com.cloud.utils.IdentityProxy;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse;
@ -33,7 +32,7 @@ import org.apache.cloudstack.api.BaseResponse;
@Entity(value = Account.class)
public class AccountResponse extends BaseResponse {
@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")
private String name;
@ -42,13 +41,13 @@ public class AccountResponse extends BaseResponse {
private Short accountType;
@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")
private String domainName;
@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")
private Long bytesReceived;
@ -150,8 +149,8 @@ public class AccountResponse extends BaseResponse {
@SerializedName(ApiConstants.ACCOUNT_DETAILS) @Param(description="details for the account")
private Map<String, String> details;
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
@ -162,8 +161,8 @@ public class AccountResponse extends BaseResponse {
this.accountType = accountType;
}
public void setDomainId(Long domainId) {
this.domainId.setValue(domainId);
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public void setDomainName(String domainName) {
@ -290,7 +289,7 @@ public class AccountResponse extends BaseResponse {
this.networkAvailable = networkAvailable;
}
public void setDefaultZone(Long defaultZoneId) {
this.defaultZoneId.setValue(defaultZoneId);
public void setDefaultZone(String defaultZoneId) {
this.defaultZoneId = defaultZoneId;
}
}

View File

@ -27,19 +27,19 @@ public class CapacityResponse extends BaseResponse {
private Short capacityType;
@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")
private String zoneName;
@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")
private String podName;
@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")
private String clusterName;
@ -61,12 +61,12 @@ public class CapacityResponse extends BaseResponse {
this.capacityType = capacityType;
}
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 getZoneName() {
@ -77,12 +77,12 @@ public class CapacityResponse extends BaseResponse {
this.zoneName = zoneName;
}
public Long getPodId() {
return podId.getValue();
public String getPodId() {
return podId;
}
public void setPodId(Long podId) {
this.podId.setValue(podId);
public void setPodId(String podId) {
this.podId = podId;
}
public String getPodName() {
@ -93,12 +93,12 @@ public class CapacityResponse extends BaseResponse {
this.podName = podName;
}
public Long getClusterId() {
return clusterId.getValue();
public String getClusterId() {
return clusterId;
}
public void setClusterId(Long clusterId) {
this.clusterId.setValue(clusterId);
public void setClusterId(String clusterId) {
this.clusterId = clusterId;
}
public String getClusterName() {

View File

@ -32,19 +32,19 @@ import org.apache.cloudstack.api.BaseResponse;
@Entity(value = Cluster.class)
public class ClusterResponse extends BaseResponse {
@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")
private String name;
@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")
private String podName;
@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")
private String zoneName;
@ -64,12 +64,12 @@ public class ClusterResponse extends BaseResponse {
@SerializedName("capacity") @Param(description="the capacity of the Cluster", responseObject = CapacityResponse.class)
private List<CapacityResponse> capacitites;
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 String getName() {
@ -80,12 +80,12 @@ public class ClusterResponse extends BaseResponse {
this.name = name;
}
public Long getPodId() {
return podId.getValue();
public String getPodId() {
return podId;
}
public void setPodId(Long podId) {
this.podId.setValue(podId);
public void setPodId(String podId) {
this.podId = podId;
}
public String getPodName() {
@ -96,12 +96,12 @@ public class ClusterResponse extends BaseResponse {
this.podName = podName;
}
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 getZoneName() {

View File

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

View File

@ -29,7 +29,7 @@ import org.apache.cloudstack.api.BaseResponse;
public class HostResponse extends BaseResponse {
@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")
private String name;
@ -44,7 +44,7 @@ public class HostResponse extends BaseResponse {
private Host.Type hostType;
@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")
private String osCategoryName;
@ -53,13 +53,13 @@ public class HostResponse extends BaseResponse {
private String ipAddress;
@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")
private String zoneName;
@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")
private String podName;
@ -119,7 +119,7 @@ public class HostResponse extends BaseResponse {
private Long managementServerId;
@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")
private String clusterName;
@ -158,17 +158,12 @@ public class HostResponse extends BaseResponse {
private Boolean haHost;
@Override
public Long getObjectId() {
return getId();
public String getId() {
return id;
}
public Long getId() {
return id.getValue();
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
@ -187,8 +182,8 @@ public class HostResponse extends BaseResponse {
this.hostType = hostType;
}
public void setOsCategoryId(Long osCategoryId) {
this.osCategoryId.setValue(osCategoryId);
public void setOsCategoryId(String osCategoryId) {
this.osCategoryId = osCategoryId;
}
public void setOsCategoryName(String osCategoryName) {
@ -199,16 +194,16 @@ public class HostResponse extends BaseResponse {
this.ipAddress = ipAddress;
}
public void setZoneId(Long zoneId) {
this.zoneId.setValue(zoneId);
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public void setPodId(Long podId) {
this.podId.setValue(podId);
public void setPodId(String podId) {
this.podId = podId;
}
public void setPodName(String podName) {
@ -287,8 +282,8 @@ public class HostResponse extends BaseResponse {
this.managementServerId = managementServerId;
}
public void setClusterId(Long clusterId) {
this.clusterId.setValue(clusterId);
public void setClusterId(String clusterId) {
this.clusterId = clusterId;
}
public void setClusterName(String clusterName) {
@ -348,22 +343,6 @@ public class HostResponse extends BaseResponse {
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) {
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.Entity;
import com.cloud.dc.DataCenter;
import com.cloud.utils.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@ -30,7 +29,7 @@ import com.google.gson.annotations.SerializedName;
@Entity(value = DataCenter.class)
public class ZoneResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="Zone id")
private IdentityProxy id = new IdentityProxy("data_center");
private String id;
@SerializedName(ApiConstants.NAME) @Param(description="Zone 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")
private boolean localStorageEnabled;
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setName(String name) {

View File

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

View File

@ -48,7 +48,7 @@ import com.cloud.utils.db.GenericDao;
@Table(name="host")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
public class HostVO implements Host, Identity {
public class HostVO implements Host {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
@ -128,20 +128,20 @@ public class HostVO implements Host, Identity {
@Column(name="setup")
private boolean setup = false;
@Column(name="resource_state", nullable=false)
@Enumerated(value=EnumType.STRING)
private ResourceState resourceState;
@Column(name="hypervisor_version")
private String hypervisorVersion;
@Column(name="update_count", updatable = true, nullable=false)
protected long updated; // This field should be updated everytime the state is updated. There's no set method in the vo object because it is done with in the dao code.
@Column(name="uuid")
private String uuid;
// This is a delayed load value. If the value is null,
// then this field has not been loaded yet.
// Call host dao to load it.
@ -695,36 +695,36 @@ public class HostVO implements Host, Identity {
public Status getState() {
return status;
}
@Override
public ResourceState getResourceState() {
return resourceState;
}
public void setResourceState(ResourceState state) {
resourceState = state;
}
@Override
public boolean isInMaintenanceStates() {
return (getResourceState() == ResourceState.Maintenance || getResourceState() == ResourceState.ErrorInMaintenance
|| getResourceState() == ResourceState.PrepareForMaintenance);
}
public long getUpdated() {
return updated;
}
public long incrUpdated() {
updated++;
return updated;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}

View File

@ -33,7 +33,7 @@ import com.cloud.utils.db.GenericDao;
@Entity
@Table(name="account")
public class AccountVO implements Account, Identity {
public class AccountVO implements Account {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
@ -54,28 +54,28 @@ public class AccountVO implements Account, Identity {
@Column(name=GenericDao.REMOVED_COLUMN)
private Date removed;
@Column(name="cleanup_needed")
private boolean needsCleanup = false;
@Column(name="network_domain")
private String networkDomain;
@Column(name="uuid")
private String uuid;
@Column(name="default_zone_id")
private Long defaultZoneId = null;
public AccountVO() {
this.uuid = UUID.randomUUID().toString();
}
public AccountVO(long id) {
this.id = id;
this.uuid = UUID.randomUUID().toString();
}
public AccountVO(String accountName, long domainId, String networkDomain, short type) {
this.accountName = accountName;
this.domainId = domainId;
@ -84,11 +84,11 @@ public class AccountVO implements Account, Identity {
this.state = State.enabled;
this.uuid = UUID.randomUUID().toString();
}
public void setNeedsCleanup(boolean value) {
needsCleanup = value;
}
public boolean getNeedsCleanup() {
return needsCleanup;
}
@ -102,16 +102,16 @@ public class AccountVO implements Account, Identity {
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
@Override
public short getType() {
return type;
}
public void setType(short type) {
this.type = type;
}
@ -120,16 +120,16 @@ public class AccountVO implements Account, Identity {
public long getDomainId() {
return domainId;
}
public void setDomainId(long domainId) {
this.domainId = domainId;
}
@Override
public Long getDefaultZoneId() {
return defaultZoneId;
}
public void setDefaultZoneId(Long defaultZoneId) {
this.defaultZoneId = defaultZoneId;
}
@ -138,7 +138,7 @@ public class AccountVO implements Account, Identity {
public State getState() {
return state;
}
public void setState(State state) {
this.state = state;
}
@ -147,31 +147,31 @@ public class AccountVO implements Account, Identity {
public Date getRemoved() {
return removed;
}
@Override
public long getAccountId() {
return id;
}
@Override
public String toString() {
return new StringBuilder("Acct[").append(id).append("-").append(accountName).append("]").toString();
}
@Override
public String getNetworkDomain() {
return networkDomain;
}
public void setNetworkDomain(String networkDomain) {
this.networkDomain = networkDomain;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}

View File

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

View File

@ -38,53 +38,53 @@ import com.cloud.utils.db.GenericDao;
@Entity
@Table(name="cluster")
public class ClusterVO implements Cluster, Identity {
public class ClusterVO implements Cluster {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
long id;
@Column(name="name")
String name;
@Column(name="guid")
String guid;
@Column(name="data_center_id")
long dataCenterId;
@Column(name="pod_id")
long podId;
@Column(name="hypervisor_type")
String hypervisorType;
@Column(name="cluster_type")
@Enumerated(value=EnumType.STRING)
Cluster.ClusterType clusterType;
@Column(name="allocation_state")
@Enumerated(value=EnumType.STRING)
AllocationState allocationState;
@Column(name="managed_state")
@Enumerated(value=EnumType.STRING)
ManagedState managedState;
@Column(name=GenericDao.REMOVED_COLUMN)
private Date removed;
@Column(name="uuid")
String uuid;
public ClusterVO() {
clusterType = Cluster.ClusterType.CloudManaged;
allocationState = Grouping.AllocationState.Enabled;
this.uuid = UUID.randomUUID().toString();
}
public ClusterVO(long dataCenterId, long podId, String name) {
this.dataCenterId = dataCenterId;
this.podId = podId;
@ -110,23 +110,23 @@ public class ClusterVO implements Cluster, Identity {
public long getPodId() {
return podId;
}
public Cluster.ClusterType getClusterType() {
return clusterType;
}
public void setClusterType(Cluster.ClusterType clusterType) {
this.clusterType = clusterType;
}
public AllocationState getAllocationState() {
return allocationState;
}
public void setAllocationState(AllocationState allocationState) {
this.allocationState = allocationState;
}
public ManagedState getManagedState() {
return managedState;
}
@ -143,7 +143,7 @@ public class ClusterVO implements Cluster, Identity {
public int hashCode() {
return NumbersUtil.hash(id);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ClusterVO)) {
@ -152,7 +152,7 @@ public class ClusterVO implements Cluster, Identity {
ClusterVO that = (ClusterVO)obj;
return this.id == that.id;
}
public HypervisorType getHypervisorType() {
return HypervisorType.getType(hypervisorType);
}
@ -160,11 +160,11 @@ public class ClusterVO implements Cluster, Identity {
public void setHypervisorType(String hy) {
hypervisorType = hy;
}
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
@ -176,12 +176,12 @@ public class ClusterVO implements Cluster, Identity {
public void setName(String name) {
this.name = name;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}

View File

@ -5,7 +5,7 @@
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
@ -39,91 +39,91 @@ import com.cloud.utils.db.GenericDao;
@Entity
@Table(name="data_center")
public class DataCenterVO implements DataCenter, Identity {
public class DataCenterVO implements DataCenter {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private long id;
@Column(name="name")
private String name = null;
@Column(name="description")
private String description = null;
@Column(name="dns1")
private String dns1 = null;
@Column(name="dns2")
private String dns2 = null;
@Column(name="internal_dns1")
private String internalDns1 = null;
@Column(name="internal_dns2")
private String internalDns2 = null;
@Column(name="router_mac_address", updatable = false, nullable=false)
private String routerMacAddress = "02:00:00:00:00:01";
@Column(name="guest_network_cidr")
private String guestNetworkCidr = null;
@Column(name="domain_id")
private Long domainId = null;
@Column(name="domain")
private String domain;
@Column(name="networktype")
@Enumerated(EnumType.STRING)
@Enumerated(EnumType.STRING)
NetworkType networkType;
@Column(name="dns_provider")
private String dnsProvider;
@Column(name="dhcp_provider")
private String dhcpProvider;
@Column(name="gateway_provider")
private String gatewayProvider;
@Column(name="vpn_provider")
private String vpnProvider;
@Column(name="userdata_provider")
private String userDataProvider;
@Column(name="lb_provider")
private String loadBalancerProvider;
@Column(name="firewall_provider")
private String firewallProvider;
@Column(name="mac_address", nullable=false)
@TableGenerator(name="mac_address_sq", table="data_center", pkColumnName="id", valueColumnName="mac_address", allocationSize=1)
private long macAddress = 1;
@Column(name="zone_token")
private String zoneToken;
private String zoneToken;
@Column(name=GenericDao.REMOVED_COLUMN)
private Date removed;
// This is a delayed load value. If the value is null,
// then this field has not been loaded yet.
// Call the dao to load it.
@Transient
Map<String, String> details;
@Column(name="allocation_state")
@Enumerated(value=EnumType.STRING)
AllocationState allocationState;
@Column(name="uuid")
private String uuid;
private String uuid;
@Column(name="is_security_group_enabled")
boolean securityGroupEnabled;
@ -168,13 +168,13 @@ public class DataCenterVO implements DataCenter, Identity {
@Override
public String getFirewallProvider() {
return firewallProvider;
return firewallProvider;
}
public void setFirewallProvider(String firewallProvider) {
this.firewallProvider = firewallProvider;
}
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false);
this.id = id;
@ -216,7 +216,7 @@ public class DataCenterVO implements DataCenter, Identity {
this.domain = domainSuffix;
this.uuid = UUID.randomUUID().toString();
}
@Override
public String getVpnProvider() {
return vpnProvider;
@ -234,13 +234,13 @@ public class DataCenterVO implements DataCenter, Identity {
public void setUserDataProvider(String userDataProvider) {
this.userDataProvider = userDataProvider;
}
@Override
public String getGuestNetworkCidr()
{
return guestNetworkCidr;
}
public void setGuestNetworkCidr(String guestNetworkCidr)
{
this.guestNetworkCidr = guestNetworkCidr;
@ -254,7 +254,7 @@ public class DataCenterVO implements DataCenter, Identity {
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
@Override
public String getDescription() {
return description;
@ -263,12 +263,12 @@ public class DataCenterVO implements DataCenter, Identity {
public String getRouterMacAddress() {
return routerMacAddress;
}
@Override
public String getDns1() {
return dns1;
}
@Override
public String getDns2() {
return dns2;
@ -291,28 +291,28 @@ public class DataCenterVO implements DataCenter, Identity {
public long getId() {
return id;
}
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setDns1(String dns1) {
this.dns1 = dns1;
}
public void setDns2(String dns2) {
this.dns2 = dns2;
}
public void setInternalDns1(String dns3) {
this.internalDns1 = dns3;
}
public void setInternalDns2(String dns4) {
this.internalDns2 = dns4;
}
@ -320,7 +320,7 @@ public class DataCenterVO implements DataCenter, Identity {
public void setRouterMacAddress(String routerMacAddress) {
this.routerMacAddress = routerMacAddress;
}
@Override
public String getDomain() {
return domain;
@ -329,7 +329,7 @@ public class DataCenterVO implements DataCenter, Identity {
public void setDomain(String domain) {
this.domain = domain;
}
public void setNetworkType(NetworkType zoneNetworkType) {
this.networkType = zoneNetworkType;
}
@ -338,12 +338,12 @@ public class DataCenterVO implements DataCenter, Identity {
public NetworkType getNetworkType() {
return networkType;
}
@Override
@Override
public boolean isSecurityGroupEnabled() {
return securityGroupEnabled;
}
public void setSecurityGroupEnabled(boolean enabled) {
this.securityGroupEnabled = enabled;
}
@ -364,34 +364,34 @@ public class DataCenterVO implements DataCenter, Identity {
@Override
public void setDetails(Map<String, String> details2) {
details = details2;
details = details2;
}
public String getDetail(String name) {
assert (details != null) : "Did you forget to load the details?";
return details != null ? details.get(name) : null;
}
public void setDetail(String name, String value) {
assert (details != null) : "Did you forget to load the details?";
details.put(name, value);
}
public AllocationState getAllocationState() {
return allocationState;
}
public void setAllocationState(AllocationState allocationState) {
this.allocationState = allocationState;
}
@Override
public int hashCode() {
return NumbersUtil.hash(id);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof DataCenterVO)) {
@ -405,20 +405,20 @@ public class DataCenterVO implements DataCenter, Identity {
public String getZoneToken() {
return zoneToken;
}
public void setZoneToken(String zoneToken) {
this.zoneToken = zoneToken;
}
public Date getRemoved() {
return removed;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}

View File

@ -33,9 +33,9 @@ import com.cloud.utils.db.GenericDao;
@Entity
@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());
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
@ -49,10 +49,10 @@ public class DomainVO implements Domain, Identity {
@Column(name="owner")
private long accountId;
@Column(name="path")
private String path = null;
@Column(name="level")
private int level;
@ -64,18 +64,18 @@ public class DomainVO implements Domain, Identity {
@Column(name="next_child_seq")
private long nextChildSeq = 1L;
@Column(name="state")
private Domain.State state;
@Column(name="network_domain")
private String networkDomain;
@Column(name="uuid")
private String uuid;
public DomainVO() {}
public DomainVO(long id, String name, long owner, Long parentId, String networkDomain) {
this(name, owner, parentId, networkDomain);
this.id = id;
@ -102,7 +102,7 @@ public class DomainVO implements Domain, Identity {
public Long getParent() {
return parent;
}
@Override
public void setParent(Long parent) {
if(parent == null) {
@ -119,7 +119,7 @@ public class DomainVO implements Domain, Identity {
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
@ -129,59 +129,59 @@ public class DomainVO implements Domain, Identity {
public long getAccountId() {
return accountId;
}
@Override
public Date getRemoved() {
return removed;
}
@Override
public String getPath() {
return path;
}
@Override
public void setPath(String path) {
this.path = path;
}
@Override
public int getLevel() {
return level;
return level;
}
public void setLevel(int level) {
this.level = level;
}
@Override
public int getChildCount() {
return childCount;
return childCount;
}
public void setChildCount(int count) {
childCount = count;
}
@Override
public long getNextChildSeq() {
return nextChildSeq;
}
public void setNextChildSeq(long seq) {
nextChildSeq = seq;
}
@Override
@Override
public Domain.State getState() {
return state;
}
@Override
public void setState(Domain.State state) {
this.state = state;
}
@Override
public String toString() {
return new StringBuilder("Domain:").append(id).append(path).toString();
@ -195,12 +195,12 @@ public class DomainVO implements Domain, Identity {
public void setNetworkDomain(String domainSuffix) {
this.networkDomain = domainSuffix;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}