Understanding Workflow Parameters
Workflows that do not operate on input have limited scope; many workflows need to be parameterized to be useful. This is done by adding a parameters member to the global workflow object. The parameters member is in turn an object that is expected to have a member for each parameter. Each parameters member must have the following members:
Table 9-2 Required Workflow Parameters Members
| Required Member | Type | Description |
|---|---|---|
|
|
String |
Label to adorn input of workflow parameter |
|
|
String |
Type of workflow parameter |
The type member must be set to one of these types:
Table 9-3 Workflow Member Type Names
| Type Name | Description |
|---|---|
|
|
A boolean value |
|
|
One of a number of specified values |
|
|
An e-mail address |
|
|
A file to be transferred to the appliance |
|
|
A valid host, as either a name or dotted decimal |
|
|
A valid hostname |
|
|
A valid, available port |
|
|
An integer |
|
|
A network address |
|
|
A name of a network node |
|
|
An integer that is greater than or equal to zero |
|
|
Any number, including floating point |
|
|
A password |
|
|
POSIX permissions |
|
|
A port number |
|
|
A size |
|
|
A string |
|
|
A list of strings |
Example 9-3 Workflow Using Two Parameters
Based on the specified types, an appropriate input form will be generated upon execution of the workflow. For example, here is a workflow that has two parameters: the name of a business unit (to be used as a project), and the name of a share (to be used as the share name).
var workflow = {
name: 'New share',
description: 'Creates a new share in a business unit',
parameters: {
name: {
label: 'Name of new share',
type: 'String'
},
unit: {
label: 'Business unit',
type: 'String'
}
},
execute: function (params) {
run('shares select ' + params.unit);
run('filesystem ' + params.name);
run('commit');
return ('Created new share "' + params.name + '"');
}
};If you upload this workflow and execute it, you will be prompted with a dialog box to fill in the name of the share and the business unit. When the share has been created, a message will be generated indicating as much.