CLOUDSTACK-924 :
   Volumes created from snapshots misses the source template information.Fixed 
the issue with volumes now getting the template id.
        Signed Off by : - Nitin Mehta <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/75261eb3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/75261eb3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/75261eb3

Branch: refs/heads/ui-multiple-vlan-ranges
Commit: 75261eb317a763114a6054664f4adf3f7a2c2709
Parents: cccdbe6
Author: Saksham Srivastava <[email protected]>
Authored: Mon Mar 11 16:38:02 2013 +0530
Committer: Nitin Mehta <[email protected]>
Committed: Mon Mar 11 16:40:12 2013 +0530

----------------------------------------------------------------------
 .../src/com/cloud/storage/VolumeManagerImpl.java   |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/75261eb3/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java 
b/server/src/com/cloud/storage/VolumeManagerImpl.java
index f0e6028..4951975 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -813,6 +813,8 @@ public class VolumeManagerImpl extends ManagerBase 
implements VolumeManager {
         Long diskOfferingId = null;
         DiskOfferingVO diskOffering = null;
         Long size = null;
+        // Volume VO used for extracting the source template id
+        VolumeVO parentVolume = null;
 
         // validate input parameters before creating the volume
         if ((cmd.getSnapshotId() == null && cmd.getDiskOfferingId() == null)
@@ -891,6 +893,7 @@ public class VolumeManagerImpl extends ManagerBase 
implements VolumeManager {
                         + snapshotId + " is not in " + Snapshot.State.BackedUp
                         + " state yet and can't be used for volume creation");
             }
+            parentVolume = 
_volsDao.findByIdIncludingRemoved(snapshotCheck.getVolumeId());
 
             diskOfferingId = snapshotCheck.getDiskOfferingId();
             diskOffering = _diskOfferingDao.findById(diskOfferingId);
@@ -947,6 +950,11 @@ public class VolumeManagerImpl extends ManagerBase 
implements VolumeManager {
         volume.setUpdated(new Date());
         volume.setDomainId((caller == null) ? Domain.ROOT_DOMAIN : caller
                 .getDomainId());
+        if (parentVolume != null) {
+            volume.setTemplateId(parentVolume.getTemplateId());
+        }  else {
+            volume.setTemplateId(null);
+        }
 
         volume = _volsDao.persist(volume);
         if (cmd.getSnapshotId() == null) {

Reply via email to