Fixing an issue related to figuring out the name of a datastore that is backed by managed storage

This commit is contained in:
Mike Tutkowski 2014-12-08 13:40:52 -07:00
parent dd700be263
commit 3ac8f8d601

View File

@ -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<String, String> 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;