vRO Workflow Machine Properties

Mindwatering Incorporated

Author: Tripp W Black

Created: 10/31 at 01:15 PM



To get a VM/machine and its machine properties, in a vRA workflow provisioning subscription:

Event Subscription:
- Select "Machine Provisioning" topic
- Added the ALL of the following conditions
- - - Data > Lifecycle state name EQUALS VMPSMasterWorkflow32.BuildingMachine
- - - Data > Lifecycle state phase EQUALS PRE
- - - Data > Machine > Machine Type EQUALS Virtual Machine

In vRO, The workflow will have an incoming input/parameter "payload".

Sample code snippets:
//Get the VM/machine and its properties:
var vm = payload.get("machine");

// get the VM ID - property of the VM
var vmId = vm.get('Id');
var vm0Addr = vm.get('VirtualMachine.Network0.Address');

// get all the VM metadata properties - vCACVmProperties and make a property object from which you can get values or loop them separately
// load from payload
vCACVMProps = payload.get('machine').get('properties');
// load from VM:
vCACVMProps = vm.get('properties');

// log all properties for breadcrumb use
System.debug('--------- vCACVMProps ----------');
for each (var key in vmProperties.keys) {
System.debug("Key: "+key+", value: "+vmProperties.get(key));

previous page