From ecbb1030163dfc5f2ce16bcb01dc60f1141f6f18 Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Fri, 22 Oct 2010 14:07:19 -0700 Subject: [PATCH] bug 6675: return snapshotId as part of the createVolume response if a non-null snapshotId was passed in. This will represent the snapshot from which the volume was created. status 6675: resolved fixed --- .../src/com/cloud/api/commands/CreateVolumeCmd.java | 3 +++ server/src/com/cloud/api/response/VolumeResponse.java | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/server/src/com/cloud/api/commands/CreateVolumeCmd.java b/server/src/com/cloud/api/commands/CreateVolumeCmd.java index 31ec30f5c70..4cfb29a6139 100644 --- a/server/src/com/cloud/api/commands/CreateVolumeCmd.java +++ b/server/src/com/cloud/api/commands/CreateVolumeCmd.java @@ -163,6 +163,9 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd { if (volume.getPoolId() != null) { response.setStoragePoolName(ApiDBUtils.findStoragePoolById(volume.getPoolId()).getName()); } + + // if the volume was created from a snapshot, snapshotId will be set so we pass it back in the response + response.setSnapshotId(getSnapshotId()); response.setZoneId(volume.getDataCenterId()); response.setZoneName(ApiDBUtils.findZoneById(volume.getDataCenterId()).getName()); diff --git a/server/src/com/cloud/api/response/VolumeResponse.java b/server/src/com/cloud/api/response/VolumeResponse.java index 8a2099d380f..8d5b643da63 100644 --- a/server/src/com/cloud/api/response/VolumeResponse.java +++ b/server/src/com/cloud/api/response/VolumeResponse.java @@ -101,6 +101,9 @@ public class VolumeResponse extends BaseResponse { @SerializedName("storage") @Param(description="name of the primary storage hosting the disk volume") private String storagePoolName; + @SerializedName("snapshotid") @Param(description="ID of the snapshot from which this volume was created") + private Long snapshotId; + public Long getId() { return id; } @@ -308,4 +311,12 @@ public class VolumeResponse extends BaseResponse { public void setStoragePoolName(String storagePoolName) { this.storagePoolName = storagePoolName; } + + public Long getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(Long snapshotId) { + this.snapshotId = snapshotId; + } }