You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by li...@apache.org on 2013/12/17 14:42:59 UTC

git commit: updated refs/heads/4.3 to 11ef692

Updated Branches:
  refs/heads/4.3 9118bbf93 -> 11ef692ac


CLOUDSTACK-4875. Vmware vCenter 5.5 - System VM deployment fails.
During VM deployment when base template is being cloned to create VM ROOT disk, get the disk path
 i.e. base file name of the VM's ROOT disk from vCenter


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

Branch: refs/heads/4.3
Commit: 11ef692acd8c6bc291a06e5c141e9b3bc1bb976a
Parents: 9118bbf
Author: Likitha Shetty <li...@citrix.com>
Authored: Sun Dec 15 16:01:27 2013 +0530
Committer: Likitha Shetty <li...@citrix.com>
Committed: Tue Dec 17 18:32:21 2013 +0530

----------------------------------------------------------------------
 .../resource/VmwareStorageProcessor.java        | 52 ++++++--------------
 .../hypervisor/vmware/mo/VirtualMachineMO.java  | 16 ++++++
 2 files changed, 32 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11ef692a/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 38f5b24..ef33ae6 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -256,22 +256,6 @@ public class VmwareStorageProcessor implements StorageProcessor {
             throw new Exception(msg);
         }
 
-        s_logger.info("Move volume out of volume-wrapper VM ");
-        String[] vmwareLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo,
-                vmdkName, vmdkName, VmwareStorageLayoutType.VMWARE, true);
-        String[] legacyCloudStackLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo,
-                vmdkName, vmdkName, VmwareStorageLayoutType.CLOUDSTACK_LEGACY, true);
-
-        dsMo.moveDatastoreFile(vmwareLayoutFilePair[0],
-                dcMo.getMor(), dsMo.getMor(),
-                legacyCloudStackLayoutFilePair[0],
-                dcMo.getMor(), true);
-
-        dsMo.moveDatastoreFile(vmwareLayoutFilePair[1],
-                dcMo.getMor(), dsMo.getMor(),
-                legacyCloudStackLayoutFilePair[1],
-                dcMo.getMor(), true);
-
         return true;
     }
 
@@ -285,21 +269,6 @@ public class VmwareStorageProcessor implements StorageProcessor {
             throw new Exception(msg);
         }
 
-        s_logger.info("Move volume out of volume-wrapper VM ");
-        String[] vmwareLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo,
-                vmdkName, vmdkName, VmwareStorageLayoutType.VMWARE, false);
-        String[] legacyCloudStackLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo,
-                vmdkName, vmdkName, VmwareStorageLayoutType.CLOUDSTACK_LEGACY, false);
-
-        dsMo.moveDatastoreFile(vmwareLayoutFilePair[0],
-                dcMo.getMor(), dsMo.getMor(),
-                legacyCloudStackLayoutFilePair[0],
-                dcMo.getMor(), true);
-
-        dsMo.moveDatastoreFile(vmwareLayoutFilePair[1],
-                dcMo.getMor(), dsMo.getMor(),
-                legacyCloudStackLayoutFilePair[1],
-                dcMo.getMor(), true);
         return true;
     }
 
@@ -325,6 +294,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
             DatastoreMO dsMo = new DatastoreMO(context, morDatastore);
 
             String vmdkName = volume.getName();
+            String vmdkFileBaseName = null;
             if (srcStore == null) {
                 // create a root volume for blank VM (created from ISO)
                 String dummyVmName = this.hostService.getWorkerName(context, cmd, 0);
@@ -334,8 +304,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
                     if (vmMo == null) {
                         throw new Exception("Unable to create a dummy VM for volume creation");
                     }
-
-                    String vmdkFilePair[] = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, null, vmdkName,
+                    vmdkFileBaseName = vmMo.getVmdkFileBaseNames().get(0);
+                    String vmdkFilePair[] = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, null, vmdkFileBaseName,
                             VmwareStorageLayoutType.CLOUDSTACK_LEGACY,
                             true	// we only use the first file in the pair, linked or not will not matter
                             );
@@ -371,6 +341,16 @@ public class VmwareStorageProcessor implements StorageProcessor {
                 vmMo = new ClusterMO(context, morCluster).findVmOnHyperHost(vmdkName);
                 assert (vmMo != null);
 
+                vmdkFileBaseName = vmMo.getVmdkFileBaseNames().get(0); // TO-DO: Support for base template containing multiple disks
+                s_logger.info("Move volume out of volume-wrapper VM ");
+                String[] vmwareLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, vmdkName, vmdkFileBaseName,
+                        VmwareStorageLayoutType.VMWARE, !_fullCloneFlag);
+                String[] legacyCloudStackLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, vmdkName, vmdkFileBaseName,
+                        VmwareStorageLayoutType.CLOUDSTACK_LEGACY, !_fullCloneFlag);
+
+                dsMo.moveDatastoreFile(vmwareLayoutFilePair[0], dcMo.getMor(), dsMo.getMor(), legacyCloudStackLayoutFilePair[0], dcMo.getMor(), true);
+                dsMo.moveDatastoreFile(vmwareLayoutFilePair[1], dcMo.getMor(), dsMo.getMor(), legacyCloudStackLayoutFilePair[1], dcMo.getMor(), true);
+
                 s_logger.info("detach disks from volume-wrapper VM " + vmdkName);
                 vmMo.detachAllDisks();
 
@@ -383,13 +363,13 @@ public class VmwareStorageProcessor implements StorageProcessor {
             // restoreVM - move the new ROOT disk into corresponding VM folder
             String vmInternalCSName = volume.getVmName();
             if (dsMo.folderExists(String.format("[%s]", dsMo.getName()), vmInternalCSName)) {
-                String oldRootDisk = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(dsMo, vmInternalCSName, vmdkName);
+                String oldRootDisk = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(dsMo, vmInternalCSName, vmdkFileBaseName);
                 if (oldRootDisk != null)
-                    VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmInternalCSName, dsMo, vmdkName);
+                    VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmInternalCSName, dsMo, vmdkFileBaseName);
             }
 
             VolumeObjectTO newVol = new VolumeObjectTO();
-            newVol.setPath(vmdkName);
+            newVol.setPath(vmdkFileBaseName);
             newVol.setSize(volume.getSize());
             return new CopyCmdAnswer(newVol);
         } catch (Throwable e) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/11ef692a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 108e35a..a68538b 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -1693,6 +1693,22 @@ public class VirtualMachineMO extends BaseMO {
 		}
 	}
 
+    public List<String> getVmdkFileBaseNames() throws Exception {
+        List<String> vmdkFileBaseNames = new ArrayList<String>();
+        VirtualDevice[] devices = getAllDiskDevice();
+        for(VirtualDevice device : devices) {
+            if(device instanceof VirtualDisk) {
+                VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
+                if(backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
+                    VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
+                    DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
+                    vmdkFileBaseNames.add(dsBackingFile.getFileBaseName());
+                }
+            }
+        }
+        return vmdkFileBaseNames;
+    }
+
 	// this method relies on un-offical VMware API
 	@Deprecated
 	public void moveAllVmDiskFiles(DatastoreMO destDsMo, String destDsDir, boolean followDiskChain) throws Exception {