Thursday, May 26, 2016

Passing parameters from VRA and consuming them in VRO 7

If you have recently migrated to VRA 7 or planning too, you may be wondering how to get information from VRA into a VRO workflow.

In this blog post I will provide some information on deploying a VM with the new Event Broker feature of vRA 7 and then retrieving the VM details so that they can be used perhaps to update a CMDB or consumed and sent in an e-mail. 

The specific example below demonstrates how to update a DB with most of the typical VM details, it will give the VM a custom name, set snapshot policy limits, place the VM in a specific vSphere folder, apply an SDRS affinity group to the VM so that the built-in vSphere load balancing features maintain the VM in a specific site and then we finally log the requestId used by VRA. Now typically if you are coming from VRA 6 the request Id could be found indirectly using the __asd_catalogRequestId parameter, however in VRA 7 a VM request is now contained in what is known as a deployment which means we no longer use the __asd_catalogRequestId parameter to locate the request but rather we need to look for the root request Id of the deployment. ie. __Cafe.Root.Request.Id   

First step is to create a workflow and then configure an event subscription which will execute the workflow at a specific phase of the deployment. Our deployment will include 2 workflows which will run OnProvisionMachine ie. precisely Data > Lifecycle state > Lifecycle state event equals VMPSMasterWorkflow32.Requested.EVENT.OnProvisionMachine and Data > Lifecycle state > Lifecycle state phase equals EVENT
and our second workflow will run on Machine Provisioned ie. precisely Data > Lifecycle state > Lifecycle state name equals VMPSMasterWorkflow32.MachineProvisioned and Data > Lifecycle state > Lifecycle state phase equals POST
  
The complete list of possible states for which we can run the selected workflows is listed in the following link.


The two workflows will look as follows (EB Update Properties):
(EB Set DRS Group on MachineProvisioned):


In the first workflow we are going to set some of the VM properties so we will want to set them as soon as the request is submitted. So in the Get payload and executionContext script we have the following:

1 comment: