slideshow 1 slideshow 2 slideshow 3 slideshow 4 slideshow 5 slideshow 6 slideshow 7

Updating Custom Properties in a vRealize Automation 8 Deployment with a vRealize Orchestrator Workflow

When deploying machines from vRealize Automation version 8.x custom properties can be used to store values that you want to process yourself during the lifecycle of the machine. These custom properties can be accessed and updated with a vRealize Orchestrator workflow when called by a subscription. How to read and update custom properties is documented in this article. In the video below I show how the properties are read and updated. Also a new custom property is added during execution. Below the video you can find the definition of the workflow parameters and the necessary Javascript code. 

Make sure your vRA Extensibility Subscription has Blocking enabled. Non-blocking subscriptions execute workflows asynchronously (fire-and-forget). Only with blocking subscriptions the output parameters of your workflow are accepted back by vRA. 

In the workflow in this example the vRA Blueprint contains a projectCode input parameter that is set as a custom property. In the workflow it will be overwritten, just to show that custom properties can also be updated by your workflow. Another property is set and not updated while the workflow also adds a new property during execution that was not there from the start of the deployment.

The way passing back data to vRA works, is that you must return output parameters that match exactly with the Event Topic's Schema. For example the Array/String resourceNames can be updated by returning an output parameter of that exact type and with that exact name. In this example the output parameter is of the type properties named customProperties. The image below shows the Schema of the Compute allocation Event Topic. The S in front of a schema element means string. If it has a stack icon next to it then it is an array. The C refers to a complex type such as the Properties type for the customProperties.

vRealize Automation Event Topic Schema

The workflow is also available as a package that you can import into your vrealize Orchestrator environment: com.VMwarebits.vRA.package.zip

This image shows the required input parameter for the workflow of the type Properties. This will contain the entire payload that is transferred from vRA to vRO. The output parameter is also of the type Properties and has the name customProperties which matches the name and type defined in the schema for the chosen Subscription Event Topic. 

vRealize Automation Update Custom Properties with vRealize Orchestrator

This is the Javascript code for the scriptable task element:

(The first part is only used to show the current properties and values.)

function dumpProperties(props,lvl){
         var keys = props.keys;
         var prefix = ""
     for (var i=0; i<lvl; i++){
                   prefix = prefix + "";
          }
          for (k in keys){
                 var key = keys[k];
                 var value = props.get(keys[k])
                 if ("Properties" == System.getObjectType(value)){
                  System.log(prefix + key + "[")
                  dumpProperties(value,(lvl+2));
                  System.log(prefix+ "]")
                 } else{
                   System.log( prefix + key + ":" + value)
                 }
                 }
   }
   dumpProperties(inputProperties, 0)
   customProps = inputProperties.get("customProperties")
   dumpProperties(customProps, 0)

customProperties = new Properties();
//This will update the current projectCode property to show
//that a property can be overwritten by a workflow
customProperties.put("projectCode", "ABC123")
//This will add a new property that did not yet exist in the request
customProperties.put("newCustomProp", "Test123")
//other properties are not updated and therefor not affected

 

Follow us on LinkedIn