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?
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;
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.
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.
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;
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!