Nutanix PRISM automated with the vRealize Orchestrator

As an Ex-VMware Specialist for Automation and Orchestration I could not resist to use the python task from the last blog post in vRealize Orchestrator (aka vCenter Orchestrator, aka Dunes). So I configured the actual Appliance which has the REST 1.0.3 Plug-In already installed. I just added the certificate (SSL Connections in configuration interface) for the Nutanix PRISM Portal and restarted the server.

After starting the vRO client the first thing to do is to add the REST Connection:

Add_REST_Host

As you can see, I only used the direct URL without any entities. After the REST connection is initially created you have to add a REST operation:

Add_REST_Operation

In my case I decided to use vms (you can use every entity that´s shown in the Nutanix PRISM REST Explorer). Now that there is a vms REST operation you can easily generate a REST workflow:

Generate_REST_Wf

I created a folder called “Nutanix” to hold all my workflows. After the generation you can immediately run the workflow and see the result: an endless JSON string 🙂

Whilst this is enough for seeing that you can have that information in a few minutes, I was interested to change the workflow to show only the protected VM´s and their power state. So I changed the first scripting task in:

//prepare request
//Do not edit 
var inParamtersValues = [];
var request = restOperation.createRequest(inParamtersValues, null);
//set the request content type
request.contentType = "";
System.log("Request: " + request);
System.log("Request URL: " + request.fullUrl);

//Customize the request here
//request.setHeader("headerName", "headerValue");

//execute request
//Do not edit 
var response = request.execute();
//prepare output parameters
System.log("Response: " + response);
statusCode = response.statusCode;
statusCodeAttribute = statusCode;
System.log("Status code: " + statusCode);
contentLength = response.contentLength;
headers = response.getAllHeaders();
contentAsString = response.contentAsString;
//System.log("Content as string: " + contentAsString);

jsonResult = JSON.parse(response.contentAsString)

for(i in jsonResult.entities){
	if(jsonResult.entities[i].protectionDomainName != null){
		System.log(jsonResult.entities[i].protectionDomainName);
		System.log(jsonResult.entities[i].vmName);
		System.log(jsonResult.entities[i].powerState);
	}
}

As you can see, I just skipped the unformatted System.log and parsed the JSON object directly with an undocumented!!! JSON method (Thanks Andreas!) in vRO. Afterwards the script checks for a protection group and if there is a value it just displays name and power state.

That´s a really basic and straightforward task to automate Nutanix PRISM with the vRealize Orchestrator.

Leave a Reply