Vcenter Orchestrator 551 Developers Guide PDF
Vcenter Orchestrator 551 Developers Guide PDF
Orchestrator
vCenter Orchestrator 5.5.1
EN-001341-01
You can find the most up-to-date technical documentation on the VMware Web site at:
http://www.vmware.com/support/
The VMware Web site also provides the latest product updates.
If you have comments about this documentation, submit your feedback to:
[email protected]
Copyright 20082014 VMware, Inc. All rights reserved. Copyright and trademark information.
VMware, Inc.
3401 Hillview Ave.
Palo Alto, CA 94304
www.vmware.com
VMware, Inc.
Contents
Updated Information 9
1 Developing Workflows 11
VMware, Inc.
55
64
VMware, Inc.
Contents
103
121
2 Scripting 125
VMware, Inc.
157
Index 161
VMware, Inc.
Developing with VMware vCenter Orchestrator provides information and instructions for developing custom
Intended Audience
This information is intended for developers who want to create custom Orchestrator workflows and actions,
as well as custom building blocks.
VMware, Inc.
VMware, Inc.
Updated Information
Developing with VMware vCenter Orchestrator is updated with each release of the product or when necessary.
This table provides the update history of Developing with VMware vCenter Orchestrator.
Revision
Description
EN-001341-01
Added Maven Archetypes, on page 158 and Plug-In Development Best Practices, on page 158.
EN-001341-00
Initial release.
VMware, Inc.
10
VMware, Inc.
Developing Workflows
You develop workflows in the Orchestrator client interface. Workflow development involves using the
workflow editor, the built-in Mozilla Rhino JavaScript scripting engine, and the Orchestrator and vCenter
Server APIs.
n
VMware, Inc.
11
12
VMware, Inc.
Workflow Parameters
Workflows receive input parameters and generate output parameters when they run.
Input Parameters
Most workflows require a certain set of input parameters to run. An input parameter is an argument that the
workflow processes when it starts. The user, an application, another workflow, or an action passes input
parameters to a workflow for the workflow to process when it starts.
For example, if a workflow resets a virtual machine, the workflow requires as an input parameter the name
of the virtual machine.
Output Parameters
A workflow's output parameters represent the result from the workflow run. Output parameters can change
when a workflow or a workflow element runs. While workflows run, they can receive the output
parameters of other workflows as input parameters.
For example, if a workflow creates a snapshot of a virtual machine, the output parameter for the workflow
is the resulting snapshot.
Workflow Attributes
Workflow elements process data that they receive as input parameters, and set the resulting data as
workflow attributes or output parameters.
Read-only workflow attributes act as global constants for a workflow. Writable attributes act as a
workflows global variables.
You can use attributes to transfer data between the elements of a workflow. You can obtain attributes in the
following ways:
n
VMware, Inc.
13
Workflow Schema
A workflow schema is a graphical representation that shows the workflow as a flow diagram of
interconnected workflow elements. The workflow schema is the most important element of a workflow as it
determines its logic.
Workflow Presentation
When users run a workflow, they provide the values for the input parameters of the workflow in the
workflow presentation. When you organize the workflow presentation, consider the type and number of
input parameters of the workflow.
Workflow Tokens
A workflow token represents a workflow that is running or has run.
A workflow is an abstract description of a process that defines a generic sequence of steps and a generic set
of required input parameters. When you run a workflow with a set of real input parameters, you receive an
instance of this abstract workflow that behaves according to the specific input parameters you give it. This
specific instance of a completed or a running workflow is called a workflow token.
Create a new workflow or create a duplicate of an existing workflow from the standard library.
Lay out and link the workflow schema to define the logical flow of the workflow.
Bind the input and output parameters of each schema element to workflow attributes.
Write the necessary scripts for scriptable task elements or custom decision elements.
Create the workflow presentation to define the layout of the input parameters dialog box that the users
see when they run the workflow.
14
VMware, Inc.
To allow you to access the Orchestrator client, the administrator must either add you to the Orchestrator
administrator LDAP group, or set View, Inspect, Edit, Execute, or Admin permissions to a group that you
are a member of.
Create a Workflow
You can create workflows in the workflows hierarchical list of the Orchestrator client.
Procedure
1
(Optional) Right-click the root of the workflows hierarchical list, or a folder in the list, and select Add
folder to create a new workflow folder.
Right-click the new folder or an existing folder and select New workflow.
VMware, Inc.
15
Edit a Workflow
You edit a workflow to make changes to an existing workflow or to develop a new empty workflow.
Procedure
1
Expand the workflows hierarchical list to navigate to the workflow that you want to edit.
To open the workflow for editing, right-click the workflow and select Edit.
(Optional) Right-click the root of the hierarchical list of workflow folders and select New folder to
create a folder to contain the workflow to edit.
Expand the Library hierarchical list of standard workflows to navigate to the workflow to edit.
Click the Workflow folder value to search for a folder in which to save the duplicate workflow.
Select the folder you created in Step 3. If you did not create a folder, select a folder that is not in the
library of standard workflows.
10
16
Description
Yes
No
VMware, Inc.
11
You duplicated a workflow from the standard library. You can edit the duplicate workflow.
Description
General
Inputs
Outputs
Schema
Presentation
Define the layout of the user input dialog box that appears
when users run a workflow. You arrange the parameters
and attributes into presentation steps and groups to ease
identification of parameters in the input parameters dialog
box. You define the constraints on the input parameters
that users can provide in the presentation by setting the
parameter properties.
Parameters References
Workflow Tokens
Events
Permissions
VMware, Inc.
17
Click the Version digits to set a version number for the workflow.
The Version Comment dialog box opens.
Type a comment for this version of the workflow and click OK.
For example, type Initial creation if you just created the workflow.
A new version of the workflow is created. You can later revert the state of the workflow to this version.
Define how the workflow behaves if the Orchestrator server restarts by setting the Server restart
behavior value.
n
Leave the default value of Resume workflow run to make the workflow resume at the point at
which its run was interrupted when the server stopped.
Click Resume workflow run and select Do not resume workflow run (set as FAILED) to prevent
the workflow from restarting if the Orchestrator server restarts.
Prevent the workflow from restarting if the workflow depends on the environment in which it runs. For
example, if a workflow requires a specific vCenter Server and you reconfigure Orchestrator to connect
to a different vCenter Server, restarting the workflow after you restart the Orchestrator server causes
the workflow to fail.
5
You defined aspects of the workflow behavior, set the version, and defined the operations that users can
perform on the workflow.
What to do next
You must define the workflow attributes and parameters.
18
VMware, Inc.
(Optional) To change the value of the parameter type, click the value and select one from the list of
available values.
The value for the parameter type is String by default.
(Optional) If you decide that the parameter should be an attribute rather than a parameter, right-click
the parameter and select Move as attribute to change the parameter into an attribute.
VMware, Inc.
19
Procedure
1
Click the attribute type to select a new type from a list of possible values.
The default attribute type is String.
Click the attribute value to set or select a value according to the attribute type.
If the attribute is a constant rather than a variable, click the check box to the left of the attribute name to
make its value read-only.
The lock icon identifies the column of read-only check boxes.
(Optional) If you decide that the attribute should be an input or output parameter rather than an
attribute, right-click the attribute and select Move as INPUT/OUTPUT parameter to change the
attribute into a parameter.
20
VMware, Inc.
abstract
back_char_esc
back_char_literal
boolean
byte
char
char_literal
class
_classResolver
const
context
debugger
dec_digits
dec_flt
default
delete
digit
double
dynamic_subscript
enum
Forbidden Keyword
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
eof
esc
exponent
export
extends
false
final
flt_literal
flt_suff
ident
implements
import
in
int
int_literal
interface
_keepLastEvaluation
_lastEvaluation
letter
long
Forbidden Keyword
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
_memberAccess
native
package
private
public
root
short
static
string_esc
string_literal
synchronized
this
_traceEvaluations
true
_typeConverter
volatil
with
WithinBackCharLiteral
WithinCharLiteral
WithinStringLiteral
Workflow Schema
A workflow schema is a graphical representation of a workflow that shows the workflow as a flow diagram
of interconnected workflow elements. The workflow schema defines the logical flow of a workflow.
n
Decisions on page 36
Workflows can implement decision functions that define different courses of action according to a
Boolean true or false statement.
VMware, Inc.
21
Drag a schema element from the Generic menu in the left pane, to the workflow schema.
Double-click the element you dragged to the workflow schema, type an appropriate name, and press
Enter.
You must provide elements with unique names in the context of the workflow.
You cannot rename Waiting timer, Waiting event, End workflow, or Throw exception elements.
22
VMware, Inc.
Drag schema elements from the Basic, Log, or Network menus to the workflow schema.
You can edit the names of the elements in the Basic, Log, or Network menus. You cannot edit their
scripting.
Drag schema elements from the Generic menu to the workflow schema.
When you drag actions or workflows to the workflow schema, a dialog box in which you can search for
the action or workflow to insert appears.
In the Filter text box, type the name or part of the name of the workflow or action to insert in the
workflow.
The workflows or actions that match the search appear in the dialog box.
10
Repeat this procedure until you have added all of the required schema elements to the workflow
schema.
What to do next
Define the properties of the elements you added to the workflow schema and link and bind them all
together.
From the left pane, select the workflow from which you want to copy schema elements.
Click All Workflows and select the workflow from the hierarchical list of workflows.
Type the name of the workflow in the search text box and press Enter.
Select one or more workflow schema elements, right-click the selection, and select Copy.
In the Schema tab of the workflow that you are editing, right-click and select Paste.
VMware, Inc.
23
What to do next
You must link and bind the copied schema elements to the existing workflow schema.
Description
Input
Skip
Value
The argument is mapped to an attribute with a value that you can set from
the Value column.
Description
Output
Skip
Local variable
Click Promote.
24
VMware, Inc.
Procedure
1
(Optional) If you are editing a workflow in the workflow editor, click Save and Close to exit the editor.
From the Orchestrator client menu, select Tools > User preferences.
Type the number of results for searches to return in the Finder Maximum Size text box.
Schema Elements
The workflow editor presents the workflow schema elements in menus in the Schema tab.
You can use the schema elements available in the Schema tab to build a workflow.
Table 13. Schema Elements and Icons
Schema Element
Name
Description
Icon
Location in Workflow
Editor
Start Workflow
Scriptable task
Decision
Custom decision
Decision activity
VMware, Inc.
25
26
Description
Icon
Location in Workflow
Editor
User interaction
Waiting timer
Waiting event
End workflow
Thrown exception
Workflow note
VMware, Inc.
Description
Icon
Location in Workflow
Editor
Action element
Workflow element
Foreach element
Asynchronous
workflow
Schedule workflow
VMware, Inc.
27
Description
Icon
Location in Workflow
Editor
Nested workflows
Pre-Defined Task
).
28
VMware, Inc.
Provide a name for the schema element in the Name text box.
This is the name that appears in the schema element in the workflow schema diagram.
(Optional) Provide a business status description in the Business Status text box.
The Business Status property is a brief description of what this element does. When a workflow is
running, the workflow token shows the Business Status of each element as it runs. This feature is useful
for tracking workflow status.
(Optional) In the Description text box, type a description of the schema element.
Description
Attributes
User Interaction
Waiting Event
Waiting Timer
Decision
Decision
End Workflow
Exception
n
n
n
n
n
n
n
n
n
n
n
External Inputs
VMware, Inc.
End
Exception
Action
Asynchronous Workflow
Exception
Nested Workflows
Predefined Task
Schedule Workflow
Scriptable Task
User Interaction
Waiting Event
Waiting Timer
Workflow
User Interaction
29
Description
IN
n
n
n
n
n
n
n
Info
n
n
n
n
n
n
n
n
n
n
n
n
n
OUT
Presentation
Scripting
Visual Binding
Workflows
30
Shows a graphical
representation of how the
parameters and attributes of
this schema element bind to the
parameters and attributes of the
elements that come before and
after it in the workflow. This is
another representation of the
element's IN and OUT
bindings.
Selects the workflows to nest.
n
n
n
n
n
n
Action
Asynchronous Workflow
Custom Decision
Predefined Task
Schedule Workflow
Scriptable Task
Workflow
Action
Asynchronous Workflow
Custom Decision
Decision
Nested Workflows
Note
Predefined Task
Schedule Workflow
Scriptable Task
User Interaction
Waiting Event
Waiting Timer
Workflow
Action
Asynchronous Workflow
Predefined Task
Schedule Workflow
Scriptable Task
Workflow
User Interaction
n
n
n
n
n
n
n
n
n
n
n
n
Action
Asynchronous Workflow
Custom Decision
Predefined Task
Schedule Workflow
Scriptable Task
Action
Asynchronous Workflow
Predefined Task
Schedule Workflow
Scriptable Task
Workflow
Nested Workflows
VMware, Inc.
A blue arrow denotes the standard path that the workflow takes from one element to the next.
A green arrow denotes the path that the workflow takes if a Boolean decision element returns true.
A red dotted arrow denotes the path that the workflow takes if a Boolean decision element returns
false.
n
A red dashed arrow denotes the exception path that the workflow takes if a workflow element does not
run correctly.
The following figure shows an example workflow schema that demonstrates the different paths that
workflows can take.
Figure 11. Different Workflow Paths Through the Logical Flow of the Workflow
VMware, Inc.
31
This example workflow can take the following paths through its logical flow.
n
Element Links
Links connect schema elements and define the logical flow of the workflow from one element to the next.
Elements can usually set only one outgoing link to another element in the workflow and one exception link
to an element that defines its exception behavior. The outgoing link defines the standard path of the
workflow. The exception link defines the exception path of the workflow. In most cases, a single schema
element can receive incoming standard path links from multiple elements.
The following elements are exceptions to the preceding statements.
n
The Start Workflow element cannot receive incoming links and has no exception link.
Exception elements can receive multiple incoming exception links, and have no outgoing or exception
links.
Decision elements have two outgoing links that define the paths the workflow takes depending on the
decision's true or false result. Decisions have no exception link.
32
VMware, Inc.
Verify that the Schema tab of the workflow editor contains elements.
Procedure
1
Place the pointer on the element that you want to connect to another element.
A blue and a red arrow appear on the element's right.
Left-click the blue arrow, hold down the left mouse button, and move the pointer to the target element.
A blue arrow appears between the two elements and a green rectangle appears around the target
element.
VMware, Inc.
33
34
The first element processes parameter a and binds the result of the processing to workflow attribute c.
The first element processes parameter b and binds the result of the processing to workflow attribute d.
The second element takes workflow attribute c as an input parameter, processes it, and binds the
resulting output parameter to workflow attribute e.
The second element takes workflow attribute d as an input parameter, processes it, and generates
output parameter f.
The workflow ends and generates workflow attribute f as its output parameter, the result of its run.
VMware, Inc.
Element Bindings
You must bind all workflow element input and output parameters to workflow attributes. Bindings set data
in the elements, and define the output and exception behavior of the elements. Links define the logical flow
of the workflow, whereas bindings define the data flow.
To set data in an element, generate output parameters from the element after processing, and handle any
errors that might occur when the element runs, you must set the element binding.
IN bindings
Set a schema element's incoming data. You bind the element's local input
parameters to source workflow attributes. The IN tab lists the element's
input parameters in the Local Parameter column. The IN tab lists the
workflow attributes to which the local parameter binds in the Source
Parameter column. The tab also displays the parameter type and a
description of the parameter.
OUT bindings
Exception bindings
IN bindings read values from the bound source parameter. OUT bindings write values into the bound source
parameter.
You must use IN bindings to bind every attribute or input parameter you use in a schema element to a
workflow attribute. If the element changes the values of the input parameters that it receives when it runs,
you must bind them to a workflow attribute by using an OUT binding. Binding the element's output
parameters to workflow elements lets other elements that follow it in the workflow schema to take those
output parameters as their input parameters.
A common mistake when creating workflows is to not bind output parameter values to reflect the changes
that the element makes to the workflow attributes.
IMPORTANT When you add an element that requires input and output parameters of a type that you have
already defined in the workflow, Orchestrator sets the bindings to these parameters. You must verify that
the parameters that Orchestrator binds are correct, in case the workflow defines different parameters of the
same type to which the element can bind.
VMware, Inc.
35
If you selected a predefined task, workflow, or action element, the IN tab lists the possible local
input parameters for that type of element, but the binding is not set.
If you selected another type of element, you can select from a list of input parameters and
attributes you already defined for the workflow by right-clicking in the IN tab and selecting Bind
to workflow parameter/attribute.
If the required attribute does not exist yet, you can create it by right-clicking in the IN tab and
selecting Bind to workflow parameter/attribute > Create parameter/attribute in workflow.
If an appropriate parameter exists, choose an input parameter to bind, and click the Not set button in
the Source Parameter text box.
A list of possible source parameters and attributes to bind to appears.
Choose a source parameter to bind to the local input parameter from the list proposed.
(Optional) If you have not defined the source parameter to which to bind, you can create it by clicking
the Create parameter/attribute in workflow link in the parameter selection dialog box.
If you selected a predefined task, workflow, or action element, the OUT tab lists the possible local
output parameters for that type of element, but the binding is not set.
If you selected another type of element, you can select from a list of output parameters and
attributes you defined for the workflow by right-clicking in the OUT tab and selecting Bind to
workflow parameter/attribute.
If the required attribute does not exist, you can create it by right-clicking in the IN tab and selecting
Bind to workflow parameter/attribute > Create parameter/attribute in workflow.
10
(Optional) If you did not define the parameter to which to bind, you can create it by clicking the Create
parameter/attribute in workflow button in the parameter selection dialog box.
You defined the input parameters that the element receives and the output parameters that it generates, and
bound them to workflow attributes and parameters.
What to do next
You can create forks in the path of the workflow by defining decisions.
Decisions
Workflows can implement decision functions that define different courses of action according to a Boolean
true or false statement.
Decisions are forks in the workflow. Workflow decisions are made according to inputs provided by you, by
other workflows, by applications, or by the environment in which the workflow is running. The value of the
input parameter that the decision element receives determines which branch of the fork the workflow takes.
For example, a workflow decision might receive the power status of a given virtual machine as its input. If
the virtual machine is powered on, the workflow takes a certain path through its logical flow. If the virtual
machine is powered off, the workflow takes a different path.
36
VMware, Inc.
Decisions are always Boolean functions. The only possible outcomes for each decision are true or false.
Custom Decisions
Custom decisions differ from standard decisions in that you define the decision statement in a script.
Custom decisions return true or false according to the statement you define, as the following example
shows.
if (decision_statement){
return true;
}else{
return false;
}
Place the mouse pointer on a decision element to link it to two other elements that define two possible
branches in the workflow.
A blue arrow and a red arrow appear on the element's right.
Place the pointer on the blue arrow, and while keeping the left mouse button pressed, move the pointer
to the target element.
A green arrow appears between the two elements and the target element turns green. The green arrow
represents the true path the workflow takes if the input parameter or attribute received by the decision
element matches the decision statement.
Place the pointer on the decision element, hold down the left mouse button, and move the pointer to the
target element.
A dotted red arrow appears between the two elements and the target element turns green. The red
arrow represents the false path that the workflow takes if the input parameter or attribute received by
the decision element does not match the decision statement.
You have defined the possible true or false paths that the workflow takes depending on the input
parameter or attribute the decision element receives.
What to do next
Define the decision statement. See Create Workflow Branches Using Decisions, on page 38.
VMware, Inc.
37
Description
Success branch
The decision element and all elements that follow the true decision path
are deleted from the workflow schema.
Failure branch
The decision element and all elements that follow the false decision path
are deleted from the workflow schema.
Both branches
The decision element and all elements that follow both decision paths are
deleted from the workflow schema.
None
Only the decision element and its links are deleted from the workflow
schema. All elements that follow both decision paths remain in the
workflow schema.
Click OK.
A dialog box that lists the properties of the decision element appears.
2
Click the Not Set (NULL) link to select the source input parameter for this decision.
A dialog box that lists all the attributes and input parameters defined in this workflow appears.
38
If you did not define the source parameter to which to bind, create it by clicking the Create
attribute/parameter in workflow link in the parameter selection dialog box.
VMware, Inc.
You defined a statement for the decision element. When the decision element receives the input parameter,
it compares the value of the input parameter to the value in the statement and determines whether the
statement is true or false.
What to do next
You must set how the workflow handles exceptions.
Exception Handling
Exception handling catches any errors that occur when a schema element runs. Exception handling defines
how the schema element behaves when the error occurs.
All elements in a workflow, except for decisions and start and end elements, contain a specific output
parameter type that serves only for handling exceptions. If an element encounters an error during its run, it
can send an error signal to an exception handler. Exception handlers catch the error and react according to
the errors they receive. If the exception handlers you define cannot handle a certain error, you can bind an
element's exception output parameter to an Exception element, which ends the workflow run in the failed
state.
Exceptions act as a try and catch sequence within a workflow element. If you do not need to handle a given
exception in an element, you do not have to bind that element's exception output parameter.
The output parameter type for exceptions is always an errorCode object.
Place the pointer on the element for which you want to define exception binding.
A blue and a red arrow appear on the element's right.
Place the pointer on the red arrow until it enlarges, hold down the left mouse button, and drag the red
arrow to the target element.
A red dashed arrow links the two elements. The target element defines the behavior of the workflow if
the element that links to it encounters an error.
Click the Exceptions tab in the schema element properties tabs at the bottom of the Schema tab.
VMware, Inc.
39
Click the Not set button to set the Output Exception Binding value.
n
Select a parameter to bind to the exception output parameter from the exception attribute binding
dialog box.
Click the target element that defines the exception handling behavior.
Click the IN tab in the schema element properties tabs at the bottom of the Schema tab.
10
Click the OUT tab for the exception handling element in the schema element properties tabs at the
bottom of the Schema tab
11
Right-click in the OUT tab and select Bind to workflow parameter/attribute to select an output
parameter for the exception handling element to generate.
Click the Scripting tab and use JavaScript to define the behavior of the exception handling element.
40
VMware, Inc.
For example, suppose that you are about to rename a virtual machine. You need the virtual machine object
and its new name. If you have to rename multiple virtual machines, you need two arrays, one for the virtual
machines and one for their names. These two arrays are not explicitly connected. A composite type lets you
have one array where each element contains both the virtual machine and its new name. In this way, the
connection between those two parameters in case of multiple values is specified explicitly and not implied
by the workflow schema.
NOTE You cannot run a workflow that contains composite types from an Orchestrator Web view or from
the vSphere Web Client.
From the Generic menu, drag a Foreach element in the workflow schema.
Description
Input
Skip
Value
The argument is mapped to an attribute with a value that you can set from
the Value column.
Description
Output
Skip
Local variable
Click Promote.
Right-click the Foreach element and select Synchronize > Synchronize presentation.
A confirmation dialog box appears.
VMware, Inc.
41
Click Ok to propagate the presentation of the Foreach element to the current workflow.
A dialog box displays information about the outcome of the operation.
10
On the Inputs tab, verify that the subworkflow's parameters are added as elements of type array.
11
On the Outputs tab, verify that the subworkflow's parameters are added as elements of type array.
You defined a Foreach element in your workflow. The Foreach element runs a workflow that takes as
parameters every element from the array of parameters or attributes that you have defined.
For parameters or attributes that are not defined as arrays, the workflow takes the same value in every
subsequent run.
Example: Rename Virtual Machines by Using a Foreach Element
You can use a Foreach element to rename several virtual machines at once. You have to insert a Foreach
element in a workflow and promote the vm and the newName parameters as input to the current workflow. In
this way, when you run the workflow, you specify the virtual machines to rename and the new names for
the virtual machines. The virtual machines are included as elements in the array that you created for the vm
parameter. The new names for the virtual machines are included in the array that you created for the
newName parameter.
Procedure
1
Select a local parameter that you want to group with other local parameters in a composite type.
Click Bind a group of parameters as composite value at the top of the IN or the OUT tab.
In the Bindings pane, select the parameters that you want to group as a composite type.
Click Accept.
You defined a composite type and made sure that the workflow will iterate over an array of this composite
type. Parameters that are grouped as a composite type are named composite_type_name.parameter_name. For
example, if you create a snapshots composite type, the parameters that are group in the type can be
snapshots.vm[in-parameter] or snapshots.name[in-parameter]. Every element from the array of the
composite type contains a single instance of every parameter that you grouped in the composite type.
Example: Rename Virtual Machines
Suppose that you want to rename 10 virtual machines at a time. For this, you insert a Foreach element in a
workflow and select the Rename virtual machine workflow in the element. You create a composite type to
connect the vm and the newName parameters explicitly. You bind the composite type as an iterator, thus
creating a single array that contains both the vm and the newName parameter.
42
VMware, Inc.
Creating the Input Parameters Dialog Box In the Presentation Tab on page 43
You define the layout of the dialog box in which users provide input parameters when they run a
workflow in the Presentation tab of the workflow editor.
Presentation Descriptions
You can add an associated description for each parameter or group of parameters, which appears in the
input parameters dialog box. The descriptions provide information to the users to help them provide the
correct input parameters. You can enhance the layout of the description text by using HTML formatting.
VMware, Inc.
43
Procedure
1
Click the input step and add a description in the General tab in the bottom half of the Presentation tab.
This description appears in the input parameters dialog box to provide information to the users to help
them provide the correct input parameters. You can enhance the layout of the description text by using
HTML formatting.
Right-click the input step you created and select Create display group.
A New Group node appears under the input step node.
Provide an appropriate name for the display group and press Enter.
This name appears as a subsection header in the input parameters dialog box when the workflow runs.
Click the display group and add a description in the General tab in the bottom half of the Presentation
tab.
This description appears in the input parameters dialog box. You can enhance the layout of the
description text by using HTML formatting. You can add a parameter value to a group description by
using an OGNL statement, such as ${#param}.
Repeat the preceding steps until you have created all the input steps and display groups to appear in
the input parameters dialog box when the workflow runs.
Drag parameters from under the Presentation node to the steps and groups of your choice.
You created the layout of the input parameters dialog box through which users provide input parameter
values when the workflow runs.
What to do next
You must set the parameter properties.
44
VMware, Inc.
Procedure
1
Select a property from the list presented in the dialog box and click OK.
The property appears in the Properties tab.
Under Value, make the property value either static or dynamic by selecting the corresponding symbol
from the drop-down menu.
Option
Description
Static property
Dynamic property
If you set the property value to static, you select a property value according to the type of parameter for
which you are setting the properties.
VMware, Inc.
45
If you set the property value to dynamic, you define the function to obtain the parameter property
value by using an OGNL expression.
The workflow editor provides help writing the OGNL expression.
a
Click the
icon to obtain a list of all the attributes and parameters defined by the workflow that
this expression can call upon.
Click the
icon to obtain a list of all the actions in the Orchestrator API that return an output
parameter of the type for which you are defining the properties.
Clicking items in the proposed lists of parameters and actions adds them to the OGNL expression.
9
46
Parameter Property
Parameter Type
Description
String
String
String
Number
Number
Number format
Number
Mandatory input
Predefined answers
VMware, Inc.
Parameter Type
Description
Matching expression
Show in inventory
Select as
Default value
Custom validation
Data binding
Authorized only
Description
${#__current}
${#__username}
${#__userdisplayname}
${#__serverurl}
${#__datetime}
${#__date}
${#__timezone}
Current timezone
VMware, Inc.
47
Create the Input Parameters Dialog Box for the User Interaction on page 55
Users provide input parameters during a workflow run in an input parameters dialog box, in the same
way that they provide input parameters when a workflow first starts.
48
VMware, Inc.
Create a workflow.
Procedure
1
Drag a User Interaction element to the appropriate position in the workflow schema.
Click the User Interaction element to display its properties tabs in the bottom half of the Schema tab.
Provide a name and a description for the user interaction in the Info tab and click Close.
Click Save.
You added a user interaction element to a workflow. When the workflow reaches this element, it waits for
information from the user before continuing its run.
What to do next
Set the security.group attribute of the user interaction to limit permission to respond to the user
interaction to a user or user group. See Set the User Interaction security.group Attribute, on page 49.
Create a workflow.
Procedure
1
Click Not set for the security.group source parameter to set which users can respond to the user
interaction.
(Optional) Select NULL to allow all users to respond to the request for user interaction.
To limit the permission to respond to a specific user or user group, click Create parameter/attribute in
workflow.
The Parameter information dialog box opens.
VMware, Inc.
49
Select Create workflow ATTRIBUTE with the same name to create the LdapGroup attribute in the
workflow.
Click Not set for the parameter value to open the LdapGroup selection box.
Type the name of the LDAP user group in the Filter text box.
10
Select the LDAP user group from the list and click Select.
For example, selecting the Administrators group means that only members of that group can respond
to this request for user interaction.
You limited the permission to respond to the user interaction request.
11
To set the timeout to an absolute date and time, see Set the timeout.date Attribute to an Absolute
Date, on page 50.
To create a function to calculate a timeout that is relative to the current date and time, see Calculate a
Relative Timeout for User Interactions, on page 51.
Procedure
1
Click Not set for the timeout.date source parameter to set the timeout parameter value.
(Optional) Select NULL to allow the user interaction to set the workflow to wait indefinitely for the user
to respond to the user interaction.
Click Create parameter/attribute in workflow to set the workflow to fail after a timeout period.
The Parameter information dialog box opens.
50
Select Create workflow ATTRIBUTE with the same name to create a Date attribute in the workflow.
VMware, Inc.
Use the calendar to select an absolute date and time until which the workflow waits for the user to
respond.
10
11
You set the timeout.date attribute to an absolute date. The workflow times out if the user does not respond
to the user interaction before this time and date.
What to do next
Define the external input parameters that the user interaction requires from the user. See Define the
External Inputs for a User Interaction, on page 53.
Procedure
1
2
3
4
5
VMware, Inc.
Drag a Scriptable task element from the Generic menu to the schema of a workflow, before the element
that requires the relative Date object for its timeout.date attribute.
Click the Edit icon (
Provide a name and description for the scripted workflow element in the Info properties tab.
Click the OUT properties tab, and click the Bind to workflow parameter/attribute icon (
).
Leave the attribute value set to Not set, because a scripted function will provide this value.
Click OK.
51
Define a function to calculate and generate a Date object named timerDate in the scripting pad in the
Scripting tab.
For example, you can create a Date object by implementing the following JavaScript function, in which
the timeout period is a relative delay in milliseconds.
timerDate = new Date();
System.log( "Current date : '" + timerDate + "'" );
timerDate.setTime( timerDate.getTime() + (86400 * 1000) );
System.log( "Timer will expire at '" + timerDate + "'" );
The preceding example JavaScript function defines a Date object that obtains the current date and time
by using the getTime method and adds 86,400,000 milliseconds, or 24 hours. The Scriptable Task
element generates this value as its output parameter.
8
Click Close.
Click Save.
You created a function that calculates a time and date relative to the current time and date and generates a
Date object. A User Interaction element can receive this Date object as an input parameter to set the timeout
period until which it waits for input from the user. When the workflow arrives at the User Interaction
element, it suspends its run and waits either until the user provides the required information, or for 24
hours before it times out.
What to do next
You must bind the Date object to the User Interaction element's timeout.date parameter. See Set the
timeout.date Attribute to a Relative Date, on page 52.
Create a scripted function that calculates a relative time and date and encapsulates it in a Date object in
the workflow. See Calculate a Relative Timeout for User Interactions, on page 51.
Procedure
1
Click Not set for the timeout.date source parameter to set the timeout parameter value.
Select the Date object that encapsulates a relative time and date that you defined in a scripted function
and click Select.
You set the timeout.date attribute to a relative date and time that a scripted function calculates.
52
VMware, Inc.
What to do next
Define the external input parameters that the user interaction requires from the user. See Define the
External Inputs for a User Interaction, on page 53.
Procedure
1
2
3
(Optional) If you already defined the input parameters in the workflow, select the parameters from the
proposed list.
Click Create parameter/attribute in workflow to create a workflow attribute to bind to the input
parameter that the user provides.
Select the input parameter type from the list of types by searching for an object type in the Filter box.
For example, if the user interaction requires the user to provide a virtual machine as an input
parameter, select VC:VirtualMachine.
Select Create workflow ATTRIBUTE with the same name to bind the input parameter that the user
provides to a new attribute in the workflow.
10
You defined the input parameters that the user provides during a user interaction.
What to do next
Define the exception behavior if the user interaction encounters an error. See Define User Interaction
Exception Behavior, on page 54.
VMware, Inc.
53
Set the security.group and timer.date attributes for the user interaction.
Procedure
1
Click Create parameter/attribute in workflow to create an exception attribute to which to bind the user
interaction.
The Parameter information dialog box opens.
Name: errorCode
Type: string
Drag a scriptable task element over the user interaction element in the workflow schema.
A red dashed arrow, which represents the exception link, appears between the two elements. The
scriptable task element binds automatically to the errorCode attribute from the user interaction.
In the Scripting tab of the scriptable task element, write a JavaScript function to handle the exception.
For example, to record the timeout in the Orchestrator log, write the following function:
System.log("No response from user. Timed out.");
10
Link and bind the scriptable task element that handles exceptions to the element that follows it in the
workflow.
For example, link and bind the scriptable task element to a Throw exception element to end the
workflow with an error.
You defined the exception behavior if the user interaction times out.
54
VMware, Inc.
What to do next
Create the dialog box in which users provide input parameters. See Create the Input Parameters Dialog
Box for the User Interaction, on page 55.
Create the Input Parameters Dialog Box for the User Interaction
Users provide input parameters during a workflow run in an input parameters dialog box, in the same way
that they provide input parameters when a workflow first starts.
You create the layout of the dialog box in the Presentation tab of the user interaction element, not in the
Presentation tab for the whole workflow. The Presentation tab of the whole workflow creates the layout of
the input parameters dialog box that appears when you start a workflow. The Presentation tab of the user
interaction element creates the layout of the input parameters dialog box that opens when a workflow
arrives at a user interaction element during its run.
Prerequisites
n
Set the security.group and timer.date attributes for the user interaction.
Procedure
1
2
(Optional) Right-click the Presentation node in the Presentation tab and select Create new step.
Steps allow you to create sections in the dialog box, with descriptions and headings under which you
can organize the input parameters.
(Optional) Right-click the Presentation node in the Presentation tab and select Create display group.
Display groups allow you to sort the order in which input parameters appear in the steps, and allow
you to add sub-headers and instructions to the dialog box.
Click an input parameter in the list and add a description of the input parameter in the General tab for
that parameter.
The description text that you type appears as a label in the input parameters dialog box to inform the
user of the information they must provide when they respond to the user interaction.
You created the input parameters dialog box in which users provide input parameters to respond to a user
interaction during a workflow run.
What to do next
For information about creating the presentation steps and groups and setting input parameter properties,
see Creating the Input Parameters Dialog Box In the Presentation Tab, on page 43.
VMware, Inc.
55
Follow the instructions in the input parameters dialog box to provide the information that the workflow
requires.
You provided information to a workflow that was waiting for user input during its run.
56
VMware, Inc.
Prerequisites for Calling a Remote Workflow from Within Another Workflow on page 61
If the workflow that you develop calls another workflow that resides on a remote Orchestrator server,
certain prerequisites must be fulfilled so that the remote workflow can run successfully.
Asynchronous
Workflows
Scheduled Workflows
VMware, Inc.
A workflow can call a workflow but defer starting that workflow until a later
time and date. The calling workflow then continues its run until it ends.
Calling a scheduled workflow creates a task to start that workflow at the
given time and date. When the calling workflow has run, you can view the
scheduled workflow in the Scheduler and My Orchestrator views in the
Orchestrator client.
57
Scheduled workflows only run once. You can schedule a workflow to run
recurrently by calling the Workflow.scheduleRecurrently method in a
scriptable task element in a synchronous workflow.
Nested Workflows
Navigate to the workflow you changed in the hierarchical list in the Workflows view in the
Orchestrator client.
Right-click the workflow, and select References > Find Elements that Use this Element.
A list of workflows that call this workflow appears.
Double-click a workflow in the list to highlight it in the Workflows view in the Orchestrator client.
Right-click the workflow element for the changed workflow from the workflow schema and select
Synchronize > Synchronize Parameters.
10
11
Repeat Step 5 to Step 10 for all the workflows that use the modified workflow.
58
VMware, Inc.
Right-click the workflow that you want to modify and select Edit.
The workflow editor opens.
Right-click the element of the child workflow whose input parameters and presentation you want to
propagate to the parent workflow and select Synchronize > Synchronize Presentation.
(Optional) Repeat Step 4 and Step 5 for all child workflows whose input parameters and presentation
you want to propagate to the parent workflow.
The input parameters of the child workflows are added to the input parameters of the parent workflow. The
presentation of the parent workflow is extended with the presentations of the child workflows.
Procedure
1
Drag a Workflow element from the Generic menu to the appropriate position in the workflow schema.
The Choose workflow selection dialog box appears.
Search for ands select the workflow you want and click OK.
If the search returns a partial result, narrow your search criterion or increase the number of search
results from the Tools > User preferences menu in the client.
3
4
Click the Workflow element to show its properties tabs in the bottom half of the Schema tab.
Click the Edit icon (
Bind the required input parameters to the workflow in the IN tab of the workflow schema element.
Bind the required output parameters to the workflow in the OUT tab of the workflow schema
element's.
Click Close.
VMware, Inc.
59
You called a workflow synchronously from another workflow. When the workflow reaches the synchronous
workflow during its run, the synchronous workflow starts, and the initial workflow waits for it to complete
before continuing its run.
What to do next
You can call a workflow asynchronously from a workflow.
Procedure
1
Drag an Asynchronous Workflow element from the Generic menu to the appropriate position in the
workflow schema.
The Choose workflow selection dialog box appears.
2
3
Search for and select the desired workflow from the list and click OK.
Click the Edit icon (
Bind the required input parameters to the workflow in IN tab of the asynchronous workflow element.
Bind the required output parameter in the OUT tab of the asynchronous workflow element.
You can bind the output parameter either to the called workflow, or to that workflow's result.
n
Bind to the workflow token of the called workflow to return the result of running the called
workflow.
Define the exception behavior of the asynchronous workflow element in the Exceptions tab.
Click Close.
You called a workflow asynchronously from another workflow. When the workflow reaches the
asynchronous workflow during its run, the asynchronous workflow starts, and the initial workflow
continues its run without waiting for the asynchronous workflow to finish.
What to do next
You can schedule a workflow to start at a later time and date.
Schedule a Workflow
You can call a workflow from a workflow and schedule it to start at a later time and date.
You schedule workflows in another workflow by using the Schedule Workflow element.
60
VMware, Inc.
Prerequisites
n
Procedure
1
Drag a Schedule Workflow element from the Generic menu to the appropriate position in the
workflow schema.
Search for the workflow to call by typing part of its name in the text box.
4
5
Click Not set for the workflowScheduleDate parameter to set the parameter.
Click Create parameter/attribute in workflow to create the parameter and set the parameter value.
Use the calendar that appears to set the date and time to start the scheduled workflow and click OK.
10
Bind the remaining input parameters to the scheduled workflow in the IN tab of the scheduled
workflow element.
11
Bind the required output parameters to the Task object in the OUT tab of the scheduled workflow
element.
12
Define the exception behavior of the scheduled workflow element in the Exceptions tab.
13
Click Close.
14
You scheduled a workflow to start at a given time and date from another workflow.
What to do next
You can call multiple workflows simultaneously from a workflow.
All input parameters of the remote workflow must be resolvable on the remote Orchestrator server.
All output parameters of the remote workflow must be resolvable on the local Orchestrator server.
To ensure that the parameters of the remote workflow are resolvable, the inventory objects that the
workflow uses must be available both in the remote and the local Orchestrator servers. In case the remote
workflow uses objects from a plug-in, the same plug-in must be available on both Orchestrator servers. The
inventories of the remote plug-in and the local plug-in must be identical. In case the remote workflow uses
system objects in Orchestrator, like workflows and actions, the same workflows and actions must exist in
the inventories of the remote and the local Orchestrator servers.
VMware, Inc.
61
For example, suppose that you insert the Rename virtual machine workflow in a Nested Workflow element
in the Test workflow that you develop. You want to run the Rename virtual machine workflow in a remote
Orchestrator server. When you run the Test workflow, the Rename virtual machine workflow is called
within the run of the Test workflow. You specify a virtual machine to rename from the inventory of the local
Orchestrator server. Because the Rename virtual machine workflow runs on the remote Orchestrator server,
the same virtual machine must be available in the inventory of that server. Otherwise, the Rename virtual
machine workflow cannot resolve its vm input parameter. Therefore, the vCenter Server plug-in on the local
and the remote Orchestrator servers must be connected to the same vCenter Server instance.
Procedure
1
Drag a Nested Workflows element from the Action & Workflow menu to the appropriate position in
the workflow schema.
The Choose workflow selection dialog box appears.
2
3
4
Set the IN and OUT bindings for this workflow in the IN and OUT tabs in the right panel of the
Workflows schema element properties tab.
Click the Connection Info tab in the right panel of the Workflows schema element properties tab.
The Connection Info tab allows you to access workflows stored in a different server to the local one,
using the appropriate credentials.
To access workflows on a remote server, select Remote and click Not set to provide a host name or IP
address for the remote server.
NOTE You can use the vCenter Orchestrator Multi-Node plug-in to call workflows on a remote server.
62
Select Inherit to use the same credentials as the user who runs the calling workflow.
Select Dynamic and click Not set to select a set of dynamic credentials that a parameter of the
credentials type defines elsewhere in the workflow.
Select Static and click Not set to enter the credentials directly.
VMware, Inc.
Click the Add Workflow button in the Workflows tab to select more workflows to add to the nested
workflow element.
10
Repeat Step 2 to Step 8 to define the settings for each of the workflows you add.
11
Run the Library > vCenter > Batch > Run a workflow on a selection of objects workflow.
Create a workflow that calls the Library > Orchestrator > Start workflows in a series or Start
workflows in parallel workflows.
Create a workflow that obtains an array of objects and runs a workflow on each object in the array in a
loop of workflow elements.
Run a workflow from JavaScript by calling the Workflow.execute() method in a For loop in a scripted
element in a workflow.
Which method you choose to run a workflow on a selection of objects depends on the workflow to run and
can affect the performance of the workflow. For example, running the Run a workflow on a selection of
objects workflow is the simplest way to run a workflow on multiple objects and requires no workflow
development, but it can only run workflows that take a single input parameter.
Creating a workflow that calls the Start workflows in a series or Start workflows in parallel workflows
allows you to run on multiple objects workflows that take more than one input parameter. The calling
workflow must create a properties array to pass the input parameters to the Start workflows in a series or
Start workflows in parallel workflow. These workflows are only for use in other workflows. Do not run
them directly.
Running a workflow in a For loop in a scripted element is faster than running a workflow in a loop of
workflow elements, but it is less flexible and limits the potential for reuse. Most importantly, running a
workflow in a scripted loop loses the checkpointing that Orchestrator performs when it starts each element
in a workflow run. As a consequence, if the Orchestrator server stops while the scripted loop is running,
when the server restarts, the workflow will resume at the beginning of the scripted element, repeating the
whole loop. If the Orchestrator server stops while running a workflow with a loop of workflow elements,
the workflow will resume at the specific element in the loop that was running when the server stopped.
For more information about the Batch workflows, see Using VMware vCenter Orchestrator Plug-Ins.
How to create a workflow that runs a workflow on an array of objects in a loop of workflow elements is
demonstrated in Develop a Complex Workflow, on page 104.
How to run a workflow in a scripted For loop is demonstrated in Workflow Scripting Examples, on
page 138.
VMware, Inc.
63
In the workflow schema, add a scriptable task element or an action to obtain a list of objects on which to
run the workflow.
For example, to run a workflow on all the virtual machines in a virtual machine folder, you can add the
getAllVirtualMachinesByFolder action to the workflow.
Link the scripted element or action and bind the input and output of the scripted element or action to
workflow inputs or attributes.
For example, you can bind the vmFolder input of the getAllVirtualMachinesByFolder action to a
workflow input parameter and the actionResult output to a workflow attribute in the calling
workflow.
Add a scriptable task element to cast the list of objects into a properties array.
For example, if the objects on which to run the workflow are an array of virtual machines, allVMs,
returned by the actionResult output of the getAllVirtualMachinesByFolder action, you can write the
following script to cast the objects into a properties array.
propsArray = new Array();
for each (var vm in allVMs) {
var prop = new Properties();
prop.put("vm", vm);
propsArray.push(prop);
}
Bind the inputs and outputs of the scriptable task element to workflow attributes.
In the example scriptable task element in Step 3, you bind the input to the allVMs array of virtual
machines and you create the propsArray output attribute as an array of Properties objects.
64
Select either of the Start workflows in a series or Start workflows in parallel workflows and link the
workflow element to the other elements.
VMware, Inc.
Bind the wf input of the Start workflows in a series or Start workflows in parallel workflow to the
workflow to run on the objects.
For example, to remove any snapshots of all the virtual machines returned by the
getAllVirtualMachinesByFolder action, select the Remove all snapshots workflow.
Bind the parameters input of the Start workflows in a series or Start workflows in parallel workflow to
the array of Properties objects that contains the objects on which to run the workflow.
For example, bind the parameters input to the propsArray attribute defined in Step 4.
(Optional) Bind the workflowTokens output of the Start workflows in a series or Start workflows in
parallel workflow to an attribute in the workflow.
10
(Optional) Continue adding more elements that use the results of running the Start workflows in a
series or Start workflows in parallel workflow.
You created a workflow that uses either of the Start workflows in a series or Start workflows in parallel
workflows to run a workflow on a selection of objects.
Set a timer, encapsulated in a Date object, that suspends the workflow until a certain time and date. You
implement long-running workflow elements that are based on a timer by including a Waiting Timer
element in the schema.
Define a trigger event, encapsulated in a Trigger object, that restarts the workflow after the trigger
event occurs. You implement long-running workflow elements that are based on a trigger by adding a
Waiting Event element or a User Interaction element in the schema.
Create a workflow.
VMware, Inc.
65
Procedure
1
2
3
4
5
Drag a Scriptable task element from the Generic menu to the schema of a workflow, before the element
that requires the relative Date object for its timeout.date attribute.
Click the Edit icon (
Provide a name and description for the scripted workflow element in the Info properties tab.
Click the OUT properties tab, and click the Bind to workflow parameter/attribute icon (
).
Leave the attribute value set to Not set, because a scripted function will provide this value.
Click OK.
Define a function to calculate and generate a Date object named timerDate in the scripting pad in the
Scripting tab.
For example, you can create a Date object by implementing the following JavaScript function, in which
the timeout period is a relative delay in milliseconds.
timerDate = new Date();
System.log( "Current date : '" + timerDate + "'" );
timerDate.setTime( timerDate.getTime() + (86400 * 1000) );
System.log( "Timer will expire at '" + timerDate + "'" );
The preceding example JavaScript function defines a Date object that obtains the current date and time
by using the getTime method and adds 86,400,000 milliseconds, or 24 hours. The Scriptable Task
element generates this value as its output parameter.
8
Click Close.
Click Save.
You created a function that calculates and generates a Date object. A Waiting Timer element can receive this
Date object as an input parameter, to suspend a long-running workflow until the date encapsulated in this
object. When the workflow arrives at the Waiting Timer element, it suspends its run and waits for 24 hours
before continuing.
What to do next
You must add a Waiting Timer element to a workflow to implement a long-running workflow that is based
on a timer.
66
Create a workflow.
VMware, Inc.
Procedure
1
Drag a Waiting Timer element from the Generic menu to the position in the workflow schema at which
to suspend the workflow's run.
If you implement a scriptable task to calculate the time and date, this element must precede the Waiting
Timer element.
Provide a description of the reason for implementing the timer in the Info properties tab.
Click the timer.date parameter's Not set button to bind the parameter to an appropriate Date object.
The Waiting Timer selection dialog box opens, presenting a list of possible bindings.
Select a predefined Date object from the proposed list, for example one defined by a Scriptable
Task element elsewhere in the workflow.
Alternatively, create a Date object that sets a specific date and time for the workflow to await.
(Optional) Create a Date object that sets a specific date and time that the workflow awaits.
a
Click Create parameter/attribute in workflow in the Waiting Timer selection dialog box.
The Parameter information dialog box appears.
Click the Value property's Not set button to set the parameter value.
A calendar appears.
Use the calendar to set a date and time at which to restart workflow.
Click OK.
Click Close.
You defined a timer that suspends a timer-based long-running workflow until a set time and date.
What to do next
You can create a long-running workflow that waits for a trigger event before continuing.
VMware, Inc.
67
Create a workflow.
In the workflow, declare a VC:Task object as an attribute or input parameter, such as a VC:Task object
from a workflow or workflow element that starts or clones a virtual machine.
Procedure
1
Drag a Scriptable Task element from the Generic menu into the schema of a workflow.
One of the elements that precedes the Scriptable Task must generate a VC:Task object as its output
parameter.
Provide a name and description for the trigger in Info properties tab.
).
(Optional) Select or create an input parameter of the Number type to define a timeout period in
seconds.
).
68
VMware, Inc.
10
11
12
The createEndOfTaskTrigger() method returns a Trigger object that monitors a VC:Task object named
task.
13
Click Close.
14
You defined a workflow element that creates a trigger event for a trigger-based long-running workflow. The
trigger element generates a Trigger object as its output parameter, to which a Waiting Event element can
bind.
What to do next
You must bind this trigger event to a Waiting Event element in a trigger-based long-running workflow.
Create a workflow.
Procedure
1
Drag a Waiting Event element from the Generic menu to the position in the workflow schema at which
you want to suspend the workflow's run.
The scriptable task that declares the trigger must immediately precede the Waiting Event element.
2
3
VMware, Inc.
Provide a description of the reason for the wait in the Info properties tab.
69
Click the trigger.ref parameter's Not set link to bind the parameter to an appropriate Trigger object.
The Waiting Event selection dialog box opens, presenting a list of possible parameters to which to bind.
Click Close.
You defined a workflow element that suspends a trigger-based long-running workflow, that waits for a
specific trigger event before restarting.
What to do next
You can run a workflow.
Configuration Elements
A configuration element is a list of attributes you can use to configure constants across a whole Orchestrator
server deployment.
All the workflows, actions, policies, and Web views running in a particular Orchestrator server can use the
attributes you set in a configuration element. Setting attributes in configuration elements lets you make the
same attribute values available to all the workflows, actions, policies, and Web views running in the
Orchestrator server.
If you create a package containing a workflow, action, policy, or Web view that uses an attribute from a
configuration element, Orchestrator automatically includes the configuration element in the package. If you
import a package containing a configuration element into another Orchestrator server, you can import the
configuration element attribute values as well. For example, if you create a workflow that requires attribute
values that depend on the Orchestrator server on which it runs, setting those attributes in a configuration
element lets you to export that workflow so that another Orchestrator server can use it. Configuration
elements therefore allow you to exchange workflows, actions, policies, and Web views between servers
more easily.
NOTE You cannot import values of a configuration element attribute from a configuration element exported
from Orchestrator 5.1 or earlier.
70
Right-click a folder in the hierarchical list of folders and select New folder to create a new folder.
VMware, Inc.
Increment the version number by clicking the version digits in the General tab and providing a version
comment.
Provide a description of the configuration element in the Description text box in the General tab.
10
11
Click the attribute values under Name, Type, Value, and Description to set the attribute name, type,
value, and description.
12
13
14
Search for a user group in the Filter text box and select the relevant user group from the proposed list.
15
Check the appropriate check boxes to set the access rights for the selected user group.
You can set the following permissions on the configuration element.
Permission
Description
View
Users can view the configuration element, but cannot view the schemas or
scripting.
Inspect
Users can view the configuration element, including the schemas and
scripting.
Admin
Execute
Edit
16
Click Select.
17
You defined a configuration element that sets common attributes across an Orchestrator server.
What to do next
You can use the configuration element to provide attributes to workflows or actions.
The user can view the elements in the workflow, but cannot view the schema
or scripting.
Inspect
The user can view the elements in the workflow, including the schema and
scripting.
Execute
VMware, Inc.
71
Edit
Admin
The user can set permissions on the workflow and has all other permissions.
The Admin permission includes the View, Inspect, Edit, and Execute permissions. All the permissions
require the View permission.
If you do not set any permissions on a workflow, the workflow inherits the permissions from the folder that
contains it. If you do set permissions on a workflow, those permissions override the permissions of the
folder that contains it, even if the permissions of the folder are more restrictive.
Create a workflow.
Procedure
1
2
3
Select a user group and select the appropriate check boxes to set the level of permissions for this user
group.
To allow a user from this user group to view the workflow, inspect the schema and scripting, run and
edit the workflow, and change the permissions, you must select all check boxes.
Click Select.
The user group appears in the permissions list.
Validating Workflows
Orchestrator provides a workflow validation tool. Validating a workflow helps identify errors in the
workflow and checks that the data flows from one element to the next correctly.
When you validate a workflow, the validation tool creates a list of any errors or warnings. Clicking an error
in the list highlights the workflow element that contains the error.
If you run the validation tool in the workflow editor, the tool provides suggested quick fixes for the errors it
detects. Some quick fixes require you to provide additional information or input parameters. Other quick
fixes resolve the error for you.
Workflow validation checks the data bindings and connections between elements. Workflow validation
does not check the data processing that each element in the workflow performs. Consequently, a valid
workflow can run incorrectly and produce erroneous results if a function in a schema element is incorrect.
72
VMware, Inc.
By default, Orchestrator always performs workflow validation when you run a workflow. You can change
the default validation behavior in the Orchestrator client. See Testing Workflows During Development, on
page 15. For example, sometimes during workflow development you might want to run a workflow that
you know to be invalid, for testing purposes.
Right-click the workflow and select Edit to open the workflow editor.
If you agree with the proposed quick fix action, click it to perform that action.
If you disagree with the proposed quick fix action, close the Workflow Validation dialog box and
fix the schema element manually.
IMPORTANT Always check that the fix that Orchestrator proposes is appropriate.
For example, the proposed action might be to delete an unused attribute, when in fact that attribute
might not be bound correctly.
9
Repeat the preceding steps until you have eliminated all validation errors.
VMware, Inc.
73
Debugging Workflows
Orchestrator provides a workflow debugging tool. You can debug a workflow to inspect the input and
output parameters and attributes at the start of any activity, replace parameter or attribute values during a
workflow run in edit mode, and resume a workflow from the last failed activity.
You can debug workflows from the standard workflow library and custom workflows. You can debug
custom workflows while developing them in the workflow editor.
Debug a Workflow
You can debug elements of a workflow by adding breakpoints to the elements in the workflow schema.
When a breakpoint is reached, you have several options to continue the debugging process. When you
debug an element from the workflow schema, you can view general information about the workflow run,
modify the workflow variables, and view log messages.
Prerequisites
Log in to the Orchestrator client as a user who can run workflows.
Procedure
1
Select a workflow from the workflow library and click the Schema tab.
To add breakpoints to the schema elements that you want to debug, right-click a workflow element and
select Toggle breakpoint.
You can enable or disable the toggled breakpoints.
).
When the workflow run is paused after it reaches a breakpoint, select one of the available options.
Option
Resume
Step into
Step over
Step return
Description
Resumes the workflow run until another breakpoint is reached.
Lets you step into a workflow element.
NOTE You cannot step into a nested workflow element when you debug a
workflow in the workflow editor.
Steps over the current element in the schema and pauses the workflow run
on the next element.
Exits the workflow element that you have stepped into.
74
VMware, Inc.
Log in to the Orchestrator client as a user who can run Mail workflows.
Procedure
1
Select the Example interaction with email workflow and click the Schema tab.
Right-click the Email Send (Interaction) workflow element and select Toggle breakpoint.
6
7
).
Select an LDAP group of users who are authorized to answer the query.
Click Submit.
).
10
In the toAddress text box, type the correct recipient address value.
For example, [email protected].
11
The workflow uses the value that you provided during the debugging process and continues the workflow
run.
Running Workflows
An Orchestrator workflow runs according to a logical flow of events.
When you run a workflow, each schema element in the workflow runs according to the following sequence.
1
The workflow binds the workflow token attributes and input parameters to the schema element's input
parameters.
The schema element's output parameters are copied to the workflow token attributes and workflow
output parameters.
The workflow token attributes and output parameters are stored in the database.
VMware, Inc.
75
This sequence repeats for each schema element until the end of the workflow.
End of Workflow
The workflow ends if the current active schema element is an end element. After the workflow reaches an
end element, other workflows or applications can use the workflow's output parameters.
Create a workflow.
Procedure
1
Click Run.
Run a Workflow
You can perform automated operations in vCenter Server by running workflows from the standard library
or workflows that you create.
For example, you can create a virtual machine by running the Create simple virtual machine workflow.
Prerequisites
Verify that you have configured the vCenter Server plug-in. For details, see Installing and Configuring
VMware vCenter Orchestrator.
Procedure
76
From the drop-down menu in the Orchestrator client, select Run or Design.
In the workflows hierarchical list, open Library > vCenter > Virtual machine management > Basic to
navigate to the Create simple virtual machine workflow.
VMware, Inc.
Right-click the Create simple virtual machine workflow and select Start workflow.
Provide the following information into the Start workflow input parameters dialog box to create a
virtual machine in a vCenter Server connected to Orchestrator.
Option
Action
a
b
Memory size in MB
Click the Not Set link and select a guest operating system from the list.
Click Not set for the Host on which to create the virtual machine value
and navigate through the vCenter Server infrastructure hierarchy to a host
machine.
Resource pool
Click Not set for the Resource pool value and navigate through the
vCenter Server infrastructure hierarchy to a resource pool.
Click Not set for the The network to connect to value and select a
network.
Press Enter in the Filter text box to see all the available networks.
Click Not set for the Datastore in which to store the virtual machine
value and navigate through the vCenter Server infrastructure hierarchy to
a datastore.
Click the workflow token to view the status of the workflow as it runs.
Click the Events tab in the workflow token view to follow the progress of the workflow token until it
completes.
10
Navigate through the vCenter Server infrastructure hierarchy to the resource pool you defined.
If the virtual machine does not appear in the list, click the refresh button to reload the inventory.
The orchestrator-test virtual machine is present in the resource pool.
11
(Optional) Right-click the orchestrator-test virtual machine in the Inventory view to see a contextual
list of the workflows that you can run on the orchestrator-test virtual machine.
VMware, Inc.
77
Expand the workflows hierarchical list to navigate to the workflow for which you want to set the
behavior.
78
On the General tab, select an option from the Resume from failed behavior drop-down menu.
Option
Description
System default
Enabled
Disabled
VMware, Inc.
On the Orchestrator server system, navigate to the folder that contains configuration files.
Option
Action
Go to
install_directory\VMware\Infrastructure\Orchestrator\appserver\conf.
Go to install_directory\VMware\Orchestrator\app-server\conf.
Go to /etc/vco/app-server/.
Set Orchestrator to resume failed workflow runs by editing the following line in the vmo.properties
file.
com.vmware.vco.engine.execute.resume-from-failed=true
Set a custom timeout period for resuming failed workflow runs by editing the following line in the
vmo.properties file.
com.vmware.vco.engine.execute.resume-from-failed.timeout-sec=<seconds>
The value you set overrides the default timeout setting of 86400 seconds.
5
From the drop-down menu in the pop-up window, select Resume and click Next.
If you select Cancel, the workflow run cannot be resumed later.
Click Submit.
VMware, Inc.
79
From the drop-down menu in the Orchestrator client, select Run or Design.
Navigate to the workflow or workflow folder for which you want to generate documentation and rightclick it.
Browse to locate the folder in which to save the PDF file, provide a file name, and click Save.
The PDF file containing the information about the selected workflow, or the workflows in the folder, is
saved on your system.
Click the General tab in the workflow editor and click Show version history.
Select a workflow version and click Diff Against Current to compare the differences.
A window displays the differences between the current workflow version and the selected workflow
version.
80
VMware, Inc.
Select a workflow version and click Revert to restore the state of the workflow.
CAUTION If you have not saved the current workflow version, it is deleted from the version history and
you cannot revert back to the current version.
The workflow state is reverted to the state of the selected version.
From the drop-down menu in the Orchestrator client, select Run or Design.
Navigate to the workflow folder in which you want to restore deleted workflows.
Select the workflow or workflows that you want to restore and click Restore.
Prompts the user for an email address to which it can send notifications.
Sends a request to the vCenter Server instance to start the virtual machine.
Waits for vCenter Server to start the virtual machine, and returns an error if the virtual machine fails to
start or if starting the virtual machine takes too long.
Waits for vCenter Server to start VMware Tools on the virtual machine, and returns an error if the
virtual machine fails to start or if starting VMware Tools takes too long.
Sends a notification to the provided email address, informing that the machine has started or that an
error occurred.
The ZIP file of Orchestrator examples available for download from the landing page of the Orchestrator
documentation contains a complete version of the Start VM and Send Email workflow.
The process for developing the example workflow consists of several tasks.
Prerequisites
Before you attempt to develop the simple example workflow, read Key Concepts of Workflows, on
page 13.
VMware, Inc.
81
Procedure
1
Set the Read-Write Properties for Attributes of the Simple Workflow Example on page 100
You can define whether parameters and attributes are read-only constants or writeable variables. You
can also set limitations on the values that users can provide for input parameters.
10
11
Set the Layout of the Simple Workflow Example Input Parameters Dialog Box on page 102
You create the layout or presentation of the input parameters dialog box in the workflow editor. The
input parameters dialog box opens when users run a workflow that needs input parameters to run.
12
82
VMware, Inc.
vCenter Server, controlling some virtual machines, at least one of which is powered off
For information about how to install and configure vCenter Server, see the vSphere Installation and Setup
documentation. For information about how to configure Orchestrator to use an SMTP server, see Installing
and Configuring VMware vCenter Orchestrator.
To write a workflow, you must have an Orchestrator user account with at least View, Execute, Inspect, Edit,
and preferably Admin permissions on the server or on the workflow folder in which you are working.
Procedure
1
Right-click the root of the workflows list and select Add folder.
Name the new workflow Start VM and Send Email and click OK.
The workflow editor opens.
In the General tab, click the version number digits to increment the version number.
Because this is the initial creation of the workflow, set the version to 0.0.1.
Click the Server restart behavior value in the General tab to set whether the workflow resumes after a
server restart.
Type a description of what the workflow does in the Description text box in the General tab.
For example, you can add the following description.
This workflow starts a virtual machine and sends a confirmation email to the Orchestrator
administrator.
10
You created a workflow called Start VM and Send Email, but you did not define its functions.
What to do next
Create the workflow's schema.
VMware, Inc.
83
Procedure
1
From the Generic menu, drag a decision element to the arrow that links the Start element and the End
element in the schema.
Double-click the decision element and change its name to VM powered on?.
The decision element corresponds to a boolean function that checks whether the virtual machine is
already powered on.
From the Generic menu, drag an action element to the red arrow that links the decision element and an
End element.
84
Type start in the Filter text box, select the startVM action from the filtered list of actions, and click
Select.
Drag the following action elements, one after the other, to the blue arrow that links the startVM action
element to an End element.
vim3WaitTaskEnd
Suspends the workflow run and pings an ongoing vCenter Server task at
regular intervals, until that task is finished. The startVM action starts a
virtual machine and the vim3WaitTaskEnd action makes the workflow wait
while the virtual machine starts up. After the virtual machine starts, the
vim3WaitTaskEnd lets the workflow resume.
vim3WaitToolsStarted
Suspends the workflow run and waits until VMware Tools starts on the
target virtual machine.
From the Generic menu, drag a scriptable task element to the blue arrow that links the
vim3WaitToolsStarted action element to an End element.
Drag another scriptable task element to the green arrow that links the VM powered on? decision element
to an End element , and name this scriptable task element Already started.
10
Drag the Already started scriptable task element to the left of the startVM action element.
Delete the blue arrow that connects the Already started scriptable task element to an End element.
Link the Already started scriptable task element to the vim3WaitToolsStarted action element with
a blue arrow.
VMware, Inc.
11
From the Generic menu, drag the following scriptable task elements into the schema.
n
Drag a scriptable task element to the startVM action element and name the scriptable task element
Start VM Failed.
n
Drag a scriptable task element to the vim3WaitTaskEnd action element and name the scriptable task
element Timeout 1.
Drag a scriptable task element to the vim3WaitToolsStarted action element and name the scriptable
task element Timeout 2.
Drag a scriptable task element to the blue arrow that links the OK scriptable task element to an End
element, name the new scriptable task element Send Email, and drag it to the right of the OK
scriptable task element.
Link the Start VM Failed, Timeout 1, and Timeout 2 scriptable task elements to the Send Email
scriptable task element with blue arrows.
Drag a scriptable task element to the Send Email scriptable task element, name the new scriptable
task element Send Email Failed, drag it to the right of the Timeout 2 scriptable task element, and
link it to the End element with a blue arrow.
12
Drag the End element to the right of the Send Email scriptable task element.
13
The following figure shows the layout of the Start VM and Send Email workflow schema elements.
Figure 13. Linking the Elements of the Start VM and Send Email Example Workflow
VMware, Inc.
85
What to do next
You can highlight different zones in the workflow.
Procedure
1
Drag a workflow note element from the Generic menu into the workflow editor.
Position the workflow note over the Already started scriptable task element.
Drag the edges of the workflow note to resize it so that it surrounds the Already started scriptable task
element.
Place a note over the vertical sequence of elements from the VM powered on? decision element to the
OK element. Add the description Start VM path.
Place a note over the startVM failed, both Timeout scriptable task elements and the Send Email
Failed scriptable task element. Add the description Error handling.
Place a note over the Send Email scriptable task element. Add the description Send email.
The following figure shows what the example workflow zones should look like.
86
VMware, Inc.
What to do next
You must define the workflow's attributes and input and output parameters.
Procedure
1
Click arg_in_0.
Type the name vm in the Choose Attribute Name dialog box and click OK.
VMware, Inc.
87
Click the Type text box and type vc:virtualm in the search text box in the parameter type dialog box.
Select VC:VirtualMachine from the proposed list of parameter types and click Accept.
Repeat Step 2 through Step 7 to create a second input parameter, with the following values.
n
Name: toAddress
Type: String
Procedure
1
On the Decision tab, click the Not set (NULL) button and select vm as the decision element's input
parameter from the list of proposed parameters.
Select the state equals statement from the list of decision statements proposed in the drop-down menu.
A Not set button appears in the value text box, which presents you with a limited choice of possible
values.
Select poweredOn.
You have defined the true or false statement against which the decision element will compare the value of
the input parameter it receives.
What to do next
You must define the bindings for the other elements in the workflow.
88
VMware, Inc.
Procedure
1
2
Action
Interaction
Business Status
Select the check box and add the text Sending start VM.
Description
Leave the text Start / Resume a VM. Return the start task.
VMware, Inc.
Click Create workflow ATTRIBUTE with the same name and click OK to exit the Parameter
information dialog box.
89
10
Repeat the preceding steps to bind the input and output parameters to the vim3WaitTaskEnd and
vim3WaitToolsStarted action elements.
Simple Workflow Example Action Element Bindings, on page 90 lists the bindings for the
vim3WaitTaskEnd and vim3WaitToolsStarted action elements.
11
The action elements' input and output parameters are bound to the appropriate parameter types and values.
What to do next
Bind the scriptable task elements and define their functions.
Binding Type
Bind to Existing or
Create Parameter?
Binding Values
task
IN
Bind
n
n
n
n
progress
IN
Create
n
n
n
n
n
90
VMware, Inc.
Binding Type
Bind to Existing or
Create Parameter?
Binding Values
pollRate
IN
Create
Value: 2
Description:
Polling rate in seconds at
which vim3WaitTaskEnd
checks the advancement of
the vCenter Server task.
Local Parameter:
actionResult[attribute]
Source parameter:
returnedManagedObject[attri
bute]
Type: Any
Description:
The returned managed object
from the waitTaskEnd
action.
actionResult
OUT
Create
n
n
vim3WaitToolsStarted Action
The vim3WaitToolsStarted action element waits until VMware Tools have installed on a virtual machine,
and defines a polling rate and a timeout period. The following table shows the input parameter bindings the
vim3WaitToolsStarted action requires.
The vim3WaitToolsStarted action element has no output, so requires no output binding.
VMware, Inc.
91
Binding Type
Bind to Existing or
Create Parameter?
Binding Values
vm
IN
Automatic binding
Local Parameter: vm
n
n
n
pollingRate
IN
Bind
n
n
n
n
timeout
IN
Create
n
n
n
n
n
Procedure
1
92
VMware, Inc.
Action
Interaction
Business Status
Select the check box and add the text VM already powered on.
Description
Leave the text The VM is already powered on, bypassing startVM and
waitTaskEnd, checking if the VM tools are up and running..
).
Repeat the preceding steps to bind the remaining input parameters to the other scriptable task
elements.
Simple Workflow Example Scriptable Task Element Bindings, on page 93 lists the bindings for the
Start VM failed, both Timeout or Error, Send Email Failed, and the OK scriptable task elements.
10
You have bound the scriptable task elements to their input and output parameters and provided the
scripting that defines their function.
What to do next
You must define the exception handling.
VMware, Inc.
93
Binding Type
Bind to Existing or
Create Parameter?
Binding Values
vm
IN
Bind
Local Parameter: vm
n
n
errorCode
IN
Create
n
n
n
n
body
OUT
Create
n
n
The Start VM Failed scriptable task element performs the following scripted function.
body = "Unable to execute powerOnVM_Task() on VM '"+vm.name+"', exception found: "+errorCode;
//Writes the following event in the vCO database
Server.error("Unable to execute powerOnVM_Task() on VM '"+vm.name, "Exception found:
"+errorCode);
94
VMware, Inc.
Binding Type
Bind to Existing or
Create Parameter?
Binding Values
vm
IN
Bind
Local Parameter: vm
n
n
errorCode
IN
Bind
n
n
n
n
body
OUT
Bind
n
n
The Timeout 1 scriptable task element requires the following scripted function.
body = "Error while waiting for poweredOnVM_Task() to complete on VM '"+vm.name+"', exception
found: "+errorCode;
//Writes the following event in the vCO database
Server.error("Error while waiting for poweredOnVM_Task() to complete on VM '"+vm.name,
"Exception found: "+errorCode);
VMware, Inc.
95
Binding Type
Bind to Existing or
Create Parameter?
Binding Values
vm
IN
Bind
Local Parameter: vm
n
n
errorCode
IN
Bind
n
n
n
n
body
OUT
Bind
n
n
The Timeout 2 scriptable task element requires the following scripted function.
body = "Error while waiting for VMware tools to be up on VM '"+vm.name+"', exception found:
"+errorCode;
//Writes the following event in the vCO database
Server.error("Error while waiting for VMware tools to be up on VM '"+vm.name, "Exception found:
"+errorCode);
Binding Type
Bind to Existing or
Create Parameter?
Binding Values
vm
IN
Bind
Local Parameter: vm
n
n
body
OUT
Bind
n
n
96
VMware, Inc.
Binding Type
Bind to Existing or
Create Parameter?
vm
IN
Bind
Binding Values
n
Local Parameter: vm
n
n
toAddress
IN
Bind
n
n
n
n
emailErrorCode
IN
Create
n
n
n
n
The Send Email Failed scriptable task element requires the following scripted function.
//Writes the following event in the vCO database
Server.error("Couldn't send result email to '"+toAddress+"' for VM '"+vm.name, "Exception found:
"+emailErrorCode);
VMware, Inc.
97
Binding Type
Bind to Existing or
Create Parameter?
vm
IN
Bind
Binding Values
n
Local Parameter: vm
n
n
toAddress
IN
Bind
n
n
n
n
body
IN
Bind
n
n
smtpHost
IN
Create
n
n
n
fromAddress
IN
Create
n
n
n
n
subject
IN
Create
n
n
n
n
The Send Email scriptable task element requires the following scripted function.
//Create an instance of EmailMessage
var myEmailMessage = new EmailMessage() ;
//Apply methods on this instance that populate the email message
myEmailMessage.smtpHost = smtpHost;
myEmailMessage.fromAddress = fromAddress;
myEmailMessage.toAddress = toAddress;
myEmailMessage.subject = subject;
myEmailMessage.addMimePart(body , "text/html");
98
VMware, Inc.
Bind the Action Elements of the Simple Workflow Example, on page 89.
Bind the Simple Workflow Example Scripted Task Elements, on page 92.
Procedure
1
5
6
Repeat the preceding steps to set the exception binding to errorCode for both vim3WaitTaskEnd and
vim3WaitToolsStarted.
10
You have defined the exception binding for the elements that return exceptions.
What to do next
You must set the read and write properties on the attributes and parameters.
VMware, Inc.
99
Set the Read-Write Properties for Attributes of the Simple Workflow Example
You can define whether parameters and attributes are read-only constants or writeable variables. You can
also set limitations on the values that users can provide for input parameters.
Setting certain parameters to read-only allows other developers to adapt the workflow or to modify it
without breaking the workflow's core function.
Prerequisites
Complete the following tasks.
n
Bind the Action Elements of the Simple Workflow Example, on page 89.
Bind the Simple Workflow Example Scripted Task Elements, on page 92.
Procedure
1
Select the check boxes to make the following attributes read-only constants:
n
progress
pollRate
timeout
smtpHost
fromAddress
subject
You have defined which of the workflow's attributes are constants and which are variables.
What to do next
Set the parameter properties and place constraints on the possible values for that parameter.
100
VMware, Inc.
Bind the Action Elements of the Simple Workflow Example, on page 89.
Bind the Simple Workflow Example Scripted Task Elements, on page 92.
Procedure
1
Add a description in the General tab in the bottom half of the screen.
For example, type The virtual machine to start.
5
6
).
From the list of proposed properties, select the Mandatory input property, click Ok, and set its value to
Yes.
When you enable this property, users cannot run the Start VM and Send Email workflow without
providing a virtual machine to start.
7
8
).
From the list of proposed properties, select Select value as, click Ok, and select list from the list of
possible values.
When you set this property, you set how the user selects the value of the (VC:VirtualMachine)vm input
parameter.
Click the (string)toAddress parameter in the top half of the Presentation tab.
10
Add a description in the Description tab in the bottom half of the screen.
For example, type The email address of the person to notify.
11
12
13
14
Click the Properties tab for (string)toAddress and click the Add property icon (
).
From the list of proposed properties, select the Mandatory input property, click Ok, and set its value to
Yes.
Click the Add property icon (
).
From the list of proposed properties, select Matching regular expression and click Ok.
This property allows you to set constraints on what users can provide as input .
15
Click the Value text box for Matching regular expression and set the constraints to
[a-zA-Z0-9_%-+.]+@[a-zA-Z0-9-.]+\.[a-zA-Z]{2,4}.
Setting these constraints limits user input to characters that are appropriate for email addresses. If the
user tries to input any other character for the email address of the recipient when they start the
workflow, the workflow does not start.
VMware, Inc.
101
You have made both parameters mandatory, defined how the user can select the virtual machine to start,
and limited the characters that can be input for the recipient's email address.
What to do next
You must create the layout, or presentation, of the input parameters dialog box in which users specify a
workflow's input parameter values when they run it.
Set the Layout of the Simple Workflow Example Input Parameters Dialog Box
You create the layout or presentation of the input parameters dialog box in the workflow editor. The input
parameters dialog box opens when users run a workflow that needs input parameters to run.
The layout you define in the Presentation tab also defines the layout of the input parameter dialog boxes for
workflows you run using a Web view.
Prerequisites
Complete the following tasks.
n
Bind the Action Elements of the Simple Workflow Example, on page 89.
Bind the Simple Workflow Example Scripted Task Elements, on page 92.
Set the Read-Write Properties for Attributes of the Simple Workflow Example, on page 100.
Procedure
1
Right-click the Presentation node in the presentation hierarchical list and select Create display group.
A New step node and a New group sub-node appear under the Presentation node.
Double-click New group to edit the group name and press Enter.
For example, name the display group Virtual Machine.
The text you enter here appears as a heading in the input parameter dialog box when users start the
workflow.
In the Description text box of the General tab at the bottom of the Presentation tab, provide a
description for the new display group.
For example, type Select the virtual machine to start.
The text you type here appears as a prompt in the input parameter dialog box when users start the
workflow.
102
VMware, Inc.
Drag the (VC:VirtualMachine)vm parameter under the Virtual Machine display group.
In the input parameters dialog box, a text box in which the user types the virtual machine name will
appear under a Virtual Machine heading.
Repeat the preceding steps to create a display group for the toAddress parameter, setting the following
properties:
a
Drag the toAddress parameter under the Recipient's Email Address display group.
Enter the email address of the person to notify when this virtual machine is powered-on.
You have set up the layout of the input parameters dialog box that appears when users run the workflow.
What to do next
You have completed the development of the simple workflow example. You can now validate and run the
workflow.
Bind the Action Elements of the Simple Workflow Example, on page 89.
Bind the Simple Workflow Example Scripted Task Elements, on page 92.
Set the Read-Write Properties for Attributes of the Simple Workflow Example, on page 100.
Set the Layout of the Simple Workflow Example Input Parameters Dialog Box, on page 102.
Procedure
1
After you have eliminated any errors, click Save and Close at the bottom of the workflow editor.
You return to the Orchestrator client.
Select Workflow Examples > Start VM and Send Email in the workflow hierarchical list.
VMware, Inc.
103
Right-click the Start VM and Send Email workflow and select Start workflow.
The input parameters dialog box opens and prompts you for a virtual machine to start and an email
address to send notifications to.
Click the workflow token to follow the progress of the workflow as it runs.
If the workflow runs successfully, the virtual machine you selected is in the powered-on state, and the email
recipient you defined receives a confirmation email.
What to do next
You can generate a document in which to review information about the workflow. See Generate Workflow
Documentation, on page 80.
Prompts the user for a resource pool that contains the virtual machines of which to take snapshots.
Verifies whether an individual virtual machine running in the pool meets specific criteria for a snapshot
to be taken.
Determines whether more virtual machines exist in the pool of which to take snapshots.
Repeats the verification and snapshot process until the workflow has taken snapshots of all eligible
virtual machines in the resource pool.
The ZIP file of Orchestrator examples that you can download from the landing page of the Orchestrator
documentation contains a completed version of the Take a Snapshot of All Virtual Machines in a Resource
Pool workflow.
Prerequisites
Before you attempt to develop this complex workflow, follow the exercises in Develop a Simple Example
Workflow, on page 81. The procedures to develop a complex workflow provide the broad steps of the
development process, but are not as detailed as the simple workflow exercises.
Procedure
1
104
VMware, Inc.
Create a Custom Action for the Complex Workflow Example on page 106
The Check VM scriptable element calls on an action that does not exist in the Orchestrator API. You
must create the getVMDiskModes action.
Define the Bindings for the Complex Workflow Example on page 111
You can bind a workflow's elements together in the workflow editor. Bindings define the data flow of
the workflow. You also bind the scriptable task elements to their JavaScript functions.
Create the Layout of the Complex Workflow Example Input Parameters on page 121
You create the layout, or presentation, of the input parameters dialog box in the Presentation tab of
the workflow editor. The input parameters dialog box opens when users run a workflow, and is the
means by which users enter the input parameters with which the workflow runs.
vCenter Server, controlling a resource pool that contains some virtual machines
The Workflow Examples folder in the workflows hierarchical list, that you created in Create the Simple
Workflow Example, on page 83.
Procedure
1
Name the new workflow Take a Snapshot of All Virtual Machines in a Resource Pool and click
OK.
The workflow editor opens.
VMware, Inc.
105
On the General tab of the workflow editor, click the version number digits to increment the version
number.
For the initial creation of the workflow, set the version to 0.0.1.
Click the Server restart behavior value to set whether the workflow resumes after a server restart.
In the Description text box, type a description of what the workflow does.
You created the Take a Snapshot of All Virtual Machines in a Resource Pool workflow.
What to do next
You must create a custom action.
Right-click the root of the actions hierarchical list and select New Module.
Increment the version number in the General tab in the actions editor by clicking the version digits.
10
11
Right-click in the top pane of the Scripting tab and select Add Parameter to create the following input
parameter.
n
106
Name: vm
VMware, Inc.
12
Value: VC:VirtualMachine
Description: The virtual machine for which to return the Disk Modes
13
You have defined the custom action the Take a Snapshot of All Virtual Machines in a Resource Pool
workflow requires.
What to do next
Create the workflow's schema.
Create a Custom Action for the Complex Workflow Example, on page 106.
Procedure
1
VMware, Inc.
Element Type
Element Name
Position in Schema
Scriptable task
Initializing
Decision
VMs to Process?
Scriptable task
Below the VMs to Process? custom decision element, linked with a red
arrow
Custom decision
Remaining VMs?
Action
getVMDiskModes
Custom decision
Create Snapshot?
107
Element Type
Element Name
Position in Schema
Workflow
Create a snapshot
Scriptable task
VM Snapshots
Scriptable task
Increment
Scriptable task
Set Output
Right of the Pool Has No VMs scriptable task element, linked with a
blue arrow
Create an exception handling link from the Create a snapshot workflow to an End element.
Drag a scriptable task element to the red dashed arrow that links the Create a snapshot workflow
to an End element.
Move the Log Exception scriptable task element to above the VM Snapshots scriptable task element.
Unlink all End elements except the End element that is at the right of the Set Output scriptable task
element.
Element
Link to
Type of Arrow
Description
Red dashed
Exception handling
Red
False result
Blue
Normal workflow
progression
Blue
Normal workflow
progression
Red
False result
The following figure shows what the linked elements of the Take a Snapshot of All Virtual Machines in a
Resource Pool workflow should look like.
108
VMware, Inc.
Figure 15. Linking of the Take a Snapshot of All Virtual Machines in a Resource Pool Example Workflow
What to do next
You can optionally define workflow zones by using workflow notes.
Procedure
1
VMware, Inc.
Description
109
Elements in Zone
Description
Select a workflow note and press Ctrl+E to select the background color.
What to do next
You must define the workflow's input and output parameters.
110
VMware, Inc.
Procedure
1
Name: resourcePool
Type: VC:ResourcePool
Description: The resource pool containing the virtual machines of which to take snapshots.
Name: snapshotVmArrayOut
Type: Array/VC:VirtualMachine
Description: The Array of virtual machines of which snapshots have been taken.
Review the bindings that you must define. See Complex Workflow Example Bindings, on page 112.
Procedure
1
VMware, Inc.
111
All the input and output parameters of the elements are bound to the appropriate parameter types and
values.
What to do next
Set the attribute properties.
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
resourcePool
IN
Bind
Binding Values
n
n
n
n
allVMs
OUT
Create
n
n
n
n
numberOfVMs
OUT
Create
n
n
n
n
112
VMware, Inc.
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
vmCounter
OUT
Create
Binding Values
n
n
n
n
vm
OUT
Create
n
n
n
n
snapshotVmArray
OUT
Create
n
n
n
n
The Initialize scriptable task element performs the following scripted function.
//Retrieve an array of virtual machines contained in the specified Resource Pool
allVMs = resourcePool.vm;
//Initialize the size of the Array and the first VM to snapshot
if (allVMs!=null && allVMs.length!=0) {
numberOfVms = allVMs.length;
vm = allVMs[0];
} else {
numberOfVms = 0;
}
//Initialize the VM counter
vmCounter = 0;
//Initializing the array of VM snapshots
snapshotVmArray = new Array();
VMware, Inc.
113
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
numberOfVMs
Decision
Bind
Binding Values
n
n
n
n
Source parameter:
numberOfVMs[attribute]
Decision statement: Greater than
Value: 0.0
Description:
The number of virtual
machines found in the
resourcePool
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
resourcePool
IN
Bind
Binding Values
n
n
n
n
The Pool Has No VMs scriptable task element performs the following scripted function.
//Writes the following event in the vCO database
Server.warn("The specified ResourcePool "+resourcePool.name+" does not contain any VMs.");
114
VMware, Inc.
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
numberOfVMs
IN
Bind
Binding Values
n
n
n
n
vmCounter
IN
Bind
n
n
n
n
Source parameter:
numberOfVMs[attribute]
Decision statement: Greater than
Value: 0.0
Description:
The number of virtual
machines found in the
resourcePool
Local parameter: vmCounter
Source parameter:
vmCounter[attribute]
Type: number
Description:
The counter of the virtual
machines inside the array
The Remaining VMs? custom decision element performs the following scripted function.
//Checks if the workflow has reached the end of the array of VMs
if (vmCounter < numberOfVms) {
return true;
} else {
return false;
}
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
vm
IN
Bind
Binding Values
n
n
n
n
actionResult
OUT
Create
n
n
n
n
errorCode
VMware, Inc.
Exception
Create
Local parameter: vm
Source parameter:
vm[attribute]
Type: VC:VirtualMachine
Description:
The current virtual machine
having a snapshot taken
Local parameter: actionResult
Source parameter:
vmDisksModes[attribute]
Type: Array/String
Description:
The current Disks Modes of
the virtual machine
115
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
vmDisksMode
IN
Bind
Binding Values
n
n
n
n
vm
IN
Bind
n
n
n
n
The Create Snapshot? custom decision element custom decision element performs the following scripted
function.
//A snapshot cannot be taken if one of its disks is in independent mode
// (independent-persistent or independent-nonpersistent)
var containsIndependentDisks = false;
if (vmDisksModes!=null && vmDisksModes.length>0) {
for (i in vmDisksModes) {
if (vmDisksModes[i].charAt(0)=="i") {
containsIndependentDisks = true;
}
}
} else {
//if no disk found no need to try to snapshot the VM
System.warn("Won't snapshot '"+vm.name+"', no disks found");
return false;
}
if (containsIndependentDisks) {
System.warn("Won't snapshot '"+vm.name+"', independent disk(s) found");
return false;
} else {
System.log("Snapshoting '"+vm.name+"'");
return true;
}
116
VMware, Inc.
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
vm
IN
Bind
Binding Values
n
n
n
n
name
IN
Create
n
n
n
n
description
IN
Create
n
n
n
n
memory
IN
Create
n
n
n
n
quiesce
IN
Create
Description:
If TRUE, a dump of the
internal state of the
virtual machine (a memory
dump) is included in the
snapshot.
n
n
n
n
VMware, Inc.
Local parameter: vm
Source parameter:
vm[attribute]
Type: VC:VirtualMachine
Description:
An active virtual machine
of which to take a
snapshot.
Description:
If TRUE and the virtual
machine is powered on when
the snapshot is taken, the
VMware Tools are used to
quiesce the file system in
the virtual machine.
117
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
snapshot
OUT
Create
Binding Values
n
n
n
n
errorCode
Exception
Create
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
vm
IN
Bind
Binding Values
n
n
n
n
snapshotVmArray
IN
Bind
n
n
n
n
snapshotVmArray
OUT
Bind
n
n
n
n
Local parameter: vm
Source parameter:
vm[attribute]
Type: VC:VirtualMachine
Description:
An active virtual machine
of which to take a
snapshot.
Local parameter:
snapshotVmArray
Source parameter:
snapshotVmArray[attribute]
Type:
Array/VC:VirtualMachine
Description:
The Array of virtual
machines of which snapshots
have been taken
Local parameter:
snapshotVmArray
Source parameter:
snapshotVmArray[attribute]
Type:
Array/VC:VirtualMachine
Description:
The Array of virtual
machines of which snapshots
have been taken
The VM Snapshots scriptable task element performs the following scripted function.
//Writes the following event in the vCO database
Server.log("Successfully took snapshot of the VM '"+vm.name);
//Inserts the VM snapshot in an array
snapshotVmArray.push(vm);
118
VMware, Inc.
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
vmCounter
IN
Bind
Binding Values
n
n
n
n
allVMs
IN
Bind
n
n
n
n
vmCounter
OUT
Bind
n
n
n
n
vm
OUT
Bind
n
n
n
n
The Increment scriptable task element performs the following scripted function.
//Increases the array VM counter
vmCounter++;
//Sets the next VM to be snapshot in the attribute vm
vm = allVMs[vmCounter];
VMware, Inc.
119
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
vm
IN
Bind
Binding Values
n
n
n
n
errorCode
IN
Bind
n
n
n
n
Local parameter: vm
Source parameter:
vm[attribute]
Type: VC:VirtualMachine
Description:
The current virtual machine
having a snapshot taken
Local parameter: errorCode
Source parameter:
errorCode[attribute]
Type: string
Description:
An exception caught while
taking a snapshot of a
virtual machine
The Log Exception scriptable task element performs the following scripted function.
//Writes the following event in the vCO database
Server.error("Coudln't snapshot the VM '"+vm.name+"', exception: "+errorCode);
Parameter Name
Binding Type
Bind to Existing
or Create
Parameter?
snapshotVmArray
IN
Bind
Binding Values
n
n
n
n
snapshotVmArrayOut
OUT
Bind
n
n
n
n
120
Local parameter:
snapshotVmArray
Source parameter:
snapshotVmArray[attribute]
Type:
Array/VC:VirtualMachine
Description:
The Array of virtual
machines of which snapshots
have been taken
Local parameter:
snapshotVmArrayOut
Source parameter:
snapshotVmArrayOut[outparameter]
Type:
Array/VC:VirtualMachine
Description:
The Array of virtual
machines of which snapshots
have been
VMware, Inc.
The Set Output scriptable task element performs the following scripted function.
//Passes the value of the internal attribute to a workflow output parameter
snapshotVmArrayOut = snapshotVmArray;
Define the Bindings for the Complex Workflow Example, on page 111.
Procedure
1
Select the read-only check box of the following attributes to make them read-only constants:
n
snapshotName
snapshotDescription
snapshotMemory
snapshotQuiesce
You have defined which of the workflow's attributes are constants and which are variables.
What to do next
You must create the workflow presentation, which creates the layout of the input parameters dialog box in
which users specify a workflow's input parameter values when they run it.
Define the Bindings for the Complex Workflow Example, on page 111.
VMware, Inc.
121
Procedure
1
Right-click the Presentation node in the presentation hierarchical list and select Create display group.
Delete the New step element that appears above the New group element.
Double-click the New group element and change the group name to Resource Pool.
Provide a description of the Resource Pool display group in the Description text box on the General
tab at the bottom of the Presentation tab.
For example,
Enter the name of the resource pool that contains the virtual machines of which to take a
snapshot.
Right-click within the Properties tab and select Add Property > Mandatory input.
Right-click within the Properties tab and select Add Property > Select value as.
When you set this property, you set how the user selects the value of the
10
Drag the (VC:ResourcePool)resourcePool parameter under the Resource Pool display group.
You have created the layout of the dialog box that appears when users run the workflow.
What to do next
You have completed the development of the complex workflow example. You can now validate and run the
workflow.
122
Create a Custom Action for the Complex Workflow Example, on page 106.
Define the Bindings for the Complex Workflow Example, on page 111.
Create the Layout of the Complex Workflow Example Input Parameters, on page 121.
VMware, Inc.
Procedure
1
After you have eliminated any errors, click Save and Close at the bottom of the workflow editor.
You return to the Orchestrator client.
In the workflow hierarchical list, select Workflow Examples > Take a Snapshot of All Virtual
Machines in a Resource Pool.
Right-click the Take a Snapshot of All Virtual Machines in a Resource Pool workflow and select Start
workflow.
The input parameters dialog box opens and prompts you for a resource pool that contains the virtual
machines of which to take a snapshot.
Click the workflow token to follow the progress of the workflow as it runs.
If the workflow runs successfully, the workflow takes a snapshot of all of the virtual machines in the
selected resource pool.
What to do next
You can generate a document in which to review information about the workflow. See Generate Workflow
Documentation, on page 80.
VMware, Inc.
123
124
VMware, Inc.
Scripting
Orchestrator uses JavaScript to create building blocks from which you create actions, workflow elements,
and policies that access the APIs of the technologies that you plug into Orchestrator.
Orchestrator uses the Mozilla Rhino 1.7R4 JavaScript engine as its scripting engine. The scripting engine
provides variable type checking, name space management, automatic completion, and exception handling.
The Orchestrator workflow engine allows you to use basic JavaScript language features, such as if, loops,
arrays, and strings. You can use objects in scripting that the Orchestrator API provides, or objects from any
other API that you import into Orchestrator through a plug-in and that you map to JavaScript objects. For
information about Rhino, see the Mozilla Rhino Web site.
This chapter includes the following topics:
n
Actions are scripted functions. You can limit the scripting you write for an
action to a single operation, to maximize the potential for action reuse by
other elements, such as other workflows. Alternatively, an action can contain
many operations, to limit the complexity of workflows, although this does
reduce the capacity for reusing the action.
Policies
You set policies by using scripts that watch for trigger events. When the
trigger events occur, policies launch orchestration operations that you define
in scripts.
Workflows
The Scriptable Task workflow element allows you to write a custom scripted
operation or sequence of operations that you can use in the workflows. You
also define the Boolean decision statement for custom decision elements in
scripts that return either true or false.
VMware, Inc.
125
When a workflow runs, the objects that pass from one workflow element to another are not JavaScript
objects. What is passed from one element to the next is the serialization of a Java object that has a
JavaScript image. As a consequence, you cannot use the whole JavaScript language, but only the classes
that are present in the API Explorer. You cannot pass function objects from one workflow element to
another.
Orchestrator runs the code in scriptable task elements in a context that is not the Rhino root context.
Orchestrator transparently wraps scriptable task elements and actions into JavaScript functions, which
it then runs. A scriptable task element that contains System.log(this); does not display the global
object this in the same way as a standard Rhino implementation does.
You can only call actions that return nonserializable objects from scripting, and not from workflows. To
call an action that returns a nonserializable object, you must write a scriptable task element that calls the
action by using the System.getModuleModuleName.action() method.
Workflow validation does not check whether a workflow attribute type is different from an input type
of an action or subworkflow. If you change the type of a workflow input parameter, for example from
VIM3:VirtualMachine to VC:VirtualMachine, but you do not update any scriptable tasks or actions that
use the original input type, the workflow validates but does not run.
Access the Scripting Engine from the Workflow Editor on page 127
The Orchestrator scripting engine uses the Mozilla Rhino 1.7R4 JavaScript engine to help you write
scripts for scripted elements in workflows. You access the scripting engine for scripted workflow
elements from the Scripting tab in the workflow editor.
Access the Scripting Engine from the Action or Policy Editor on page 128
The Orchestrator scripting engine uses the Mozilla Rhino JavaScript engine to help you write scripts
for actions or policies. You access the scripting engine for actions and policies from the Scripting tabs
in the action and policy editors.
126
VMware, Inc.
Chapter 2 Scripting
Accessing the Orchestrator Server File System from JavaScript and Workflows on page 131
Orchestrator limits access to the Orchestrator server file system from JavaScript and Workflows to
specific directories.
Right-click a workflow in the Workflows view of the Orchestrator client and select Edit.
Add a Scriptable Task element or a Custom Decision element to the workflow schema.
You accessed the scripting engine to define the scripted functions of workflow elements. The Scripting tab
allows you to navigate through the API, consult documentation about the objects, search for objects, and
write JavaScript.
What to do next
Search the Orchestrator API using the API Explorer.
VMware, Inc.
127
Select an option from the drop-down menu in the Orchestrator client, depending on the type of the
element whose scripting you want to edit.
Option
Description
Design
Run
Right-click an action or policy in the Actions or Policies views and select Edit.
You accessed the scripting engine to define the scripted functions of action or policy elements. The Scripting
tab allows you to navigate through the API, consult documentation about the objects, search for objects, and
write JavaScript.
What to do next
Search the Orchestrator API using the API Explorer.
The API Explorer appears. You can use it to search all the objects and functions of the Orchestrator API.
What to do next
Use the API Explorer to write scripts for scriptable elements.
128
VMware, Inc.
Chapter 2 Scripting
Procedure
1
Enter the name or part of a name of an object in the API Explorer Search text box and click Search.
To limit your search to a particular object type, uncheck or check the Scripting Class, Attributes &
Methods and Types & Enumerations check boxes.
What to do next
Use the objects you find in scripts.
Description
Type
Types
Function set
Primitive
Primitive types
Object
Attribute
JavaScript attributes
Method
JavaScript methods
Constructor
JavaScript constructors
Enumeration
JavaScript enumerations
String set
Module
A collection of actions
Plug-in
Writing Scripts
The Orchestrator scripting engine helps you to write scripts. Automatic insertion of functions and automatic
completion of lines of scripting accelerates the scripting process and minimizes the potential for writing
errors in scripts.
Prerequisites
Open a scripted element for editing and click its Scripting tab.
VMware, Inc.
129
Procedure
1
Navigate through the hierarchical list of objects on the left of the Scripting tab, or use the API Explorer
search function, to select a type, class, or method to add to the script.
Right-click in the scripting pad, and paste the element you copied into the appropriate place in the
script.
The scripting engine enters the element into the script, complete with its constructor and an instance
name.
For example, if you copied the Date object, the scripting engine pastes the following code into the script.
var myDate = new Date();
The scripting engine highlights those parameters that you already defined in the element. Any
undefined parameters remain unhighlighted.
5
Place the cursor at the end of an element you pasted into the script and press Ctrl+space to select from a
contextual list of possible methods and attributes that the object can call.
NOTE The automatic completion feature is currently experimental.
130
Keyword Type
Bold black
Green
Red
Purple
Green
Code comments
Italic gray
Green
VMware, Inc.
Chapter 2 Scripting
Output text
Green
Workflow attributes
Pink
Workflow inputs
Pink
Workflow outputs
Pink
Move the cursor to the appropriate position in a script in the scripting pad of the Scripting tab.
Accessing the Orchestrator Server File System from JavaScript and Workflows
Orchestrator limits access to the Orchestrator server file system from JavaScript and Workflows to specific
directories.
JavaScript functions and workflows only have read, write, and execute permission in the permanent
directory c:\orchestrator.
The Orchestrator administrator can modify the folders to which JavaScript functions and workflows have
read, write, and execute access by setting a system property. See Installing and Configuring VMware vCenter
Orchestrator for information about setting system properties.
JavaScript functions and workflows also have read, write, and execute permission in the server system
default temporary I/O folder. Writing to the default temporary I/O folder is the only portable, guaranteed,
and configuration-independent means of accessing the file system with full permissions. However, files that
you write to the temporary I/O folder are lost when you reboot the server.
You obtain the default temporary I/O folder by calling the System.getTempDirectory method in JavaScript
functions.
VMware, Inc.
131
Include the following code line in JavaScript functions to access the java.io.temp-dir folder.
var tempDir = System.getTempDirectory()
Use the following European Computer Manufacturers Association (ECMA) error types. Use Error as a
generic exception that plug-in functions return, and the following specific error types.
n
TypeError
RangeError
EvalError
ReferenceError
URIError
SyntaxError
132
VMware, Inc.
Chapter 2 Scripting
...
} catch ( e if e instanceof URIError ) {
}
n
All exceptions that scripts do not catch must be simple string objects of the form <type>:SPACE<human
readable message>, as the following example shows.
throw "ValidationError: The input parameter 'myParam' of type 'string' is too short."
Simple string exception type checking must use the following pattern.
try {
throw "VMwareNoSpaceLeftOnDatastore: Datastore 'myDatastore' has no space left" ;
} catch ( e if (typeof(e)=="string" && e.indexOf("VMwareNoSpaceLeftOnDatastore:") == 0) ) {
System.log("No space left on device") ;
// Do something useful here
}
Simple string exception type checking, must use the following pattern in scripted elements in
workflows.
if (typeof(errorCode)=="string"
&& errorCode.indexOf("VMwareNoSpaceLeftOnDatastore:")
== 0) {
// Do something useful here
}
VMware, Inc.
133
134
VMware, Inc.
Chapter 2 Scripting
Compare Types
The following JavaScript example checks whether an object matches a given object type.
var path = 'myurl/test';
if(typeof(path, string)){
throw("string");
else {
throw("other");
}
VMware, Inc.
135
Send an Email
The following JavaScript example sends an email to the defined recipient, through an SMTP server, with the
defined content.
var message = new EmailMessage() ;
message.smtpHost = "smtpHost" ;
message.subject= "my subject" ;
message.toAddress = "[email protected]" ;
message.fromAddress = "[email protected]" ;
message.addMimePart("This is a simple message","text/html") ;
message.sendMessage() ;
136
VMware, Inc.
Chapter 2 Scripting
} finally {
myMailClient.closeFolder();
myMailClient.close();
}
VMware, Inc.
137
Persistent Logging
The following JavaScript example creates persistent log entries.
Server.log("This is a persistant message", "enter a long description here");
Server.warn("This is a persistant warning", "enter a long description here");
Server.error("This is a persistant error", "enter a long description here");
Non-Persistent Logging
The following JavaScript example creates non-persistent log entries.
System.log("This is a non-persistant log message");
System.warn("This is a non-persistant log warning");
System.error("This is a non-persistant log error");
138
VMware, Inc.
Chapter 2 Scripting
Schedule a Workflow
The following JavaScript example starts a workflow with a given set of properties, and then schedules it to
start one hour later.
var workflowToLaunch = myWorkflow ;
// create parameters
var workflowParameters = new Properties() ;
workflowParameters.put("name","John Doe") ;
// change the task name
workflowParameters.put("__taskName","Workflow for John Doe") ;
// create scheduling date one hour in the future
var workflowScheduleDate = new Date() ;
var time = workflowScheduleDate.getTime() + (60*60*1000) ;
workflowScheduleDate.setTime(time) ; var scheduledTask =
workflowToLaunch.schedule(workflowParameters,workflowScheduleDate);
VMware, Inc.
139
140
VMware, Inc.
Developing Actions
Orchestrator provides libraries of predefined actions. Actions represent individual functions that you use as
building blocks in workflows, Web views, and scripts.
Actions are JavaScript functions. They take multiple input parameters and have a single return value. They
can call on any object in the Orchestrator API, or on objects in any API that you import into Orchestrator by
using a plug-in.
When a workflow runs, an action takes its input parameters from the workflow's attributes. These attributes
can be either the workflow's initial input parameters, or attributes that other elements in the workflow set
when they run.
This chapter includes the following topics:
n
Reusing Actions
When you define an individual function as an action instead of coding it directly into a scriptable task
workflow element, you expose it in the library. When an action is visible in the library, other workflows can
use it.
When you define actions independently from the workflows that call on them, you can update or optimize
the actions more easily. Defining individual actions also allows other workflows to reuse actions. When a
workflow runs, Orchestrator caches each action only the first time that the workflow runs it. Orchestrator
can then reuse the cached action. Caching actions is useful for recursive calls in a workflow, or fast loops.
You can duplicate actions, export them to other workflows or packages, or move them to a different module
in the actions hierarchical list.
VMware, Inc.
141
Procedure
1
Browse the libraries of actions by expanding the nodes of the actions hierarchical list.
You can use the Actions view to view information about the actions in the libraries and create and edit
actions.
Displays general information about the action, including its name, its version
number, the permissions, and a description.
Scripting
Shows the action's return types, input parameters, and the JavaScript code
that defines the action's function.
Events
Permissions
Shows which users and user groups have permission to access this action.
Creating Actions
You can define individual functions as actions that other elements, such as workflows, can use. Actions are
JavaScript functions with defined input and output parameters and permissions.
n
Create an Action
When you define an individual function as an action, instead of coding it directly into a scriptable task
workflow element, you can expose it in the library for other workflows to use.
Procedure
142
Expand the root of the actions hierarchical list and navigate to the module in which you want to create
the action.
VMware, Inc.
Type a name for the action in the text box and click OK.
Your custom action is added to the library of actions.
10
11
12
You created a custom action and added the action input parameters.
What to do next
You can use the new custom action in a workflow.
Expand the nodes of the actions hierarchical list to navigate to a given action.
Right-click the action and select Find Elements that Use this Element.
A dialog box shows all of the elements, such as workflows or packages, that implement this action.
Double-click an element in the list of results to show that element in the Orchestrator client.
VMware, Inc.
143
Avoid writing actions that perform multiple functions, because this limits the potential for reusing the
action.
Avoid actions that run for long periods of time. Instead, create a loop in the workflow and include a
Waiting Event or Waiting Timer element after the action element.
Do not write check points in actions. Workflows set a check point at the start and end of each element's
run.
Avoid writing loops in an action. Create loops in the workflow instead. If the server restarts, a running
workflow resumes at its last check point, at the start of an element. If you write a loop inside an action
and the server restarts while the workflow is running that action, the workflow resumes at the check
point at the beginning of that action, and the loop starts again from the beginning.
Start action names with a lowercase letter. Use an uppercase letter at the beginning of each conjoined
word in the name. For example, myAction.
Make action names as explicit as possible, so that the function of the action is clear. For example,
backupAllVMsInPool.
n
Use the inverse Internet address format for module names. For example,
com.vmware.myactions.myAction.
144
Preferably limit parameter names to a single word. If a name must contain more than one word, use an
uppercase letter at the beginning of each conjoined word in the name. For example, myParameter.
Use the plural form for parameters that represent an array of objects.
VMware, Inc.
Select an action version and click Diff Against Current to compare the differences.
A window that displays the differences between the current action version and the selected action
version appears.
Select an action version and click Revert to restore the state of the action.
CAUTION If you have not saved the current action version, it is deleted from the version history and
you cannot revert back to the current version.
The action state is reverted to the state of the selected version.
Navigate to the folder in which you want to restore a deleted action or actions.
Select the action or actions that you want to restore and click Restore.
VMware, Inc.
145
146
VMware, Inc.
Workflows and Web views can require as attributes objects that you create independently of Orchestrator.
To use external objects as attributes in workflows or Web views, you import them into the Orchestrator
server as resource elements.
Objects that workflows and Web views can use as resource elements include image files, scripts, XML
templates, HTML files, and so on. Any workflows or Web views that run in the Orchestrator server can use
any resource elements that you import into Orchestrator.
Importing an object into Orchestrator as a resource element allows you to make changes to the object in a
single location, and to propagate those changes automatically to all the workflows or Web views that use
this resource element.
You can organize resource elements into folders. The maximum size for a resource element is 16MB.
This chapter includes the following topics:
n
Edit the Resource Element Information and Access Rights, on page 148
Click the Viewer tab to display the contents of the resource element.
Right-click the resource element and select Find Elements that Use this Element.
Orchestrator lists all the workflows and Web views that use this resource element.
VMware, Inc.
147
What to do next
Import and edit a resource element.
Right-click a resource folder in the hierarchical list or the root and select New folder to create a folder in
which to store the resource element.
Right-click the resource folder in which to import the resource element and select Import resources.
Click the General tab and set the resource element name, version, and description.
148
Click the Permissions tab and click the Add access rights icon (
group.
VMware, Inc.
Check the appropriate check boxes to set the level of permissions for this user group and click OK.
Permissions are not cumulative. To allow a user to view the resource element, use it in their workflows
or Web views, and change the permissions, you must check all check boxes.
10
You edited the general information about the resource element and set the user access rights.
What to do next
Save the resource element to a file to update it, or add the resource element to a workflow or Web view.
Modify the source file of the resource element in your local system.
Navigate through the hierarchical list to the resource element that you have updated.
(Optional) Click the Viewer tab to check that Orchestrator has updated the resource element.
VMware, Inc.
149
An image, script, XML, or HTML file, or any other type of object imported into Orchestrator as a
resource element.
Procedure
1
Expand the hierarchical tree viewer to navigate to the workflow that requires the resource element as
an attribute.
On the General tab, in the Attributes pane, click the Add attribute icon (
).
Click the attribute name and type a new name for the attribute.
In the Select a type dialog box, type resource in the Filter box to search for an object type.
Option
Action
Click Value and type the name of the resource element or category of resource elements in the Filter
text box.
10
From the proposed list, select the resource element or a folder containing resource elements and click
Select.
11
150
VMware, Inc.
An image, script, XML, or HTML file, or any other type of object imported into Orchestrator as a
resource element.
Procedure
1
If the Web view is running, right-click the Web view to which you want to add the resource element
and select Unpublish.
).
Click the attribute name and type a new name for the attribute.
In the Select a type dialog box, type resource in the Filter box to search for an object type.
Option
Action
10
Click Value and type the name of the resource element or category of resource elements in the Filter
text box.
11
From the proposed list, select the resource element or a folder containing resource elements and click
Select.
12
You added a resource element or folder of resource elements as an attribute in a Web view.
VMware, Inc.
151
152
VMware, Inc.
Creating Packages
Packages are used for transporting content from one Orchestrator server to another. Packages can contain
workflows, actions, policies, Web views, configurations, or resources.
When you add an element to a package, Orchestrator checks for dependencies and adds any dependent
elements to the package. For example, if you add a workflow that uses actions or other workflows,
Orchestrator adds those actions and workflows to the package.
When you import a package, the server compares the versions of the different elements of its contents to
matching local elements. The comparison shows the differences in versions between the local and imported
elements. The administrator can decide whether to import the package, or can select specific elements to
import.
Packages use digital rights management to control how the receiving server can use the contents of the
package. Orchestrator signs packages and encrypts the packages for data protection. Packages can track
which users export and redistribute elements by using X509 certificates.
IMPORTANT Packages that Orchestrator 3.2 generates are upwardly compatible with Orchestrator 4.x and
5.x. You can import a package from an Orchestrator 3.2 server to an Orchestrator 4.x or 5.x server. Packages
from Orchestrator 4.x and 5.x are not backward compatible with Orchestrator 3.2. You cannot import a
package generated by an Orchestrator 4.x or 5.x server to an Orchestrator 3.2 server.
For more information about using packages, see Using the VMware vCenter Orchestrator Client.
n
VMware, Inc.
153
Create a Package
You can export workflows, policies, actions, plug-in references, resources, Web views, and configuration
elements in packages. All elements that an element in a package implements are added to the package
automatically, to ensure compatibility between versions. If you do not want to add the referenced elements,
you can delete them in the package editor.
Prerequisites
Verify that the Orchestrator server contains elements such as workflows, actions, and policies that you can
add to a package.
Procedure
1
Click Insert Workflows (list search) to search for and select workflows in a selection dialog box.
Click Insert Workflows (tree browsing) to browse and select folders of workflows from the
hierarchical list.
On the Policy Templates, Actions, Web View, Configurations, Resources, and Used Plug-Ins tabs,
add policy templates, actions, Web views, configuration elements, resource elements, and plug-ins to
the package.
154
VMware, Inc.
The user can view the elements in the package, but cannot view the schemas
or scripting.
Inspect
The user can view the elements in the package, including the schemas and
scripting.
Edit
Admin
Prerequisites
Create a package, open it for editing in the package editor, and add the necessary elements to the package.
Procedure
1
2
3
Check the appropriate check boxes to set the level of permissions for this user and click Select.
To allow a user to view the elements, inspect the schema and scripting, run and edit the elements, and
change the permissions, you must check all check boxes.
VMware, Inc.
155
156
VMware, Inc.
The Orchestrator Appliance provides a repository containing Maven artifacts, which you can use to create
plug-in projects from archetypes.
The repository is hosted at https://orchestrator_server:8281/vco-repo/ or http://orchestrator_server:
8280/vco-repo/, in case your Maven version does not support the HTTPS protocol. This location is
embedded in the pom.xml file of standard Orchestrator Maven plug-in projects.
This chapter includes the following topics:
n
Procedure
1
(Optional) If you cannot access the repository over HTTPS, you can access it over HTTP. If you access
the repository over HTTP or have a valid SSL certificate, you can create a project without using the Dmaven.wagon.http.ssl.allowall=true flag.
mvn archetype:generate -DarchetypeCatalog=http://orchestrator_server:8280/vco-repo/archetypecatalog.xml -DrepoUrl=http://orchestrator_server:8280/vco-repo Dmaven.repo.remote=http://orchestrator_server:8280/vco-repo Dmaven.wagon.http.ssl.insecure=true
VMware, Inc.
157
If the build process is successful, the plug-in .dar file is generated in the DAR module's target/ directory.
Maven Archetypes
You can use a set of predefined Maven archetypes as templates for developing Orchestrator plug-ins.
The following table describes the default Maven archetypes available in Orchestrator.
Table 61. Default Maven Archetypes
Archetype
Description
com.vmware.o11n:o11n-plugin-archetype-simple
com.vmware.o11n:o11n-package-archetype
com.vmware.o11n:o11n-client-archetype-rest
com.vmware.o11n:o11n-plugin-archetype-inventory
com.vmware.o11n:o11n-archetype-inventoryannotation
com.vmware.o11n:o11n-archetype-spring
A plug-in that uses Spring-based SDK, provides a DIenabled environment, and adds higher-level services in
comparison to standard plug-in APIs.
Locking Workflows
After you verify that all workflows in your plug-in work as expected, lock them to prevent unauthorized
modifications. Having locked workflows ensures that the basic functions of the plug-in cannot be
compromised. If users need to modify a default workflow for a specific purpose, they can create a copy of
the original workflow and edit it.
To produce release builds with locked workflows, pass the -DallowedMask=vf parameter to Maven.
158
VMware, Inc.
If you do not create a signing certificate, the .package file is signed with thearchetype.keystore file. Create a
certificate by using the keytool from JDK and store the certificate in the keystore under the
_dunesrsa_alias_ alias. You can use the -DkeystoreLocation= and -DkeystorePassword parameters to
provide the path to the keystore file and the password to Maven, or you can edit the pom.xml file to insert
the values manually.
VMware, Inc.
159
160
VMware, Inc.
Index
A
Action element 25
action elements, binding 89
Action view 141
actions
adding 142
attributes 144
basic guidelines 144
binding 90
coding guidelines 144
creating 106, 142
finding elements that implement 143
naming 144
parameters 144
restoring deleted 145
reusing 141
version history 145
Actions 141
Actions view 142
API Explorer, accessing 128
attributes
definition 19, 87
read-write properties 100, 121
audience 7
B
binding
action elements 89
decision elements 88
scriptable tasks 92
bindings
action 90
defining 35, 111, 112
exception 39, 99
scriptable tasks 93
Boolean choices 38
C
Command scripting class 132
complex workflow example
notes 109
zones 109
composite type 40, 42
configuration elements, creating 70
creating workflows 15
VMware, Inc.
D
debug a workflow, example 75
debugging workflows 74
decision element, bindings 88
Decision element 25
decision elements
deleting branches 38
deleting paths 38
linking 37
Decision elements 38
documentation 80
E
End Workflow element 25
exception bindings, creating 39
exception handing 39
exceptions binding 99
F
file system, System.getTempDirectory 132
file system access 131
Foreach 40
Foreach element 41, 42
G
generate, workflow documentation 80
I
IN bindings 35
input parameters
definition 111
obtaining from user 43
properties 44
providing during run 48, 49
setting properties 45
input parameters dialog box, creating 102, 121
input parameters, obtaining from user 43
J
javascript, file system access 131
JavaScript 125, 132
161
L
linking
decision elements 37
schema elements 32
long-running workflows
date object 65
Date object 65
timer-based 66
trigger 68
Trigger object 65
trigger-based 69
M
Maven, archetypes 158
Mozilla Rhino JavaScript engine, limitations 126
N
nested workflows 62
O
Orchestrator client, accessing 14
Orchestrator API 126, 141
OS commands, accessing 132
OUT bindings 35
output parameters 13
P
packages
create 154
digital rights management 153
permissions 155
signature 153
parameter properties
dynamic 44, 45
static 44, 45
parameters
definition 19, 87, 111
promote 24
properties 100
read-write properties 100
PDF 80
plug-in
archetype 157
creating 157
development 157
plug-in development, best practices 158
presentation
creating 102, 121
creating display groups 121
display groups 43
input steps 43
Presentation tab 43, 45, 121
Presentation Tab 44
presentations 17
162
properties
parameter 100
read-write 100
R
relative date object 51, 65
remote workflow
calling 61
prerequisites 61
resource elements
adding to workflows 150
adding to Web views 151
editing 148
importing 148
save to file 149
updating 149
viewing 147
resume a failed workflow run 79
resuming a failed workflow run
enabling 79
set behavior 78
timeout 79
S
schema
bindings 33, 35
custom decisions 36
data flow 33, 35
decisions 32, 36
exception path 31, 32
links 31, 32
logical flow 31, 32
standard path 31, 32
Schema elements 40, 41
schema element, properties 28
schema elements
binding 111, 112
bindings 35
decisions 38
linking 32
properties 29
user interaction 48, 49
schemas 17
scriptable task elements, binding 92, 93
Scriptable Task element 25
scripting
access scripting engine from workflow 127
access scripting engine from actions 128
access scripting engine from policies 128
access to Java classes 132
accessing OS commands 132
adding objects 129
adding parameters 131
VMware, Inc.
Index
T
token 13
U
updated information 9
User Interaction element 25
user interactions
attributes 48, 49
defining external inputs 53
elements 48, 49
relative timeout 51, 52
user interactions, exceptions 54
user interactions, input parameters dialog
box 55
user interactions, responding 56
user interactions, security.group attribute 49
user interactions, timeout.date attribute 50, 52
using 141
V
viewing 141
W
Waiting Event element 25
Waiting Timer element 25
VMware, Inc.
worfklows, validation 72
workflow
attributes 18, 19, 87
create simple 81
creating 83, 105
end 75
notes 86, 109
parameters 18, 19, 87
presentation 17, 43
running 103, 122
schema 17
validation 103, 122
zones 86, 109
workflow debugger 74
workflow attributes, naming 20
workflow development 11
workflow documentation 80
workflow editor
General tab 18
opening 16
tabs 17
workflow folders 15
workflow parameters, naming 20
workflow presentation, creating 43
workflow schema
bindings 31
copying elements 23
create 22, 84, 107
edit 22
elements 22
links 31
schema element properties tabs 29
viewing 22
Workflow schema, schema element
properties 28
workflow schema, elements 25
workflow token
attributes 75
check points 75
workflow token attributes 14
workflow validation tool 72
workflows
asynchronous 57, 60
branching 38
calling other workflows 56
creation 15
debugging 74
debugging example 75
develop complex 104
editing 16
editing standard workflows 16
file system access 131
163
X
XML scripting, E4X 134
164
VMware, Inc.