VMware Aria Automation Orchestrator

 View Only
  • 1.  nested xpath expression | retrieve all VMs that are defined as templates

    Posted Nov 01, 2018 04:21 PM

    I am trying to retrieve all VM templates that exist within the vCenter Server.

    Assuming that I am using the following code:

    var VcVirtualMachine_Array = Server.findAllForType("VC:VirtualMachine",XPath_query);

    what should be the XPath_query value ?

    I already tried the following methods:

    var XPath_query = "xpath:isTemplate='true'";

    var XPath_query = "xpath:config.template[contains(.,'true')]";

    var XPath_query = "xpath://config/template[@name='template' and @type='true']";

    also , according to the following link:

    https://www.vmware.com/support/orchestrator/doc/vro-vsphere60-api/html/VirtualMachine.html

    the Finder type: VC:VirtualMachine

    has a Property named isTemplate

    but I am not able to filter the output using this type of Property.

    what is the way to filter using XPath a nested attribute ?

    because the object it's self has an attribute named: config.template

    but all of them were not helping to achieve what I am looking to retrieve as already filtered output.

    thank in advanced for the assistance



  • 2.  RE: nested xpath expression | retrieve all VMs that are defined as templates

    Broadcom Employee
    Posted Nov 01, 2018 09:31 PM

    Hi,

    Try with:

    var XPath_query = "xpath:config/template[ . = true() ]";

    var VcVirtualMachine_Array = Server.findAllForType("VC:VirtualMachine", XPath_query);



  • 3.  RE: nested xpath expression | retrieve all VMs that are defined as templates

    Posted Mar 18, 2025 10:06 AM

    For future references, this did the trick for me:

    // xpath query do get only templates
    var query = "xpath:summary/config/template = 'true'";
    var templates = Server.findAllForType("VC:VirtualMachine", query);