VMware {code} Community
uehguaglio
Contributor
Contributor
Jump to solution

how to retrieve info from VmDiskFileInfo

Hi,

Can somebody tell me how to take informations from VmDiskFileInfo.

I have the ManagedObjectReference for all the virtual machine and for the associated datastores. How can I have the VmDiskFileInfo

property "capacityKb"on a specified Datastore for a specified Virtual Machine?

tnk

Reply
0 Kudos
1 Solution

Accepted Solutions
dmhaynes
Enthusiast
Enthusiast
Jump to solution

I apologize. I misunderstood your question.

VmDiskFileInfo is a subclass of FileInfo.

FileInfos are returned as part of a SearchDatastore_Task or SearchDatastoreSubFolders_Task in the 'info' property.

So, you need to use these tasks to fetch the info property for the file(s) you are interested in and cast the info[] elements to VmDiskFileInfo objects.

View solution in original post

Reply
0 Kudos
6 Replies
dmhaynes
Enthusiast
Enthusiast
Jump to solution

Since you want this information per VM, I would start there.

So,

1. use the VM moref to get the datastore property which is an array of morefs to the datastores for this VM.

2. for each datastore moref, load the info property which is a DatastoreInfo object

3. compare the name of the data store with the one you want

4. get the values you want

Reply
0 Kudos
uehguaglio
Contributor
Contributor
Jump to solution

Yes, but where is the link with the Data Object VmDiskFileInfo? I already retrieved many others Datastore and Vm's properties (this is my code) but...

PropertySpec d1 = new PropertySpec();

d1.setPathSet(new String[] { "summary.name",

"summary.capacity",

"summary.freeSpace"

});

d1.setType("Datastore");

PropertySpec h1 = new PropertySpec();

h1.setPathSet(new String[] { "name",

"summary.runtime.connectionState",

"summary.hardware.model",

"summary.hardware.cpuModel",

"summary.hardware.cpuMhz",

"summary.hardware.numCpuCores",

"summary.hardware.memorySize",

"summary.quickStats.overallCpuUsage",

"summary.quickStats.overallMemoryUsage",

"summary.quickStats.distributedCpuFairness",

"summary.hardware.numNics",

"config.fileSystemVolume.volumeTypeList",

"summary.config.product",

"summary.config.vmotionEnabled",

"config.datastorePrincipal",

"config.storageDevice.scsiLun",

"config.vmotion.ipConfig",

"vm",

"datastore"

});

h1.setType("HostSystem");

PropertySpec vm1 = new PropertySpec();

vm1.setPathSet(new String[] { "name",

"runtime.powerState",

"runtime.bootTime",

"runtime.host",

"runtime.maxCpuUsage",

"runtime.maxMemoryUsage",

"summary.quickStats.overallCpuUsage",

"datastore"});

...

Please help me or I'll get crazy!

Reply
0 Kudos
dmhaynes
Enthusiast
Enthusiast
Jump to solution

I apologize. I misunderstood your question.

VmDiskFileInfo is a subclass of FileInfo.

FileInfos are returned as part of a SearchDatastore_Task or SearchDatastoreSubFolders_Task in the 'info' property.

So, you need to use these tasks to fetch the info property for the file(s) you are interested in and cast the info[] elements to VmDiskFileInfo objects.

Reply
0 Kudos
uehguaglio
Contributor
Contributor
Jump to solution

mmm....I begin to see more clearly...

thank you dmhaynes, now I try

Reply
0 Kudos
ajpoland
Contributor
Contributor
Jump to solution

Hello,

Is there a trick to getting access to VmDiskFileInfo's beyond just casting a FileInfo to a VmDiskFileInfo? I'm trying it with a VmDiskFileQuery searchSpec, which successfully returns a list of only .vmdk files, but it runs into a class cast exception attempting to convert FileInfo to VmDiskFileInfo:

> }}

Result is: Exception in thread "main" java.lang.ClassCastException: com.vmware.vim25.FileInfo when it hits the line with the cast.

Reply
0 Kudos
macquivr
Contributor
Contributor
Jump to solution

I can help you with that, you need to set the FileType boolean in the QueryFlags on your details object.

This will give you VmDiskFileInfo objects, but my current problem is that these objects are not populated with any data.

- JT

Reply
0 Kudos