2. Auto-Scaling and Cloud Bursting : 2.6 Autoscaling and Bursting a vApp : 2.6.3 Push implementation Example
   
2.6.3 Push implementation Example
Some monitoring systems can call other systems, based on defined alarm rules. The advantage of the push system is that it sends alerts when needed, unlike the pull system, which might check when not needed yet not check when needed.
In this example, the F5 load balancer is configured to send SNMP alerts when the average server latency remains above or below one second for five minutes.
Figure 9. F5 SNMP Alert Rule Example
RAID:Users:christophe:Desktop:Screen Shot 2012-05-11 at 4.07.08 PM.png
 
The parsing of the strings in Figure 9 is used to start either an upscale or a downscale workflow. The vCenter Orchestrator SNMP plug-in can be configured with the load balancer hosts and have a policy listening for new traps, the script for which follows.
System.log("Agent: " + event.getValue("agent"));
var key = event.getValue("key");
var snmpResult = SnmpService.retrievePolicyData(key);
// Get data as Array of Properties
var data = System.getModule("com.vmware.library.snmp").processSnmpResult(snmpResult);
System.log("Enterprise: " + snmpResult.enterprise);
// Log data
System.getModule("com.vmware.library.snmp").logResult(data);
 
for each (var element in data) {
if (element.get("snmpType") == "Octet String") {
var value = element.get("value");
var ipPort = value.substring(value.indexOf("pool-member") + 12, value.length).split(" ")[0];
var ip = ipPort.split(":")[0];
var port = ipPort.split(":")[1];
System.log("ip : " + ip);
System.log("port : " + port);
if (value.indexOf("Workload-Analytics Average Server Latency below") > -1) {
//Downscaling
var workflowToLaunch = Server.getWorkflowWithId("7e81523f-1478-4b08-8a86-eb77b194c322");
if (workflowToLaunch == null) {
throw "Workflow not found";
}
var workflowParameters = new Properties();
workflowParameters.put("ip",ip);
workflowParameters.put("port",port);
var wfToken = workflowToLaunch.execute(workflowParameters);
}
if (value.indexOf("Workload-Analytics Average Server Latency above") > -1) {
//upscaling
var workflowToLaunch = Server.getWorkflowWithId("ae871d09-1bf5-4085-9505-c7281d0977d3");
if (workflowToLaunch == null) {
throw "Workflow not found";
}
var workflowParameters = new Properties();
workflowParameters.put("ip",ip);
workflowParameters.put("port",port);
var wfToken = workflowToLaunch.execute(workflowParameters);
}
}
}
 
The Upscale and burst a vApp and Downscale and Unburst a vApp both take the vApp name, tier, and virtual datacenter to burst to as inputs. The SNMP trap allows the IP address and port of the member server latency to be retrieved, so two wrapper workflows are used.
The following example depicts the wrapper workflow for the upscale provided in the
PSO/vCloud Director Auto scaling and bursting/Policy/SNMP folder.
Figure 10. Workflow Schema: Upscale and burst a vApp (member IP and port input)
 
2.6.3.1. Workflow Steps
1. Get an F5 iControl member object from the IP and port.
2. If found, get the Pool from the member. If not, log and exit.
3. Get the autoscale configuration name from the pool.
4. Start the upscale and burst workflow.
In the provided workflow, a preferred virtual datacenter is not passed as a parameter because it is optional and because a single pool is used in the test environment. It is possible, with an additional step in the workflow, to get the virtual datacenter that matches a given pool in the configuration to add capacity in priority where server latency is degraded and to remove capacity where it goes above expected performance.