vmware: fix volume stats logic (#3473)

During volume stats calculation, if a volume has more than one disk in
the chain-info it is not used to sum the physical and virtual size
in the loop, instead any previous entry was overwritten by the last disk.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2019-07-22 17:27:41 +05:30 committed by GitHub
parent 6a336f8bc1
commit e1fa270593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3612,8 +3612,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
Pair<VirtualDisk, String> vds = vmMo.getDiskDevice(file.getFileName(), true);
long virtualsize = vds.first().getCapacityInKB() * 1024;
long physicalsize = primaryStorageDatastoreMo.fileDiskSize(file.getPath());
VolumeStatsEntry vse = new VolumeStatsEntry(chainInfo, physicalsize, virtualsize);
statEntry.put(chainInfo, vse);
if (statEntry.containsKey(chainInfo)) {
VolumeStatsEntry vse = statEntry.get(chainInfo);
if (vse != null) {
vse.setPhysicalSize(vse.getPhysicalSize() + physicalsize);
vse.setVirtualSize(vse.getVirtualSize() + virtualsize);
}
} else {
VolumeStatsEntry vse = new VolumeStatsEntry(chainInfo, physicalsize, virtualsize);
statEntry.put(chainInfo, vse);
}
}
}
}