Cohesity and vRealize Automation (vRA) Day 1

February 13, 2017


Adding all instances from vRA catalog request to protection job

By Dana Gertsch, Consultant, Kovarus

In my previous article, I discussed how to use the recently released Cohesity REST API to enable Backup as a Service (BaaS) within VMware vRealize Automation. In this article, I’ll discuss the workflow which adds all the virtual machine instances from a single vRA catalog item request.

I had to make some design decisions along the way. The main one was to either update the protection job every time a machine was ready, or wait until all the machines in a request where ready. One of my goals was to minimize the REST calls, so waiting until the entire request was complete made the most sense.

Here is a screenshot of the workflow. I’ll discuss the elements throughout this article.


My approach was to kill off every workflow run, except the first one. The Sleep element pauses the workflow for up to 10 seconds. Once awake, the workflow will Get properties from the EBS payload. I’m only concerned with the protection job name, and the request ID. They will be used by other elements down the line, and will be assigned to vRealize Orchestrator (vRO) attribute.

Then it checks to see if a vRO configuration element containing the rootRequestId exists. If it does, then the workflow ends with no other action taken. If the attribute doesn’t exist, it creates the record. Here is the logic to check the configuration element.

At this point I should only have a single workflow running. After creating a lock, I find the CatalogItemRequest, which is fed into a workflow which waits until the request is complete.

At this point we are ready to start communicating with Cohesity. They use a bearer token rather than the traditional username and password. The action cohesityGetBearerToken logs in and returns the token and is stored in a vRO attribute.

The element Get Protection Job returns the Cohesity ID for the vCenter managing the new VMs and the protection job Id, assigning them to a vRO attribute.

Refresh protection source is fired to force a Cohesity discovery of the new machines. The workflow then “Sleeps” for 60 seconds to allow the refresh to complete.

Now I’m ready to start the heavy lifting. coheistyGetVMNamesFromRequestResources action makes a REST call to vRA using the vCACCAFERestClient, and returns the names of all the VMs in the request.

Next we talk to Cohesity to obtain the name and protection source Id’s for each VM, using cohesityGetProtecionIdForVMsByName . This action returns a vRO Property Object which will be used to add the VMs to the Protection Job, and to update the vRA Entity.

Add VM's to Protection Group  makes two REST calls. The first get the protection job object which includes array of currently protected VMs (by ID). The new IDs are extracted from the Property Object, and the protection job object is updated (by adding the new machine IDs). The second REST call updates the protection job.

The last significant action cohesityUpdateEntityPropertiesOnCohesityRequest , uses the Property Object we created earlier to add custom properties to each VM. These properties are used by another workflow to remove the machine from the protection job when the machine is disposed.

The last two elements remove the configuration element holding the request Id, and releases the vRO lock.

This article covered a lot. The following examples were provided:

Cohesity REST API
Get Virtual Machine data
Force a vCenter data collection
Update a protection job with the new VMs

vRealize Automation
Monitored the Request state, waiting until it was complete
Used vCACCAFERestClient to get information about the resource request
Update the vCAC Entity with the protection job Id, and virtual machine Id

vRealize Orchestrator
Use Configuration Elements to store settings between workflow runs
Set and removed locks

Some additional integrations being finalized include: run protection job on demand, clone virtual machine, restore virtual machine, and add unprotected VM to protection job. The entire package including how to configure vRA should be publically available in the very near future.