From be38b9706615d5ab0cc9959577b0fff9a36a9fc6 Mon Sep 17 00:00:00 2001 From: Mike Tutkowski Date: Mon, 8 Dec 2014 13:40:52 -0700 Subject: [PATCH] Fixing an issue related to figuring out the name of a datastore that is backed by managed storage --- .../vmware/resource/VmwareResource.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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 b0aaa7fddd3..f55ca67cb40 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 @@ -2035,15 +2035,31 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa if (diskInfoBuilder != null) { VolumeObjectTO volume = (VolumeObjectTO)vol.getData(); - ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, volume.getDataStore().getUuid()); - DatastoreMO dsMo = new DatastoreMO(context, morDs); - String dsName = dsMo.getName(); + String dsName = null; + String diskBackingFileBaseName= null; Map details = vol.getDetails(); boolean isManaged = details != null && Boolean.parseBoolean(details.get(DiskTO.MANAGED)); + if (isManaged) { + String iScsiName = details.get(DiskTO.IQN); + + // if the storage is managed, iScsiName should not be null + dsName = VmwareResource.getDatastoreName(iScsiName); + + diskBackingFileBaseName = new DatastoreFile(volume.getPath()).getFileBaseName(); + } + else { + ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, volume.getDataStore().getUuid()); + DatastoreMO dsMo = new DatastoreMO(context, morDs); + + dsName = dsMo.getName(); + + diskBackingFileBaseName = volume.getPath(); + } + VirtualMachineDiskInfo diskInfo = - diskInfoBuilder.getDiskInfoByBackingFileBaseName(isManaged ? new DatastoreFile(volume.getPath()).getFileBaseName() : volume.getPath(), dsName); + diskInfoBuilder.getDiskInfoByBackingFileBaseName(diskBackingFileBaseName, dsName); if (diskInfo != null) { s_logger.info("Found existing disk info from volume path: " + volume.getPath()); return diskInfo;