From 15e2bc463f05ff8b77f6b6a79bbcb391216778d8 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 23 Apr 2013 14:03:35 -0700 Subject: [PATCH] CLOUDSTACK-2120: mixed zone management - extend listSnapshots API to return zone type. --- .../api/response/SnapshotResponse.java | 16 ++++++++++++++++ server/src/com/cloud/api/ApiResponseHelper.java | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java b/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java index 5b77fb2f360..7484ac965fd 100644 --- a/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java +++ b/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java @@ -93,6 +93,14 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe @Param(description = "the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage") private Snapshot.State state; + @SerializedName(ApiConstants.ZONE_NAME) + @Param(description = "name of the availability zone") + private String zoneName; + + @SerializedName(ApiConstants.ZONE_TYPE) + @Param(description = "network type of the availability zone") + private String zoneType; + @SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with snapshot", responseObject = ResourceTagResponse.class) private List tags; @@ -173,6 +181,14 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe this.projectName = projectName; } + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public void setZoneType(String zoneType) { + this.zoneType = zoneType; + } + public void setTags(List tags) { this.tags = tags; } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index f4567c0a236..ba5322f0938 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -443,6 +443,12 @@ public class ApiResponseHelper implements ResponseGenerator { snapshotResponse.setVolumeId(volume.getUuid()); snapshotResponse.setVolumeName(volume.getName()); snapshotResponse.setVolumeType(volume.getVolumeType().name()); + + DataCenter zone = ApiDBUtils.findZoneById(volume.getDataCenterId()); + if (zone != null) { + snapshotResponse.setZoneName(zone.getName()); + snapshotResponse.setZoneType(zone.getNetworkType().toString()); + } } snapshotResponse.setCreated(snapshot.getCreated()); snapshotResponse.setName(snapshot.getName());