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

label

String

Label to adorn input of workflow parameter

type

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

Boolean

A boolean value

ChooseOne

One of a number of specified values

EmailAddress

An e-mail address

File

A file to be transferred to the appliance

Host

A valid host, as either a name or dotted decimal

HostName

A valid hostname

HostPort

A valid, available port

Integer

An integer

NetAddress

A network address

NodeName

A name of a network node

NonNegativeInteger

An integer that is greater than or equal to zero

Number

Any number, including floating point

Password

A password

Permissions

POSIX permissions

Port

A port number

Size

A size

String

A string

StringList

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.