Backup-as-a-Service with Cohesity and vRealize Automation

September 7, 2016


 

Moving a VM into a new Cohesity Protection Job

By Dana Gertsch, Consultant, Kovarus

Kovarus was recently approached by Cohesity to develop some sample vRealize Automation solutions to showcase the new REST API available in version 2.9.

One of the use cases was to move a previously deployed machine to another Protection Job. This blog discusses the steps necessary to create this Day 2 Resource Action in vRealize Automation.

In effect we needed to do the following:

  1. Capture and display the current Projection Job in the Request Form
  2. Provide the requester a dynamic list of available Protection Jobs to choose from
  3. Remove the VM from the original Protection Job
  4. Add the VM to the target (new) Protection Job
  5. Update the VM properties with the new Protection Job information (used to retire or remove the VM when the machine is destroyed)

Our solution used an existing vRealize Orchestrator (vRO) action to populate the drop-down list (to choose the new Protection Job), a new action to get the current Protection Job from the VM properties, and a new workflow to do the heavy lifting.

Our first action extracted the Cohesity Username, Password, and Cohesity RestHost from a vRO Configuration Element. These variables were used to login and get the Authorization Token required by the other REST calls. The following code snippet contains the important parts:

We are not going to discuss how to get the list of available Protection Jobs, but will show how to figure out what the REST call should look like. Cohesity has a nice development tool available via their GUI. Simply click on Help in the upper right hand corner, and then select REST API.

Backup-as-a-Service-1

Click on the ProtectionJobs Tag

Backup-as-a-Service-2

Under /public/ProtectionJobs (Should be the first Path listed), click on the “Try this operation” button near the bottom, then “Send Request” near the bottom.

If the response is successful, you should get some very useful information, including the REST URL, and an array containing all of your Protection Jobs.

BackupasaService3

Here is one of our Protection Jobs from the array in JSON format:

Our existing Action simply returns an Array of “name”, which we’ll use later to populate the XaaS form.

The second Action takes a VC:VirtualMachine as input, finds the vCACEntity, then returns the custom property holding the old Protection Job. The code is pretty straightforward.

The actual workflow that does the heavy lifting looks like this. It’s pretty complex, so we’ll discuss that in another post in the future. The workflow has two Input Parameters newJobName, and vm.

BackupasaService4

The next step is to setup the XaaS Resource Action in vRA. Create a new Resource Action, Select the Day 2 workflow and then click Next.

BackupasaService5

Click Next on the Input Resource page. On the Details page, change the Target criteria to match your environment, and then Click Next.

BackupasaService6

Our finished request form looks like this:

BackupasaService7

Current Job Name is populated with the action used to get the VM custom property, and New Protection Job is populated with the Get Protection Jobs Action. Now lets see this in action. Find your Cohesity protected Machine, and then click your Move to Protection Job action.

BackupasaService8

Enter something in the Description Field, and then click Next to get to the Form. Here you see which Protection Job the VM is part of, and a drop down list of the available jobs.

BackupasaService9

After making sure our vRA request completed successfully, we checked the target Protection Job to make sure the machine was moved.

BackupasaService10

The new Cohesity REST API coupled with vRealize Automation and vRealize Orchestrator should make day-to-day operations for your users much easier by greatly reducing the number of portals they have to access each day.

If you have any other questions about Cohesity, vRealize, and cloud automation or anything else; please do not hesitate to contact us.