cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From likit...@apache.org
Subject git commit: updated refs/heads/master to fa2f18d
Date Tue, 17 Dec 2013 13:43:59 GMT
Updated Branches:
  refs/heads/master 3604f87c8 -> fa2f18d2a


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/fa2f18d2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fa2f18d2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fa2f18d2

Branch: refs/heads/master
Commit: fa2f18d2a208dca070fb831ecaf9bb8aec372a26
Parents: 3604f87
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Tue Dec 17 18:29:48 2013 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Tue Dec 17 18:31:15 2013 +0530

----------------------------------------------------------------------
 .../resource/VmwareStorageProcessor.java        | 37 ++++++++------------
 .../hypervisor/vmware/mo/VirtualMachineMO.java  | 16 +++++++++
 2 files changed, 30 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fa2f18d2/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 7c3e73a..b55dbec 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -253,16 +253,6 @@ public class VmwareStorageProcessor implements StorageProcessor {
             s_logger.error(msg);
             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;
     }
 
@@ -275,15 +265,6 @@ public class VmwareStorageProcessor implements StorageProcessor {
             s_logger.error(msg);
             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;
     }
 
@@ -309,6 +290,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);
@@ -319,8 +301,9 @@ public class VmwareStorageProcessor implements StorageProcessor {
                         throw new Exception("Unable to create a dummy VM for volume creation");
                     }
 
-                    String vmdkFilePair[] = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo,
null, vmdkName, VmwareStorageLayoutType.CLOUDSTACK_LEGACY, true    // we only use the first
file in the pair, linked or not will not matter
-                    );
+                    vmdkFileBaseName = vmMo.getVmdkFileBaseNames().get(0);
+                    // we only use the first file in the pair, linked or not will not matter
+                    String vmdkFilePair[] = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo,
null, vmdkFileBaseName, VmwareStorageLayoutType.CLOUDSTACK_LEGACY, true);
                     String volumeDatastorePath = vmdkFilePair[0];
                     synchronized (this) {
                         s_logger.info("Delete file if exists in datastore to clear the way
for creating the volume. file: " + volumeDatastorePath);
@@ -353,6 +336,14 @@ 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();
 
@@ -365,11 +356,11 @@ 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))
{
-                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/fa2f18d2/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 771c4a5..b23b0ff 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -1737,6 +1737,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 {


Mime
View raw message