
Get Size of VMSnapshot (VMWare)
Hello!
I have a small question - how ca I get the size of a VMSnapshot, that is made via a VMWare ESX call?
I've found one function, that calculates the amount, during the creation of a Snapshot (see the code snippet), but it seems, that I cannot get this value anywhere after the creation
Is there any entry of this in a database, or in a log file?
A.
package com.cloud.hypervisor.vmware.manager;
private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost,
String fileName, String poolUuid, String exceptFileName)
throws Exception{
long size = 0;
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolUuid);
DatastoreMO dsMo = new DatastoreMO(context, morDs);
HostDatastoreBrowserMO browserMo = dsMo.getHostDatastoreBrowserMO();
String datastorePath = "[" + dsMo.getName() + "]";
HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec();
FileQueryFlags fqf = new FileQueryFlags();
fqf.setFileSize(true);
fqf.setFileOwner(true);
fqf.setModification(true);
searchSpec.setDetails(fqf);
searchSpec.setSearchCaseInsensitive(false);
searchSpec.getMatchPattern().add(fileName);
ArrayList<HostDatastoreBrowserSearchResults> results = browserMo.
searchDatastoreSubFolders(datastorePath, searchSpec);
for(HostDatastoreBrowserSearchResults result : results){
if (result != null) {
List<FileInfo> info = result.getFile();
for (FileInfo fi : info) {
if(exceptFileName != null && fi.getPath().contains(exceptFileName)) {
continue;
} else {
size = size + fi.getFileSize();
}
}
}
}
return size;
}

