VMware Cloud Community
schistad
Enthusiast
Enthusiast

findAllForType and xpath; which attributes can be searched?

Is there any way to determine which attributes in, say, a VM, are actually searchable?

Let's say I want to find a VM using the hostname of the guest OS (eg hostname). The following does NOT work:

Server.findAllForType("Vc:virtualMachine","xpath:guest.HostName='host.name'")

Whereas this does:

Server.findAllForType("Vc:virtualMachine","xpath:name='hostname'")

I have a feeling that the type of property (eg simple String versus something inherited from a VMware class) is relevant, but I've never seen an actual explanation.

I also know that there are ways to retrieve this through the VMware search service but that sounds like a lot more work, and slower code.

0 Kudos
1 Reply
qc4vmware
Virtuoso
Virtuoso

Hey there.  I see you have stumbled into the black hole of VMware tribal knowledge AKA Server.findAllForType.  An amazingly powerful tool that is totally undocumented.  I urge you to open up a support case if you haven't already as I consider the lack of documentation a bug.  It seems that every plugin implements the query piece differently and even has different options depending on the object type in many cases.  I have made a request that the documentation for each plugin be updated to include the details of how the query piece of Server.findAllForType is implemented and also a few examples.  If you are doing anything with vCAC please look at this post of mine which had some guidance on querying that plugin.  Server.findAllForType query parameter mystery solved (sorta) .

0 Kudos