I have c# code that retrieves various items of inventory, using the usual rigmarole of object, property, and traversal specs etc.
The traversal spec I am using is a fairly "broad" one - it basically includes every time of traversal imaginable in going through the inventory tree. The objective is to basically get all VMs with some associated properties.
One thing that is bugging me now is that if I start the object spec at the moref of the root folder or the vmfolder of a datacenter, everything works fine and I get the morefs to VMs and the properties I want. However, if I start the object spec (objectspec.obj) at the moref of the datacenter itself, then I do not get anything back. Is it even possible to start at a datacenter (not the vmfolder of the datacenter) and get all the VMs therein? I understand that I can get the vmfolder from the datacenter and then get the VMs, and that works fine - the question is whether I can start at the datacenter moref itself.
Any help or comments would be much appreciated.
-- Moby
Hi Moby,
Yes, you can start from datacenter itself and then fetch the VMs through the datacenter->vmfolder->VM path. Basically the point is that you can start from any object, provided you get the managed object reference for that object. For example, if you want retrieve VM runtime info, you can set your starting object as datacenter and then drill down all the way to VM through the traversal spec and then fetch the prop. Alternatively, if you have the VM MO R, set the starting point as the VM and then fetch the prop.
There might be some issue in the way you are writing your traversal spec.
Hope this info helps!
- Angela -
Hi Moby,
Yes, you can start from datacenter itself and then fetch the VMs through the datacenter->vmfolder->VM path. Basically the point is that you can start from any object, provided you get the managed object reference for that object. For example, if you want retrieve VM runtime info, you can set your starting object as datacenter and then drill down all the way to VM through the traversal spec and then fetch the prop. Alternatively, if you have the VM MO R, set the starting point as the VM and then fetch the prop.
There might be some issue in the way you are writing your traversal spec.
Hope this info helps!
- Angela -
Thanks Angela - it was a wedged traversalspec - works like a charm once I redid the tspec.
Hi,
I am trying to understand writing the traversal spec to browse through inventory. Appreciate if you can explain or point me to the appropriate documentation to read and understand. It will be great if you can share your code also.
Thanks,
Prasad
check out this code of vijava API: http://vijava.svn.sourceforge.net/viewvc/vijava/trunk/src/com/vmware/vim25/mo/util/PropertyCollector...
It has code to build full inventory traversal.
Steve Jin, http://www.doublecloud.org
Thanks a lot for your reply. I understood the pattern of writing the traversal spec though I did not logically understand the reason for including all the below selection specs as we go up.
Thanks,
Prasad
Hi Prasad,
I think you can simplify the traversal spec if you just start from a Datacenter. But I dont think you will get much by doing that unless you notice a performance problem there.
Steve, http://www.doublecloud.org