Get expiration date of a vRA Request in a vRO EBS Workflow

A customer of mine wanted to do automatic documentation of deployed dev and test machines in vRA7, by creating a subpage in Confluence for each deployed machine.

One piece of information the customer wanted in the documentation was the initial expiration date of the deployed machine.

I wanted to do the documentation as part of one of the EBS lifecycle workflows in vRO.

But the expiration date is not in the Request, and it’s not in the Machine Properties. So after some digging I found out how to get it.

The below JavaScript code, which can be used in vRO needs a single input, namely of the vRA IaaS Host object in vRO (vCAC:VCACHost), in my example with the name of “vcacHost”.
The example just logs the Expiration Date to the System log in vRO, but you can grab it as a variable and use it further along in the vRO workflow if needed.

1
2
3
4
5
6
7
8
9
var vraIaasResourceId = System.getContext().getParameter("__asd_targetResourceId")

var filter = "VirtualMachineID eq guid'" + vraIaasResourceId + "'";

var virtualMachineEntity = (vCACEntityManager.readModelEntitiesBySystemQuery(vraIaasHost.id , "ManagementModelEntities.svc" , "VirtualMachines" , filter))[0]

var vraIaasVm = virtualMachineEntity.getInventoryObject()

System.log(vraIaasVm.expires)