vRA7 – Dynamically Provision to Clusters based on vROps Metrics

Hey Hey,

I have been asked this question quite a lot lately, How can I use the metrics in vROps to determine which cluster can be provisioned to. This is something that I have delivered for customers but never really demoed, because to do this correctly its quite complex and I nearly always leverage an information store of some kind. Like etcd a key value store. This is hard to have something you can download and try out show or reproduce unless you have the same kind of setup.

Today I have done a really quick and nasty version that will allow you to take it away and refine it for your environment or have a play if your interested in the idea.
I have added a video below for people who want to see it in action manipulating vROps to change the results and make sure it works correctly, as well as not wanting to read my really bad grammar/spelling.

vRA property.
To use this we need to set a property called __reservationPolicyID (thats 2 x _ ) in the property definitions, this can be further added to a property group if required.
Configure this as the below image, we are using an action which (i Hope) is available to download as part of the package at the bottom of this post.
Screenshot 2017-01-16 15.12.19

We then need to set this on the machine in the blueprint we are going to use. I have added mine to a property group that I was using for AWS reservations originally.
Screenshot 2017-01-16 15.17.35

vRO Action
Now to where the magic happens, the vRO action. to make this a lot simpler I am just calling a workflow and then using a simple case statement to choose which reservation policy has the most free resources. A better structure can be put in place, but I would need a days workshop to take everyone through the dozen actions and how vROps resources link up to vRA resources.
basically if you want this to be dynamic you would need to have the reservation policies to be named in such away the vROPs cluster resources could be derived, then you would search vROps for the cluster, get its vROps ID then you would request the metric you require. Or you could have all this in a a key value store and have another flow that grabs the updated metrics every 5 minutes etc.

But today we just have everything hard coded.
in the below image:
Red – This is just a property object that I have added in the vROps cluster name and its vROps ID
Black – Calling another action that grabs an attribute out of a configuration item (this is the workflow I will be running)
Green – Loops through the property created in Red and execures the workflow grabing the output. if the output is more (more capacity) write it to a variable.
Orange – Based on what has the highest capacity, return the corresponding vRA Reservation Policy ID.
Screenshot 2017-01-16 16.03.54.

Code
var clusterObject = new Properties();
var tempArray = [];
clusterObject.put("Virtualiseme","423e2e11-80dd-4cec-aa62-bf87826a872e");
clusterObject.put("AutoDeploy","17063b56-8a1c-4c65-bced-4c374513ffef");
var stat = null;
var preferredCluster;

var runWorkflow = System.getModule("virtualiseme.vro.configurations").getConfigurationAttributeValueByPath("virtualiseme","vROps Capacity","capacityWorkflow","Workflow");
for(obj in clusterObject){
var executionProperties = new Properties()
executionProperties.put('idValue',clusterObject[obj])
var currentToken = runWorkflow.execute(executionProperties);
var complete = false;
while(complete == false){
if(currentToken != null && (currentToken.state != "running" && currentToken.state != "waiting")){
System.log("Workflow '"+currentToken.name+"' terminated with status '"+currentToken.state+"'");
complete = true;
}
}
//get output from the workflow token
var outputPropertiesToken = currentToken.getOutputParameters()
System.log('outputPropertiesToken.keys: ' + outputPropertiesToken.keys)
System.log("outputPropertiesToken.get('statOutput'): " + outputPropertiesToken.get('statOutput'))
var tempStat = outputPropertiesToken.get('statOutput');
if(stat == null || tempStat > stat){
stat = tempStat;
preferredCluster = obj;
System.log(preferredCluster);
}

}

System.log(preferredCluster);

switch (preferredCluster.toUpperCase()) {
case "AUTODEPLOY":
tempArray.push("c4d45450-d44b-4154-bd1b-d3e54d0af0f2")
return tempArray;
case "VIRTUALISEME":
tempArray.push("8dbea13c-bce1-4812-8fce-187ed41cb200")
return tempArray;
}

vRO Workflow
The below workflow is pretty simple its just getting vROps token then we are really only making a rest call using a GET operation /suite-api/api/resources/stats/latest?resourceId={id}&statKey={stat} then I just pass the metric value out to the output as a string.
As you can see from the below image I have set the metric I will be using and the operation.
Screenshot 2017-01-16 16.25.41
Screenshot 2017-01-16 16.25.56

So if its all done correctly at deployment time we should get a dropdown (in this case with only one entry).

Screenshot 2017-01-16 16.30.41

Going forward I really dont like the standard forms and where possible I will try and front with XaaS, this reservation policy selection can be done within the XaaS form smartly if there is another component to choose from for example domain, I have had customers that had different subscriptions or clusters per domain. So using the domain selection I can choose the policy or policies to choose from. This could be taken further to check the available clusters or AWS subscriptions for capacity before submitting..

Above I have just used a cluster but this can go for reservation groups or even using the vRA plugin, either way the base is here and gives an idea on how to go forward with an enterprise level setup.

Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Anti SPAM BOT Question * Time limit is exhausted. Please reload CAPTCHA.