Assign a VM to a Rubrik slaDomain

Assign a VM to a Rubrik slaDomain

September 14, 2015 0 By Eric Shanks

This last post in the series shows you how Nick Colyer and I to tie everything together. If you want to just download the plugins and get started, please visit Github.com and import the plugins into your own vRealize Orchestrator environment.

Download the Plugin from Github

NOTE: The first version of this code has been refactored and migrated to Github in Rubrik’s Repository since the time of this initial writing

To recap where we’ve been, we:

  • Learned some basics about REST
  • Added Rest Hosts and Operations to vRO
  • Used REST to get Authentication Tokens for Rubrik
  • Used the Authentication Tokens to query for VMs in Rubrik

Now in this post we’ll take the VM we just queried for and assign it to an slaDomain (Backup Policy) for Rubrik. Finally, all of our workflows will be able to be used for a useful purpose!

RubrikAssignSLA-schema

 

Before we dive into the workflow we should setup our REST operations. In this case we’re using a PATCH operation on the /vm/{id} resource. Here we need to supply the Rubrik Virtual Machine ID that we found in our previous post.

GenerateWFfromRESTOp

The first step should look pretty familiar to you after reading the previous posts. We’re calling the Rubrik Authentication workflow to get us login to the Rubrik appliance. This should be old hat to you by now so I won’t repeat it in this post. The guts of this post are in the scripting piece which is where we will assign the virtual machine to the correct slaDomain.

Let’s take a quick look at the visual binding tab of the “AssignVMtoSLADomain” element. We’ve got two input parameters that we’ll either input manually each time we run the workflow, or pass from another workflow. These are the RubrikVM to which we’ll assign a policy, and the slaDomain which is the policy to be applied. The rest of the parameters that we pass to our REST call are things like the REST Operations, and the authentication token. As far as outputs are concerned, we are outputting the status of the REST call.
RubrikAssignSLA-visualbinding

 

The magic piece shows our REST call. Open the scripting tab and we find that we’re using the authentication token to do our REST call. We then do some formatting of the slaDomainID to put some quotes around it and then log our settings.

In the payload section we format the content of the REST call. We set the sladomain and then log more information. YOU CAN’T LOG TOO MUCH INFORMATION! After this we create a request by adding a new variable called request and we put the inParamaters values and the content. This will create our request with the RubrikVMID in the inParamatersValues, and the slaDomainID in the content parameter.

We modify the request types to “application/json” as the type of header’s we’re passing and then an additional header with our authentication token in it. The last section will then execute the request.

RubrikAssignSLA-scripting

 

When we actually execute this request we’ll need to select the virtual machine and an slaDomain. The slaDomain is a GUID so you’d need to lookup this information ahead of time, or run another workflow to find the slaDomain. Nick Colyer explains how to do this on his site SystemsGame.com if you’re interested. Otherwise you can find this information by looking at the Rubrik swagger-ui.

Summary

When you execute this workflow you’ll have to pass a few parameters such as Virtual Machine and slaDomain but when it executes it will tell the Rubrik appliance to start protecting a virtual machine under the policies of the slaDomain. This workflow is the first time in this series that an actual operation is performed that would be beneficial to a Systems Administrator that is managing an environment.

This series is here to explain how these pieces were put together and how they can be customized. Putting many of these workflows together can be incredibly useful to an automated environment. Think about the possibilities of deploy a new VM from vRealize Automation. After provisioning we can then pass the virtual machine parameters over to vRO and then automatically call the Rubrik REST api and protect this virtual machine by combining a few of the pieces we’ve just built. There are plenty of new possibilities like adding a day 2 operation to allow an end user to perform a Rubrik snapshot or restore from the vRA user portal, or through the vRO console.

If you want to use the plugins that Nick Colyer and I created, feel free to download them at Github and use them in your own environment.

Download the Plugin