vRA Event Broker – pass basic and custom properties to vRO

When it comes to automation and further customization of the vRA managed VMs we can’t overlook the vRA 7.x Event Broker. It gives us the opportunity to trigger a vRO workflow when one or multiple conditions are met. In most use cases the information regarding the object that triggers the workflow needs to be used in the vRO workflow. This article aims to explore how to pass basic and custom properties from vRA to vRO.

Event subscription

For the purpose of this example we will create a new subscription which will trigger a workflow after VM provisioning.
First step would be to prepare the vRO workflow. In this case we only need one input parameter of type Properties.
We will work with and print the received information from vRA via one Scriptable task.
Make sure to add the Properties parameter to the IN section of the Scriptable task in order to have access to it.
Now we are ready to create our subscription.

  1. From vRA select Administration -> Events -> Subscriptions and select the green plus icon to add new.
  2. Select an event topic. On the left hand side are listed the available options to select and on the right side there are details about the selected topic. The information carried by this event is shown under the Schema.
    Select Machine Provisioning and click Next.
  3. As mentioned above, we want to trigger a workflow after VM provisioning. To achieve that, on the Conditions tab select the following:
    PropertyOperatorValue
    Data > Machine > Machine typeEqualsConstant > Virtual Machine
    Data > Lifecycle state > Lifecycle state nameEqualsConstant > VMPSMasterWorkflow32.MachineProvisioned
    Data > Lifecycle state > State phaseEqualsConstant > POST

    Once ready, click Next.
  4. On the Workflow tab browse to the workflow you want to be executed. On the right side you’ll see a brief summary of the workflow.
    Select the desired workflow and click Next.
  5. Specify name and description for the new subscription on the Details tab and click Finish. The rest of the fields in this tab are beyond the scope of this article.
  6. Don’t forget to Publish the subscription after it’s ready.

At this point we have created our subscription which will trigger specific workflow after VM Provisioning. Let’s move on with reading the information passed from vRA Event Broker to vRO.

Basic properties

Based on the Schema of the carried info from vRA showed above, here is an example of reading two of the basic machine properties – Name and MoRef (Managed Object Reference).
First, let’s add the following code to the Scriptable task:

Once new VM is provisioned from vRA the result from the workflow should look like this:

Custom properties

Below is expanded view of part of the Schema shown in the Event Subscription section.

By default, the data in machine -> properties is not carried out. To do so, we need to add a custom property to the blueprint.

Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineProvisioned

For the value we can use either:

  • * – to pass all data
  • Property name – to pass only specific property

In addition, I have prepared two custom properties with predefined list of values and assigned them to the blueprint. The final Properties tab looks as follows:
Next we need to edit the Scriptable task in the vRO workflow and add the following code:

The for each cycle will print all properties and their values.
The last two lines will print only the specified properties.

Now, let’s request new VM from this blueprint, selecting values for the custom properties:
Once the VM is provisioned, we can check the workflow results:
As you can see, besides the custom added properties, there are multiple built in. It’s recommended to use specific prefix for the custom properties to avoid overlapping.

Having access to additional VM information can help you to further automate your VM provisioning activities.

Your ideas and comments are always welcome!

The following two tabs change content below.

Ivaylo Ivanov

Ivaylo has 5 years of professional IT experience. Most of it in server administration area, network and virtualization technologies. From 2014 he specializes in VMware products family. He holds VCIX6-DCV and VCP7-CMA certifications. vExpert 2016/2017

About Ivaylo Ivanov

Ivaylo has 5 years of professional IT experience. Most of it in server administration area, network and virtualization technologies. From 2014 he specializes in VMware products family. He holds VCIX6-DCV and VCP7-CMA certifications. vExpert 2016/2017
Bookmark the permalink.

One Comment

  1. Thanks Mate! as I finally started to play with vRA recently, was looking for the way how to execute command on the remote ssh host with some variables. Was surprised this isn’t there out of the box.

Leave a Reply