VMware Aria Automation 8.x Finder Objects
The vRealize Automation 7.x inventory includes 92 finder objects that can be used to select other inventory objects by name or properties.
The finder objects can be applied through either drop-down menus or a tree view.
You can implement drop-down menus or tree views for the plug-in objects that are documented in API Explorer under
vRA / Types
by adding them as workflow inputs. With the latest version of the plug-in for added in product version 8.4, these objects types are :- VRA:CloudAccount
- VRA:CloudAccountNsxT
- VRA:CloudAccountNsxV
- VRA:CloudAccountVsphere
- VRA:DataCollector
- VRA:Host
- VRA:Infrastructure
- VRA:Project
- VRA:Region
- VRA:Tag(supports only drop-down menus)
- VRA:Zone
For the other object types you can implement a drop-down menu either with string-based inputs displaying object names bound to an action, or by using one of the following methods:
- Authenticating in VMware Aria Automation by passing theVRA:Hostincluding the specific credentials. The object is included with the sample package.
- Creating a REST query to list the objects by applying filters if necessary.
- Return the object names from the JSON payload.
The string-based input drop-down menu can be populated with actions that return properties that include the ID of the object as a key and the name of the object as a value. By using these properties, you can access the object ID without needing to create actions that query the object by name. An example of such an action is the
getDeploymentsIdsAndNames
action included in the sample package.To perform efficient queries to find objects, it is necessary to use the query service. Retrieving all objects and iterating through them in a loop is not a best practice, particularly for objects that can have hundreds or thousands of iterations.
Use filtering as much as possible to avoid using CPU, IO, memory, input/output (I/O), or network resources on both the VMware Aria Automation and the Automation Orchestrator deployment.
The following example includes a query used to find an IaaS (Infrastructure as a Service) machine by name. The sample code snippet is taken from the sample action
getMachineByNameQS
.var url = "/iaas/api/machines"; // Query service parameter var nameFilter = "name eq '" + machineName + "'"; var parameters = "$filter=" + encodeURIComponent(nameFilter).replace("'", "%27"); var machines = System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjects(vraHost,url,parameters); if (machines.length == 1) return machines[0]; if (machines.length == 0) return null; // More Machines returned than expected ! System.warn("getProjectByNameQS returned " + projects.length + " projects"); return null;
You must encode any variable that can contain spaces or other special characters that are not accepted in the URL or from the server. For example, an apostrophe
(')
must be replaced with %27
.Paging must also be handled. The default number of object returned in a single query is limited. To get all objects, it is possible to:
- Change the default number of objects per page.There can be a maximum limit.
- Make different queries for different page numbers until all objects are received.
The samples actions
getIaaSObjects
and getDeploymentObjects
provide samples on how to use the paging parameters with the IaaS and deployment services. Depending on the service in use, this is done either with the skip parameter or the page parameter.The following sample includes the
getIaaSObjects
sample code:if (vraHost == null || url == null) return null; var iaasObject = System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjectFromUrl(vraHost,url, parameters); var content = iaasObject.content; var skip = 0; var elementsLeft = iaasObject.totalElements - iaasObject.numberOfElements; var allContent = content; var numberOfElements = iaasObject.numberOfElements while (elementsLeft >0) { var skip = skip + numberOfElements; if (parameters == null) parameters = "$skip=" + skip; else parameters = parameters + "&$skip=" + skip; iaasObject = System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjectFromUrl(vraHost,url, parameters); content = iaasObject.content; elementsLeft = elementsLeft - iaasObject.numberOfElements; allContent = allContent.concat(content); } return allContent;
The following sample includes the
getDeploymentObjects
sample code:if (vraHost == null || url == null) return null; var object = System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjectFromUrl(vraHost, url, parameters); var content = object.content; var page = 1; var allContent = content; while (object.last == false) { if (parameters == null || parameters == "") newParameters = "page=" + page; else newParameters = parameters + "&page=" + page; object = System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjectFromUrl(vraHost, url, newParameters); content = object.content; allContent = allContent.concat(content); page++; } return allContent;
To avoid searching for which service is using which query service syntax for paging, the
getObjects()
action checks which query service format to use based on the properties of the JSON file and returns all objects.As an example of providing an alternative to having inventory objects, the sample package includes the
Drop down
folder. The folder contains workflow examples with forms that use actions to populate the drop-down menus, including deployments, deployment resources, and deployment resource tags.Another alternative to plug-in inventory objects is to create Automation Orchestrator dynamic types for the required VMware Aria Automation objects. In this way, you can use an object as input supporting different properties or a tree view.
In some use cases, a single tree view is more convenient than multiple drop-down menus because you can filter for the object you want to select based on its parents.