if (getMoRef().equals(snapshotLayout.getKey())) {
// loop through each disk and count the last diskunit in the chain only
// because the previous ones are shared with the other snapshots so don't double counting
VirtualDevice[] devices = getConfig().getHardware().getDevice();
for(DiskLayout disk : snapshotLayout.getDisk()) {
VirtualDisk vdisk = (VirtualDisk)findDevice(devices, disk.getKey());
String diskMode = ((VirtualDisk.FlatVer2BackingInfo)vdisk.getBacking()).getDiskMode();
// independent disks are not included in snapshot
if (!diskMode.equals(DiskMode.independent_nonpersistent.name()) &&
!diskMode.equals(DiskMode.independent_persistent.name())) {
DiskUnit[] diskUnits = disk.getChain();
int[] fileKeys = diskUnits[diskUnits.length - 1].getFileKey();
// count the total of each file's size
long total = 0;
for (int fileKey : fileKeys) {
FileInfo fileInfo = fileMap.get(fileKey);
if (fileInfo != null) {
total += fileInfo.getSize();
}
}
// add up
size.add(total);
DeviceId deviceId =
new DeviceId(findDevice(devices, vdisk.getControllerKey()), vdisk);
sizeDetail.put(deviceId, new DiskSize(total));
}
}
// add vmsn file size which is always on data storage