From 04a2b2d326c34e234e78852b28fa18a5f96fcc00 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 23 Apr 2013 16:32:19 -0700 Subject: [PATCH] CLOUDSTACK-2120: mixed zone management - extend listPods, listClusters, listHosts, listStoragePools, listSystemVms, listRouters API to return zone type. --- .../api/response/ClusterResponse.java | 9 +- .../api/response/DomainRouterResponse.java | 11 + .../cloudstack/api/response/HostResponse.java | 9 +- .../cloudstack/api/response/PodResponse.java | 9 +- .../api/response/StoragePoolResponse.java | 15 +- .../api/response/SystemVmResponse.java | 11 + .../src/com/cloud/api/ApiResponseHelper.java | 3 + .../query/dao/DomainRouterJoinDaoImpl.java | 1 + .../cloud/api/query/dao/HostJoinDaoImpl.java | 1 + .../api/query/dao/StoragePoolJoinDaoImpl.java | 1 + .../api/query/vo/DomainRouterJoinVO.java | 12 + .../com/cloud/api/query/vo/HostJoinVO.java | 11 + .../cloud/api/query/vo/StoragePoolJoinVO.java | 11 + setup/db/db/schema-410to420.sql | 230 +++++++++++++++++- 14 files changed, 328 insertions(+), 6 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/response/ClusterResponse.java b/api/src/org/apache/cloudstack/api/response/ClusterResponse.java index a90acde6145..cfd772d7115 100644 --- a/api/src/org/apache/cloudstack/api/response/ClusterResponse.java +++ b/api/src/org/apache/cloudstack/api/response/ClusterResponse.java @@ -46,7 +46,10 @@ public class ClusterResponse extends BaseResponse { @SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the cluster") private String zoneName; - + + @SerializedName(ApiConstants.ZONE_TYPE) @Param(description = "network type of the availability zone") + private String zoneType; + @SerializedName("hypervisortype") @Param(description="the hypervisor type of the cluster") private String hypervisorType; @@ -116,6 +119,10 @@ public class ClusterResponse extends BaseResponse { this.zoneName = zoneName; } + public void setZoneType(String zoneType) { + this.zoneType = zoneType; + } + public String getClusterType() { return clusterType; } diff --git a/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java b/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java index b2bc02e9b83..79c8596a8d1 100644 --- a/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java +++ b/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java @@ -42,6 +42,9 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView @SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name for the router") private String zoneName; + @SerializedName(ApiConstants.ZONE_TYPE) @Param(description = "network type of the availability zone") + private String zoneType; + @SerializedName(ApiConstants.DNS1) @Param(description="the first DNS for the router") private String dns1; @@ -186,6 +189,14 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView this.zoneName = zoneName; } + public String getZoneType() { + return zoneType; + } + + public void setZoneType(String zoneType) { + this.zoneType = zoneType; + } + public void setDns1(String dns1) { this.dns1 = dns1; } diff --git a/api/src/org/apache/cloudstack/api/response/HostResponse.java b/api/src/org/apache/cloudstack/api/response/HostResponse.java index 687687d37fc..be1a4b443be 100644 --- a/api/src/org/apache/cloudstack/api/response/HostResponse.java +++ b/api/src/org/apache/cloudstack/api/response/HostResponse.java @@ -59,7 +59,10 @@ public class HostResponse extends BaseResponse { @SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the host") private String zoneName; - + + @SerializedName(ApiConstants.ZONE_TYPE) @Param(description = "network type of the availability zone") + private String zoneType; + @SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID of the host") private String podId; @@ -209,6 +212,10 @@ public class HostResponse extends BaseResponse { this.zoneName = zoneName; } + public void setZoneType(String zoneType) { + this.zoneType = zoneType; + } + public void setPodId(String podId) { this.podId = podId; } diff --git a/api/src/org/apache/cloudstack/api/response/PodResponse.java b/api/src/org/apache/cloudstack/api/response/PodResponse.java index f31c289217e..471cac1aa47 100644 --- a/api/src/org/apache/cloudstack/api/response/PodResponse.java +++ b/api/src/org/apache/cloudstack/api/response/PodResponse.java @@ -36,10 +36,13 @@ public class PodResponse extends BaseResponse { @SerializedName("zoneid") @Param(description="the Zone ID of the Pod") private String zoneId; - + @SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the Pod") private String zoneName; + @SerializedName(ApiConstants.ZONE_TYPE) @Param(description = "network type of the availability zone") + private String zoneType; + @SerializedName("gateway") @Param(description="the gateway of the Pod") private String gateway; @@ -86,6 +89,10 @@ public class PodResponse extends BaseResponse { return zoneName; } + public void setZoneType(String zoneType) { + this.zoneType = zoneType; + } + public void setZoneName(String zoneName) { this.zoneName = zoneName; } diff --git a/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java b/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java index e034b17e8ea..4411ddcb112 100644 --- a/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java +++ b/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java @@ -38,12 +38,15 @@ public class StoragePoolResponse extends BaseResponse { @SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the storage pool") private String zoneName; + @SerializedName(ApiConstants.ZONE_TYPE) @Param(description = "network type of the availability zone") + private String zoneType; + @SerializedName("podid") @Param(description="the Pod ID of the storage pool") private String podId; @SerializedName("podname") @Param(description="the Pod name of the storage pool") - private String podName; - + private String podName; + @SerializedName("name") @Param(description="the name of the storage pool") private String name; @@ -126,6 +129,14 @@ public class StoragePoolResponse extends BaseResponse { this.zoneName = zoneName; } + public String getZoneType() { + return zoneType; + } + + public void setZoneType(String zoneType) { + this.zoneType = zoneType; + } + public String getPodId() { return podId; } diff --git a/api/src/org/apache/cloudstack/api/response/SystemVmResponse.java b/api/src/org/apache/cloudstack/api/response/SystemVmResponse.java index 8d2798a9d04..3439dc025e3 100644 --- a/api/src/org/apache/cloudstack/api/response/SystemVmResponse.java +++ b/api/src/org/apache/cloudstack/api/response/SystemVmResponse.java @@ -46,6 +46,9 @@ public class SystemVmResponse extends BaseResponse { @SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name for the system VM") private String zoneName; + @SerializedName(ApiConstants.ZONE_TYPE) @Param(description = "network type of the availability zone") + private String zoneType; + @SerializedName("dns1") @Param(description="the first DNS for the system VM") private String dns1; @@ -150,7 +153,15 @@ public class SystemVmResponse extends BaseResponse { public void setZoneName(String zoneName) { this.zoneName = zoneName; } + + public String getZoneType() { + return zoneType; + } + public void setZoneType(String zoneType) { + this.zoneType = zoneType; + } + public String getDns1() { return dns1; } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index ba5322f0938..cd0158d074e 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -817,6 +817,7 @@ public class ApiResponseHelper implements ResponseGenerator { if (zone != null) { podResponse.setZoneId(zone.getUuid()); podResponse.setZoneName(zone.getName()); + podResponse.setZoneType(zone.getNetworkType().toString()); } podResponse.setNetmask(NetUtils.getCidrNetmask(pod.getCidrSize())); podResponse.setStartIp(ipRange[0]); @@ -961,6 +962,7 @@ public class ApiResponseHelper implements ResponseGenerator { if (dc != null) { clusterResponse.setZoneId(dc.getUuid()); clusterResponse.setZoneName(dc.getName()); + clusterResponse.setZoneType(dc.getNetworkType().toString()); } clusterResponse.setHypervisorType(cluster.getHypervisorType().toString()); clusterResponse.setClusterType(cluster.getClusterType().toString()); @@ -1165,6 +1167,7 @@ public class ApiResponseHelper implements ResponseGenerator { if (zone != null) { vmResponse.setZoneId(zone.getUuid()); vmResponse.setZoneName(zone.getName()); + vmResponse.setZoneType(zone.getNetworkType().toString()); vmResponse.setDns1(zone.getDns1()); vmResponse.setDns2(zone.getDns2()); } diff --git a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java index 488c4e494e1..25cd62faf7b 100644 --- a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java @@ -148,6 +148,7 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase implements hostResponse.setOsCategoryId(host.getOsCategoryUuid()); hostResponse.setOsCategoryName(host.getOsCategoryName()); hostResponse.setZoneName(host.getZoneName()); + hostResponse.setZoneType(host.getZoneType().toString()); hostResponse.setPodName(host.getPodName()); if ( host.getClusterId() > 0) { hostResponse.setClusterName(host.getClusterName()); diff --git a/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java index 34b88baa897..260ff4d18e3 100644 --- a/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java @@ -77,6 +77,7 @@ public class StoragePoolJoinDaoImpl extends GenericDaoBase