Understanding Workflows
Understanding Workflows
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:
TABLE 125
Required Object Members
Required member Type Description
name
String Name of the workflow
description
String Description of workflow
execute
Function Function that executes the workflow
EXAMPLE 18
Hello World Workflow
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 Utilization
Workflows 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” on page 43), 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] + '%');
}
};
588 Oracle ZFS Storage Appliance Administration Guide, Release OS8.6.x • September 2016