VMware Cloud Community
jimmyvandermast
Hot Shot
Hot Shot
Jump to solution

Server.findAllForType VC:VirtualMachine query properties

I am trying to find a VM by querying the annotation.

My idea is to use

searchStr = "test"

query = "xpath:annotation eq '" + searchStr + "'";

vms = Server.findAllForType("VC:VirtualMachine", query);

The only thing that I find on the net / documentation is to query by 'name', while I am pretty sure that it must be possible to query based on other properties like the (config.)annotation?

Is there a way to find how and on what properties I can do a query?

Reply
0 Kudos
1 Solution

Accepted Solutions
jimmyvandermast
Hot Shot
Hot Shot
Jump to solution

Thanks, so I guess I have to step back and do it in an other way.

For now I get my result with an action:

var vmlist = new Array();

var vms = VcPlugin.getAllVirtualMachines();

for each (vm in vms) {

     if (vm.config.annotation == searchStr) {

     vmlist.push(vm);

     }

}

return vmlist;

View solution in original post

4 Replies
jimmyvandermast
Hot Shot
Hot Shot
Jump to solution

While doing more testing, I notice that it does work with the vCAC:VirtualMachine and a query on "Notes eq ...".

The same, with either Notes or annotations, does not work on the VC:VirtualMachine.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

That's normal.

The query parameter of Server.findAllForType() is plug-in specific. Most of the plug-ins completely ignore it. Other plug-ins use it to filter the list of returned objects, but only for some types. And even when the given plug-in uses this parameter, the format of the string passed there is not standartized - some plug-ins may expect XPath query, other - OData query or just a plain string.

jimmyvandermast
Hot Shot
Hot Shot
Jump to solution

Thanks, so I guess I have to step back and do it in an other way.

For now I get my result with an action:

var vmlist = new Array();

var vms = VcPlugin.getAllVirtualMachines();

for each (vm in vms) {

     if (vm.config.annotation == searchStr) {

     vmlist.push(vm);

     }

}

return vmlist;

qc4vmware
Virtuoso
Virtuoso
Jump to solution

Someday... if we are really lucky... VMware will actually require this to be documented.  Its one of my serious pet peeves. I like that is doesn't have to be a standard format... I hate having the information being some sort of tribal knowledge!

Reply
0 Kudos