cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject git commit: updated refs/heads/4.4-forward to 68992c8
Date Tue, 22 Apr 2014 04:14:18 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward 756f48f91 -> 68992c8f7


CLOUDSTACK-6170 (VMware root-disk support for managed storage)


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

Branch: refs/heads/4.4-forward
Commit: 68992c8f7391acf623efbe9159807789a7ebfe1e
Parents: 756f48f
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Sat Apr 19 23:39:57 2014 -0600
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Mon Apr 21 22:00:20 2014 -0600

----------------------------------------------------------------------
 .../resource/VmwareStorageProcessor.java        | 43 +++++++++++++-------
 1 file changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/68992c8f/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index fd7520e..e413524 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -139,8 +139,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
         return null;
     }
 
-    private void copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost, DatastoreMO
datastoreMo, String secondaryStorageUrl,
-            String templatePathAtSecondaryStorage, String templateName, String templateUuid)
throws Exception {
+    private VirtualMachineMO copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost,
DatastoreMO datastoreMo, String secondaryStorageUrl,
+            String templatePathAtSecondaryStorage, String templateName, String templateUuid,
boolean createSnapshot) throws Exception {
 
         s_logger.info("Executing copyTemplateFromSecondaryToPrimary. secondaryStorage: "
+ secondaryStorageUrl + ", templatePathAtSecondaryStorage: " +
                 templatePathAtSecondaryStorage + ", templateName: " + templateName);
@@ -186,17 +186,24 @@ public class VmwareStorageProcessor implements StorageProcessor {
             throw new Exception(msg);
         }
 
-        if (vmMo.createSnapshot("cloud.template.base", "Base snapshot", false, false)) {
-            // the same template may be deployed with multiple copies at per-datastore per-host
basis,
-            // save the original template name from CloudStack DB as the UUID to associate
them.
-            vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_UUID, templateName);
-            vmMo.markAsTemplate();
-        } else {
-            vmMo.destroy();
-            String msg = "Unable to create base snapshot for template, templateName: " +
templateName + ", templateUuid: " + templateUuid;
-            s_logger.error(msg);
-            throw new Exception(msg);
+        if (createSnapshot) {
+            if (vmMo.createSnapshot("cloud.template.base", "Base snapshot", false, false))
{
+                // the same template may be deployed with multiple copies at per-datastore
per-host basis,
+                // save the original template name from CloudStack DB as the UUID to associate
them.
+                vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_UUID, templateName);
+                vmMo.markAsTemplate();
+            } else {
+                vmMo.destroy();
+
+                String msg = "Unable to create base snapshot for template, templateName:
" + templateName + ", templateUuid: " + templateUuid;
+
+                s_logger.error(msg);
+
+                throw new Exception(msg);
+            }
         }
+
+        return vmMo;
     }
 
     @Override
@@ -289,10 +296,12 @@ public class VmwareStorageProcessor implements StorageProcessor {
 
                 dsMo = new DatastoreMO(context, morDs);
 
-                copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl,
templateInfo.first(), templateInfo.second(),
-                        managed ? managedStoragePoolRootVolumeName : templateUuidName);
-
                 if (managed) {
+                    VirtualMachineMO vmMo = copyTemplateFromSecondaryToPrimary(hyperHost,
dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(),
+                            managedStoragePoolRootVolumeName, false);
+
+                    vmMo.unregisterVm();
+
                     String[] vmwareLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo,
managedStoragePoolRootVolumeName,
                         managedStoragePoolRootVolumeName, VmwareStorageLayoutType.VMWARE,
false);
                     String[] legacyCloudStackLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo,
null,
@@ -304,6 +313,10 @@ public class VmwareStorageProcessor implements StorageProcessor {
                     String folderToDelete = dsMo.getDatastorePath(managedStoragePoolRootVolumeName,
true);
                     dsMo.deleteFolder(folderToDelete, dcMo.getMor());
                 }
+                else {
+                    copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl,
templateInfo.first(), templateInfo.second(),
+                            templateUuidName, true);
+                }
             } else {
                 s_logger.info("Template " + templateInfo.second() + " has already been setup,
skip the template setup process in primary storage");
             }


Mime
View raw message