You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/04/22 10:07:38 UTC
git commit: updated refs/heads/4.4 to b32fb37
Repository: cloudstack
Updated Branches:
refs/heads/4.4 b6617843d -> b32fb37c5
[DB-CHANGE] 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/b32fb37c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b32fb37c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b32fb37c
Branch: refs/heads/4.4
Commit: b32fb37c513d9b0c2a0bf29038533097532a1b17
Parents: b661784
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Sat Apr 19 23:39:57 2014 -0600
Committer: Daan Hoogland <da...@onecht.net>
Committed: Tue Apr 22 10:06:42 2014 +0200
----------------------------------------------------------------------
.../resource/VmwareStorageProcessor.java | 43 +++++++++++++-------
1 file changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b32fb37c/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");
}