Skip to content

Commit be38b97

Browse files
author
Mike Tutkowski
committed
Fixing an issue related to figuring out the name of a datastore that is backed by managed storage
1 parent d276c0f commit be38b97

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,15 +2035,31 @@ private VirtualMachineDiskInfo getMatchingExistingDisk(VirtualMachineDiskInfoBui
20352035
if (diskInfoBuilder != null) {
20362036
VolumeObjectTO volume = (VolumeObjectTO)vol.getData();
20372037

2038-
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, volume.getDataStore().getUuid());
2039-
DatastoreMO dsMo = new DatastoreMO(context, morDs);
2040-
String dsName = dsMo.getName();
2038+
String dsName = null;
2039+
String diskBackingFileBaseName= null;
20412040

20422041
Map<String, String> details = vol.getDetails();
20432042
boolean isManaged = details != null && Boolean.parseBoolean(details.get(DiskTO.MANAGED));
20442043

2044+
if (isManaged) {
2045+
String iScsiName = details.get(DiskTO.IQN);
2046+
2047+
// if the storage is managed, iScsiName should not be null
2048+
dsName = VmwareResource.getDatastoreName(iScsiName);
2049+
2050+
diskBackingFileBaseName = new DatastoreFile(volume.getPath()).getFileBaseName();
2051+
}
2052+
else {
2053+
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, volume.getDataStore().getUuid());
2054+
DatastoreMO dsMo = new DatastoreMO(context, morDs);
2055+
2056+
dsName = dsMo.getName();
2057+
2058+
diskBackingFileBaseName = volume.getPath();
2059+
}
2060+
20452061
VirtualMachineDiskInfo diskInfo =
2046-
diskInfoBuilder.getDiskInfoByBackingFileBaseName(isManaged ? new DatastoreFile(volume.getPath()).getFileBaseName() : volume.getPath(), dsName);
2062+
diskInfoBuilder.getDiskInfoByBackingFileBaseName(diskBackingFileBaseName, dsName);
20472063
if (diskInfo != null) {
20482064
s_logger.info("Found existing disk info from volume path: " + volume.getPath());
20492065
return diskInfo;

0 commit comments

Comments
 (0)