A workflow is embodied in a valid ECMAscript file, containing a single global variable, workflow. This is an Object that must contain at least three members:
|
The following is an example of a basic workflow:
var workflow = { name: 'Hello world', description: 'Bids a greeting to the world', execute: function () { return ('hello world!') } };
Uploading this workflow will result in a new workflow named "Hello world"; executing the workflow will result in the output "hello world!"
Example 19 Using the Workflow Run Function to Return CPU UtilizationWorkflows execute asynchronously in the appliance shell, running (by default) as the user executing the workflow. As such, workflows have at their disposal the appliance scripting facility (see Working with CLI Scripting), and may interact with the appliance just as any other instance of the appliance shell. That is, workflows may execute commands, parse output, modify state, and so on. Here is a more complicated example that uses the run function to return the current CPU utilization:
var workflow = { name: 'CPU utilization', description: 'Displays the current CPU utilization', execute: function () { run('analytics datasets select name=cpu.utilization'); cpu = run('csv 1').split('\n')[1].split(','); return ('At ' + cpu[0] + ', utilization is ' + cpu[1] + '%'); } };