Get Rubrik VM through vRealize OrchestratorSeptember 10, 2015
Part four of this series will show you how to lookup a VM in the Rubrik Hybrid Cloud appliance through the REST API by using vRealize Orchestrator. If you’d rather just download the plugin and get using it, check out the link to Github to get the plugin and don’t forget to check out Nick Colyer’s post over at systemsgame.com about how to use it.
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
Why do we need this workflow: Rubrik assigns a unique identifier to each virtual machine that it discovers from your vCenter inventory. If we want to perform any operations on this VM such as, adding it to an sladomain (backup policy), we need to be able pass over an Identifier to Rubrik that it understands. This workflow will take a vCenter object and retrieve the Rubrik VM ID that corresponds to it
INPUTS: VM in the VC:VirtualMachine format. This is a Virtual Machine Object from vCenter.
OUTPUTS: Status Codes and the RubrikVMID in a string (text) format.
If we take a quick glance at the vRealize Orchestrator Schema we’ll get a good idea about what’s about to happen. The first thing we do is to get the VMware Managed Object Reference (MOR) from vCenter. Next, we’re going obtain a Rubrik base64 token so that we can authenticate with the Hybrid Cloud Appliance and then eventually execute our REST call against the Rubrik appliance which is where we get our VM ID.
Prior to us jumping into the workflow, I want to take second to look at the REST Operation that we setup earlier. Just as a quick refresher, we previously added a REST operation for Get VM. If you want a quick reminder, we setup a GET operations on the /vm resource. We’ll use this operation in our workflow.
Let’s start at the beginning of our workflow. The first element in our schema is going to get the MOR from vCenter. We’re going to take the Virtual Machine as an input and our output is going to be just the MOR ID.
I wish that I could tell you this is an incredibly difficult operation that Nick and I spend days working just so that you didn’t have to, but really we’re just looking for the vm.id and saving it as a variable. We also log it if that makes you feel better about this element?
Next, we are going to call the workflow that we created earlier to obtain our Rubrik Token. I’m not going to walk through this whole piece again, but if you want a refresher, please take a look at the previous post. The main thing to remember here is that we’re sending a REST request to Rubrik to obtain a token or cookie so that we can issue further commands.
Now that we’ve got our token we can try to execute our desired command against the Rubrik appliance. In the “Get VMs from Rubrik” element, we are going to pass our RESTHost parameter to the next scripting element. The rest of the element inputs come from the previous elements in our workflow. Specifically, we need to pass the Rubrik Token and our MOR ID so that we can use it in our REST Calls.
Here is the magic piece to this workflow. In the scripting tab we specify all of our headers and payload for the REST Call. Notice that again, we set the request content type to “application/json” and our REST URL will be passed over from the REST operation we configured earlier.
Under the “Customize request” we create a new variable for our authentication token. This is the Token we retrieved earlier with the “Basic ” in front of it. We log the token in case we need to do further troubleshooting. Lastly, we make our requests and pass the header information over.
The result is returning a single VM ID from Rubrik that matches the Virtual Machine we selected in vCenter.
This workflow would likely make more sense to come from a cloud management platform such as vRealize Automation but if you want to test it out, just run the workflow from vRO. You’l be asked for the VM and in the logs will see the VM ID.
This is another intermediary step in getting our workflow to be something usable. We have not configured REST hosts and operations, retrieved Rubrik tokens for authentication purposes, and now can retrieve a VM ID. Our next step would be to retrieve the slaDomains.