Bindings define how the simple workflow example's scriptable task elements process input parameters. You also bind the scriptable task elements to their JavaScript functions.

When defining bindings, Orchestrator presents parameters you have already defined in the workflow as candidates for binding. If you have not defined the required parameter in the workflow yet, the only parameter choice is NULL. Click Create parameter/attribute in workflow to create a new parameter.

Start VM Failed Scriptable Task

The Start VM Failed scriptable task element handles any exceptions that the startVM action throws by setting the content of an email notification about the failure to start the virtual machine, and writing the event in the Orchestrator log.

The following table shows the input and output parameter bindings that the Start VM Failed scriptable task element requires.

Table 1. Bindings of the Start VM Failed Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local Parameter: vm

  • Source parameter: vm[in-parameter]

  • Type: VC:VirtualMachine

  • Description: The virtual machine to power on.

errorCode

IN

Create

  • Local Parameter: errorCode

  • Source parameter: errorCode[attribute]

  • Type: string

  • Description: Catch any exceptions while powering on a VM.

body

OUT

Create

  • Local Parameter: body

  • Source parameter: body[attribute]

  • Type: string

  • Description: The email body

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 Orchestrator database 
Server.error("Unable to execute powerOnVM_Task() on VM '"+vm.name+"', exception found: "+errorCode);

Timeout 1 Scriptable Task Element

The Timeout 1 scriptable task element handles any exceptions that the vim3WaitTaskEnd action throws by setting the content of an email notification about the failure of the task, and writing the event in the Orchestrator log.

The following table shows the input and output parameter bindings that the Timeout 1 scriptable task element requires.

Table 2. Bindings of the Timeout 1 Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local Parameter: vm

  • Source parameter: vm[in-parameter]

  • Type: VC:VirtualMachine

  • Description: The virtual machine to start.

errorCode

IN

Bind

  • Local Parameter: errorCode

  • Source parameter: errorCode[attribute]

  • Type: string

  • Description: Catch any exceptions while powering on a VM.

body

OUT

Bind

  • Local Parameter: body

  • Source parameter: body[attribute]

  • Type: string

  • Description: The email body

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 Orchestrator database
Server.error("Error while waiting for poweredOnVM_Task() to complete on VM '"+vm.name+"', exception found: "+errorCode);

Timeout 2 Scriptable Task Element

The Timeout 2 scriptable task element handles any exceptions that the vim3WaitToolsStarted action throws by setting the content of an email notification about the failure of the task, and writing the event in the Orchestrator log.

The following table shows the input and output parameter bindings that the Timeout 2 scriptable task element requires.

Table 3. Bindings of the Timeout 2 Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local Parameter: vm

  • Source parameter: vm[in-parameter]

  • Type: VC:VirtualMachine

  • Description: The virtual machine to power on.

errorCode

IN

Bind

  • Local Parameter: errorCode

  • Source parameter: errorCode[attribute]

  • Type: string

  • Description: Catch any exceptions while powering on a VM.

body

OUT

Bind

  • Local Parameter: body

  • Source parameter: body[attribute]

  • Type: string

  • Description: The email body

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 Orchestrator database
Server.error("Error while waiting for VMware tools to be up on VM '"+vm.name+"', exception found: "+errorCode);

OK Scriptable Task Element

The OK scriptable task element receives notice that the virtual machine has started successfully, sets the content of an email notification about the successful start of the virtual machine, and writes the event in the Orchestrator log.

The following table shows the input and output parameter bindings that the OK scriptable task element requires.

Table 4. Bindings of the OK Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local Parameter: vm

  • Source parameter: vm[in-parameter]

  • Type: VC:VirtualMachine

  • Description: The virtual machine to power on.

body

OUT

Bind

  • Local Parameter: body

  • Source parameter: body[attribute]

  • Type: string

  • Description: The email body

The OK scriptable task element requires the following scripted function.

body = "The VM '"+vm.name+"' has started successfully and is ready for use";
//Writes the following event in the Orchestrator database
Server.log(body);

Send Email Failed Scriptable Task Element

The Send Email Failed scriptable task element receives notice that the sending of the email failed, and writes the event in the Orchestrator log.

The following table shows the input parameter bindings that the Send Email Failed scriptable task element requires.

Table 5. Bindings of the Send Email Failed Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local Parameter: vm

  • Source parameter: vm[in-parameter]

  • Type: VC:VirtualMachine

  • Description: The virtual machine to power on.

toAddress

IN

Bind

  • Local Parameter: toAddress

  • Source parameter: toAddress[in-parameter]

  • Type: string

  • Description: The email address of the person to inform of the result of this workflow

emailErrorCode

IN

Create

  • Local Parameter: emailErrorCode

  • Source parameter: emailErrorCode[attrbute]

  • Type: string

  • Description: Catch any exceptions while sending an email

The Send Email Failed scriptable task element requires the following scripted function.

//Writes  the following event in the Orchestrator database
Server.error("Couldn't send result email to '"+toAddress+"' for VM '"+vm.name+"', exception found: "+emailErrorCode);

Send Email Scriptable Task Element

The purpose of the Start VM and Send Email workflow is to inform an administrator when it starts a virtual machine. To do so, you must define the scriptable task that sends an email. To send the email, the Send Email scriptable task element needs an SMTP server, addresses for the sender and recipient of the email, the email subject, and the email content.

The following table shows the input and output parameter bindings that the Send Email scriptable task element requires.

Table 6. Bindings of the Send Email Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local Parameter: vm

  • Source parameter: vm[in-parameter]

  • Type: VC:VirtualMachine

  • Description: The virtual machine to power on.

toAddress

IN

Bind

  • Local Parameter: toAddress

  • Source parameter: toAddress[in-parameter]

  • Type: string

  • Description: The email address of the person to inform of the result of this workflow

body

IN

Bind

  • Local Parameter: body

  • Source parameter: body[attribute]

  • Type: string

  • Description: The email body

smtpHost

IN

Create

  • Local Parameter: smtpHost

  • Source parameter: smtpHost[attribute]

  • Type: string

  • Description: The email SMTP server

fromAddress

IN

Create

  • Local Parameter: fromAddress

  • Source parameter: fromAddress[attribute]

  • Type: string

  • Description: The email address of the sender

subject

IN

Create

  • Local Parameter: subject

  • Source parameter: subject[attribute]

  • Type: string

  • Description: The email subject

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");

//Apply the method that sends the email message
myEmailMessage.sendMessage();
System.log("Sent email to '"+toAddress+"'");