cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [16/27] git commit: updated refs/heads/master to ae23144
Date Wed, 04 Sep 2013 22:42:25 GMT
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/c6dfb33d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c6dfb33d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c6dfb33d

Branch: refs/heads/master
Commit: c6dfb33d9f2c74f2e508ecafec737d1c849a5577
Parents: dbe4e13
Author: Kelven Yang <kelveny@gmail.com>
Authored: Fri Aug 9 17:27:26 2013 -0700
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Wed Sep 4 14:49:45 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/c6dfb33d/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 af6026b..70b5bf0 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
@@ -3954,10 +3954,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);
 
@@ -4075,10 +4078,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/c6dfb33d/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 {
     	


Mime
View raw message