Daniel Langenhan

Cloud - Architect - Designer - Consultant

Working with vRO Properties

Properties in vRealize Orchestrator are a great way to transport complex variables between different workflows.

A property can carry several different variable types as well as being "multi-dimentional". What I mean by that is that one can define properties within properties within properties. In vRealize Automation this is used in the payload that the eventmanager produces. 

A property consists of a Key (sting) and the vaiable that is assosiated to the property. For instance the key vmName contains the name (Sting) of the vm, where as the key vmObject could contain the VM object it self. 

Create a property

To create a property you first have to define it using (well there is more...but these are just the basics):

var vmDetail = new Properties(); 

Even if you define the out-put variable of a scriptable task as an property you need to initialize it with the line above.

Put content into a property

The next step would be to fill up the property with content (vm is the VMware object of type VC:VirtualMachine)

vmDetail.put("vmName",vm.name);
vmDetail.put("vmCPU",vm.cpu);
vmDetail.put("vmMem",vm.memory);

The content that is assigned to a property can be of any type: string, number, array, properties...any type of variable that vRO knows. For example lets assign an array of string to the property:

vmUsers = new Array();
vmUsers.push("Jeff");
vmUsers.push("Magret");
vmDetail.put("vmUsers",vmUsers);

Read the content of a propery

To read content of a property you can use two methods (well there is more...but again... basics). The first one is to call it by the name of the key:

System.log(   vmDetail.get(vmCPU)   );
System.log(   vmDetail.get(vmUsers)[1]   );

The second method is to walk the property, meaning to display all content:

for each (key in vmDetails.keys){
    System.log(  vmDetails.get(key)  );
}

Create properies within Properties

The ability to put properties into properties is by far the greates feature of properties. (allVMs is an array of VC:VirtualMachine)

vmDetails = new Properties(); 
for each (vm in allVMs){
    var vmDetail = new Properties();
    vmDetail.put("vmName",vm.name);
    vmDetail.put("vmCPU",vm.cpu);
    vmDetail.put("vmMem",vm.memory);
    vmDetails.put(vm.name,vmDetail);
}