Ce message est également disponible en : Anglais
Today, on this blog post i will show you how to retrieve the NSX Edge Load Balancer VIP provisioned by vRA.
Currently i am using 3 VMware components in my LAB : vRealize Automation 7.0 , vRealize Orchestrator 7.0.1 and NSX 6.2.
I have created a blueprint for the provisioning of 2 VMs behind a load balancer.
In my lab, i want to retrieve all the load balancer’s VIP provisioned by vRA in NSX. I will used API call for this work and vRO script to achieve my goal.
So, the first thing to do :
In vRO you have to create a HTTP Rest HOST. In my exemple , it will be https://NSXMANAGER/API/
Create a new workflow and use a generic « Scriptable Task« . I will simply named it « Retrieve Edge ».
The only input that i will add on this generic scriptable task is the « rest host » (My NSX Manager).
In the « Scripting » tab, we will first retrieve all the Edge located in the NSX Manager. We will use this URL . https://NSXMANAGER/API/4.0/edges/
var request = restHost.createRequest("GET", "4.0/edges/"); //Get all Edge request.contentType = "application/xml"; System.log("Check all Edge - Request URL: " + request.fullUrl); //Display request URL var response = request.execute(); if(response.statusCode != 200) throw("Could not GET edge list ! : " + response.statusCode + "n" + response.contentAsString); var edgelistXML = new XML(response.contentAsString); //Convert response as String
Then, we have to create a list of Edges created by vRA. In this case, vRA create a description with the value « Edge provisioned and managed by VMware vRealize Automation ». So basically , we just have to found a match.
We will have a list of Edge’s ID provisioned by VRA.
// Get EdgeSummary node var EdgeList = edgelistXML.edgePage.edgeSummary; //Check for EdgeID provisioned by vRA. var EdgeID = []; for each (var edge in EdgeList) { if (edge.description.text() == "Edge provisioned and managed by VMware vRealize Automation") { EdgeID.push(edge.objectId.text().toString()); } } if (EdgeID.length == null) throw("No Edge found"); System.log("Edge-Id found :"+EdgeID);
Finally, if a match is found, we have to retrieve the VIP of our Edge based on our Edge ID. We have to call a « GET » on this URL : https://NSXMANAGER/API/4.0/edges/edge-id
//Check for VIP var EdgeIP = []; for each(var ID in EdgeID) { var request = restHost.createRequest("GET", "4.0/edges/"+ID); request.contentType = "application/xml"; System.log("Check VIP on Request URL: " + request.fullUrl); var response = request.execute(); if(response.statusCode != 200) throw("Could not GET edge from ID ! : " + response.statusCode + "n" + response.contentAsString); var edgeconfXML = new XML(response.contentAsString); EdgeIP.push(edgeconfXML.features.loadBalancer.virtualServer.ipAddress.text().toString()); } System.log("Edge IP :"+EdgeIP);
Then you will display the VIP of your NSX Edge Load Balancer provisioned by vRA.
On my next post, i will show you how to add a VM in a existing load balancer.