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 may 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 is shown below:
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)