Updated Branches:
  refs/heads/4.2 a8edf415b -> 17715d7e7

CLOUDSTACK-3237: pass disk file name instead of full datastore path when 
setting up storage relocation specin order to safely locate the disk device


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

Branch: refs/heads/4.2
Commit: 17715d7e7762de61f0b2e64ded7e1deb6b0541b3
Parents: a8edf41
Author: Kelven Yang <[email protected]>
Authored: Fri Aug 9 17:27:26 2013 -0700
Committer: Kelven Yang <[email protected]>
Committed: Fri Aug 9 17:28:35 2013 -0700

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         | 13 +++++++----
 .../resource/VmwareStorageLayoutHelper.java     | 23 ++++++++++++++++++++
 2 files changed, 32 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17715d7e/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 409c1f3..5e8510e 100755
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -3932,10 +3932,13 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
                     relocateSpec.setDatastore(morDsAtSource);
                     isFirstDs = false;
                 }
-                srcDiskName = String.format("[%s] %s.vmdk", srcDsName, 
volume.getPath());
+                srcDiskName = 
VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(
+                       new DatastoreMO(srcHyperHost.getContext(), 
morDsAtSource), 
+                       vmName, 
+                       volume.getPath() + ".vmdk");
                 diskLocator = new VirtualMachineRelocateSpecDiskLocator();
                 diskLocator.setDatastore(morDsAtSource);
-                diskLocator.setDiskId(getVirtualDiskInfo(vmMo, srcDiskName));
+                diskLocator.setDiskId(getVirtualDiskInfo(vmMo, 
volume.getPath() + ".vmdk"));
 
                 diskLocators.add(diskLocator);
 
@@ -4052,10 +4055,12 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
                 throw new Exception(msg);
             }
 
-            srcDiskName = String.format("[%s] %s.vmdk", srcDsName, volumePath);
+            srcDiskName = 
VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(
+               new DatastoreMO(srcHyperHost.getContext(), morDs), vmName, 
+               volumePath + ".vmdk");
             diskLocator = new VirtualMachineRelocateSpecDiskLocator();
             diskLocator.setDatastore(morDs);
-            diskLocator.setDiskId(getVirtualDiskInfo(vmMo, srcDiskName));
+            diskLocator.setDiskId(getVirtualDiskInfo(vmMo, volumePath + 
".vmdk"));
 
             diskLocators.add(diskLocator);
             relocateSpec.getDisk().add(diskLocator);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17715d7e/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
 
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
index b41b72a..c61f15e 100644
--- 
a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
@@ -64,6 +64,29 @@ public class VmwareStorageLayoutHelper {
        return null;
     }
     
+    public static String findVolumeDatastoreFullPath(DatastoreMO dsMo, String 
vmName, String vmdkFileName) throws Exception {
+       if(vmName != null) {
+               String path = getVmwareDatastorePathFromVmdkFileName(dsMo, 
vmName, vmdkFileName);
+               if(!dsMo.fileExists(path)) {
+                       path = getLegacyDatastorePathFromVmdkFileName(dsMo, 
vmdkFileName);
+                       
+                       // to save one call to vCenter, we won't check file 
existence for this round, so the caller
+                       // may still fail with exception, but if that's case, 
we will let it fail anyway
+               }
+               return path;
+       } else {
+                       String path = 
getLegacyDatastorePathFromVmdkFileName(dsMo, vmdkFileName);
+               if(!dsMo.fileExists(path)) {
+                       // Datastore file movement is not atomic operations, we 
need to sync and repair
+                       path = dsMo.searchFileInSubFolders(vmdkFileName, false);
+
+                       // to save one call to vCenter, we won't check file 
existence for this round, so the caller
+                       // may still fail with exception, but if that's case, 
we will let it fail anyway
+               }
+               return path;
+       }
+    }
+    
     public static String syncVolumeToVmDefaultFolder(DatacenterMO dcMo, String 
vmName, 
        DatastoreMO ds, String vmdkName) throws Exception {
        

Reply via email to