Community
 
 
 

CloudPlatform 4.x

284 followers
 
Avatar
Administrator

Get Size of VMSnapshot (VMWare)

Avatar

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;
}

 

 

 


Artjoms Petrovs MEMBERS 06 March 2014 - 15:40 PM
2 comments
0

Please sign in to leave a comment.

 
 

Previous 2 comments

Avatar
Administrator
Avatar

Get Size of VMSnapshot (VMWare)

Hi,

 

Can you check for vm_snapshot_chain_size in volumes table


Prashanth Reddy Mandadi CITRIX EMPLOYEES 07 March 2014 - 15:21 PM
Comment actions Permalink
Avatar
Administrator
Avatar
Prashanth, Thank You! This is exactly I was desperately looking for! 

A.

Artjoms Petrovs MEMBERS 07 March 2014 - 15:56 PM
Comment actions Permalink

Top Contributors