VMware {code} Community
kaustubh_aphale
Contributor
Contributor

Can we get cluster/inventory hierarchy in terms of ObjectIds?

kaustubh_aphale_0-1644218419275.png

Hey, @_vladi_. Just a quick question. Is it possible to extract the hierarchy of all the level's ObjectIds?

 

Reply
0 Kudos
4 Replies
amarinov
VMware Employee
VMware Employee

Hi @kaustubh_aphale,

 

The vSphere Client retrieves the hierarchy nodes on demand i.e. the children of a node are retrieved on-demand only when that node gets expanded for the first time. The reason for this is that retrieving the full hierarchy would require multiple calls (the number of calls is equal to number of non-leaf nodes in the desired sub-tree) as first the top-level node has to be retrieved, then all of its child nodes, then all of its grandchild nodes and so on.

 

Do you have a local or a remote plugin? What do you need this hierarchy for?

 

Thanks,
Aleksandar

Reply
0 Kudos
kaustubh_aphale
Contributor
Contributor

I am working in remote plugin, and I want to cache the events and basically want to save the API call or fetching efforts. Hence in a scenario when I am on a DC level 1 and already have its data and I move to VC level, then I want to fetch only DC level 2's data. Hence require its objectId irrespective of it is expanded or not.

Reply
0 Kudos
amarinov
VMware Employee
VMware Employee

Hi @kaustubh_aphale,


You will need to use the the vim25 API or the vAPI to retrieve the necessary data. Eventual data caching should happen on the plugin server, invalidating the cache is a different matter which you should handle on your side.


The SDK cannot provide any cached tree hierarchy.


Thanks,
Aleksandar

Reply
0 Kudos
kaustubh_aphale
Contributor
Contributor

Thanks Aleksandar,
With your help I got what I was looking for. Appreciate your efforts!

Cheers
Kaustubh

Reply
0 Kudos