cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject git commit: updated refs/heads/master to b344bb4
Date Fri, 11 Oct 2013 23:18:00 GMT
Updated Branches:
  refs/heads/master 47dd1c1e9 -> b344bb4cf


KVM: Change new volume/template downloads to use UUID in database
rather than creating a fresh random UUID, so admins can match
volumes frontend to backend


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

Branch: refs/heads/master
Commit: b344bb4cf3a697a1614044812a07a8f7561140c2
Parents: 47dd1c1
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Fri Oct 11 17:16:48 2013 -0600
Committer: Marcus Sorensen <marcus@betterservers.com>
Committed: Fri Oct 11 17:16:48 2013 -0600

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java  | 13 +++++-----
 .../kvm/storage/KVMStorageProcessor.java        | 25 ++++++++++++++------
 .../kvm/storage/LibvirtStorageAdaptor.java      |  2 +-
 3 files changed, 25 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b344bb4c/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index e07d122..af31d48 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1457,19 +1457,18 @@ ServerResource {
 
             if (cmd.getTemplateUrl() != null) {
                 if(primaryPool.getType() == StoragePoolType.CLVM) {
-                    vol = templateToPrimaryDownload(cmd.getTemplateUrl(),primaryPool);
+                    vol = templateToPrimaryDownload(cmd.getTemplateUrl(),primaryPool, dskch.getPath());
                 } else {
                     BaseVol = primaryPool.getPhysicalDisk(cmd.getTemplateUrl());
-                    vol = _storagePoolMgr.createDiskFromTemplate(BaseVol, UUID
-                            .randomUUID().toString(), primaryPool, 0);
+                    vol = _storagePoolMgr.createDiskFromTemplate(BaseVol,
+                            dskch.getPath(), primaryPool, 0);
                 }
                 if (vol == null) {
                     return new Answer(cmd, false,
                             " Can't create storage volume on storage pool");
                 }
             } else {
-                vol = primaryPool.createPhysicalDisk(UUID.randomUUID()
-                        .toString(), dskch.getSize());
+                vol = primaryPool.createPhysicalDisk(dskch.getPath(), dskch.getSize());
             }
             VolumeTO volume = new VolumeTO(cmd.getVolumeId(), dskch.getType(),
                     pool.getType(), pool.getUuid(), pool.getPath(),
@@ -1486,7 +1485,7 @@ ServerResource {
     }
 
     // this is much like PrimaryStorageDownloadCommand, but keeping it separate
-    protected KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool
primaryPool) {
+    protected KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool
primaryPool, String volUuid) {
         int index = templateUrl.lastIndexOf("/");
         String mountpoint = templateUrl.substring(0, index);
         String templateName = null;
@@ -1522,7 +1521,7 @@ ServerResource {
 
             /* Copy volume to primary storage */
 
-            KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, UUID.randomUUID().toString(),
primaryPool, 0);
+            KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, volUuid,
primaryPool, 0);
             return primaryVol;
         } catch (CloudRuntimeException e) {
             s_logger.error("Failed to download template to primary storage",e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b344bb4c/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
index b1c8ec7..04bdd76 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
@@ -192,8 +192,19 @@ public class KVMStorageProcessor implements StorageProcessor {
             KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(),
                     primaryStore.getUuid());
 
-            KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(),
+            KVMPhysicalDisk primaryVol = null;
+            if (destData instanceof VolumeObjectTO) {
+                VolumeObjectTO volume = (VolumeObjectTO) destData;
+                primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, volume.getUuid(),
+                    primaryPool, cmd.getWaitInMillSeconds()); 
+            } else if (destData instanceof TemplateObjectTO) {
+                TemplateObjectTO destTempl = (TemplateObjectTO) destData;
+                primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, destTempl.getUuid(),
                     primaryPool, cmd.getWaitInMillSeconds());
+            } else {
+                primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, UUID.randomUUID().toString(),
+                    primaryPool, cmd.getWaitInMillSeconds());
+            }
 
 
             DataTO data = null;
@@ -230,8 +241,8 @@ public class KVMStorageProcessor implements StorageProcessor {
         }
     }
 
-    // this is much like PrimaryStorageDownloadCommand, but keeping it separate
-    private KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool
primaryPool, int timeout) {
+    // this is much like PrimaryStorageDownloadCommand, but keeping it separate. copies template
direct to root disk
+    private KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool
primaryPool, String volUuid, int timeout) {
         int index = templateUrl.lastIndexOf("/");
         String mountpoint = templateUrl.substring(0, index);
         String templateName = null;
@@ -267,7 +278,7 @@ public class KVMStorageProcessor implements StorageProcessor {
 
             /* Copy volume to primary storage */
 
-            KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(templateVol, UUID.randomUUID().toString(),
+            KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(templateVol, volUuid,
                     primaryPool, timeout);
             return primaryVol;
         } catch (CloudRuntimeException e) {
@@ -299,14 +310,14 @@ public class KVMStorageProcessor implements StorageProcessor {
 
             if (primaryPool.getType() == StoragePoolType.CLVM) {
                 templatePath = ((NfsTO)imageStore).getUrl() + File.separator + templatePath;
-                vol = templateToPrimaryDownload(templatePath, primaryPool, cmd.getWaitInMillSeconds());
+                vol = templateToPrimaryDownload(templatePath, primaryPool, volume.getUuid(),
cmd.getWaitInMillSeconds());
             } else {
                 if (templatePath.contains("/mnt")) {
                     //upgrade issue, if the path contains path, need to extract the volume
uuid from path
                     templatePath = templatePath.substring(templatePath.lastIndexOf(File.separator)
+ 1);
                 }
                 BaseVol = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(),
templatePath);
-                vol = storagePoolMgr.createDiskFromTemplate(BaseVol, UUID.randomUUID().toString(),
BaseVol.getPool(), cmd.getWaitInMillSeconds());
+                vol = storagePoolMgr.createDiskFromTemplate(BaseVol, volume.getUuid(), BaseVol.getPool(),
cmd.getWaitInMillSeconds());
             }
             if (vol == null) {
                 return new CopyCmdAnswer(" Can't create storage volume on storage pool");
@@ -1009,7 +1020,7 @@ public class KVMStorageProcessor implements StorageProcessor {
             primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid());
             disksize = volume.getSize();
 
-            vol = primaryPool.createPhysicalDisk(UUID.randomUUID().toString(), disksize);
+            vol = primaryPool.createPhysicalDisk(volume.getUuid(), disksize);
 
             VolumeObjectTO newVol = new VolumeObjectTO();
             newVol.setPath(vol.getName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b344bb4c/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index 51e3363..e04297e 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -768,7 +768,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
     public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
             String name, PhysicalDiskFormat format, long size, KVMStoragePool destPool, int
timeout) {
 
-        String newUuid = UUID.randomUUID().toString();
+        String newUuid = name;
         KVMStoragePool srcPool = template.getPool();
         KVMPhysicalDisk disk = null;
 


Mime
View raw message