Bindings define how the simple workflow example's action elements process input and output parameters.

The Take Snapshots of All Virtual Machines in a Resource Pool workflow requires the following input and output parameter bindings. You also define the JavaScript functions for the scriptable task elements.

In cases in which you bind to existing parameters, the binding inherits the type and description values from the original parameter.

Initializing Scriptable Task

The Initializing scriptable task element initializes the attributes of the workflow. The following table shows the input and output parameter bindings that the Initializing scriptable task element requires.

Table 1. Bindings of the Initializing Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

resourcePool

IN

Bind

  • Local parameter: resourcePool

  • Source parameter: resourcePool[in-parameter]

  • Type: VC:ResourcePool

  • Description: The resource pool containing the virtual machines of which to take snapshots

allVMs

OUT

Create

  • Local parameter: allVMs

  • Source parameter: allVMs[attribute]

  • Type: Array/VC:VirtualMachine

  • Description: The virtual machines in the resource pool.

numberOfVMs

OUT

Create

  • Local parameter: numberOfVMs

  • Source parameter: numberOfVMs[attribute]

  • Type: number

  • Description: The number of virtual machines found in the resourcePool

vmCounter

OUT

Create

  • Local parameter: vmCounter

  • Source parameter: vmCounter[attribute]

  • Type: number

  • Description: The counter of the virtual machines inside the array

vm

OUT

Create

  • Local parameter: vm

  • Source parameter: vm[attribute]

  • Type: VC:VirtualMachine

  • Description: The current virtual machine having a snapshot taken

snapshotVmArray

OUT

Create

  • Local parameter: snapshotVmArray

  • Source parameter: snapshotVmArray[attribute]

  • Type: Array/VC:VirtualMachine

  • Description: The Array of virtual machines of which snapshots have been taken

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

VMs to Process? Decision Element

The VMs to Process? decision element determines whether any virtual machines of which to take snapshots exist in the resource pool. The following table shows the bindings that the VMs to Process? decision element requires.

Table 2. Bindings of the VMs to Process? Decision Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

numberOfVMs

Decision

Bind

  • Source parameter: numberOfVMs[attribute]

  • Decision statement: Greater than

  • Value: 0.0

  • Description: The number of virtual machines found in the resourcePool

Pool Has No VMs Scriptable Task Element

The Pool Has No VMs scriptable task element logs the fact that the resource pool contains no eligible virtual machines in the Orchestrator database. The following table shows the bindings that the Pool Has No VMs scriptable task element requires.

Table 3. Bindings of the Pool Has No VMs Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

resourcePool

IN

Bind

  • Local parameter: resourcePool

  • Source parameter: resourcePool[in-parameter]

  • Type: VC:ResourcePool

  • Description: The resource pool containing the virtual machines of which to take snapshots.

The Pool Has No VMs scriptable task element performs the following scripted function.

//Writes the following event in the Orchestrator database
Server.warn("The specified ResourcePool "+resourcePool.name+" does not contain any VMs.");

Remaining VMs? Custom Decision Element

The Remaining VMs? custom decision element determines whether any virtual machines of which to take snapshots remain in the resource pool. The following table shows the bindings that the Remaining VMs? custom decision element requires.

Table 4. Bindings of the Remaining VMs? Custom Decision Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

numberOfVMs

IN

Bind

  • Source parameter: numberOfVMs[attribute]

  • Decision statement: Greater than

  • Value: 0.0

  • Description: The number of virtual machines found in the resourcePool

vmCounter

IN

Bind

  • 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;
}

getVMDisksModes Action Element

The getVMDisksModes action element obtains the modes of the disks running in a virtual machine. The following table shows the bindings that the getVMDisksModes action element requires.

Table 5. Bindings of the getVMDisksModes Action Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local parameter: vm

  • Source parameter: vm[attribute]

  • Type: VC:VirtualMachine

  • Description: The current virtual machine having a snapshot taken

actionResult

OUT

Create

  • Local parameter: actionResult

  • Source parameter: vmDisksModes[attribute]

  • Type: Array/String

  • Description: The current Disks Modes of the virtual machine

errorCode

Exception

Create

Local parameter: errorCode

Create Snapshot? Custom Decision Element

The Create Snapshot? custom decision element determines whether to take snapshots of virtual machines, depending on the disk modes of the virtual machines. The following table shows the bindings that the Create Snapshot? custom decision element requires.

Table 6. Bindings of the Create Snapshot? Decision Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vmDisksMode

IN

Bind

  • Local parameter: vmDisksMode

  • Source parameter: vmDisksMode[attribute]

  • Type: Array/String

  • Description: The current Disks Modes of the virtual machine

vm

IN

Bind

  • Local parameter: vm

  • Source parameter: vm[attribute]

  • Type: VC:VirtualMachine

  • Description: The current virtual machine having a snapshot taken

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;
}

Create a snapshot Workflow Element

The Create a snapshot workflow element takes snapshots of virtual machines. The following table shows the bindings that the Create a snapshot workflow element requires.

Table 7. Bindings of the Create a snapshot Workflow Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local parameter: vm

  • Source parameter: vm[attribute]

  • Type: VC:VirtualMachine

  • Description: An active virtual machine of which to take a snapshot.

name

IN

Create

  • Local parameter: name

  • Source parameter: snapshotName[attribute]

  • Type: string

  • Description: The name for this snapshot. The name does not need to be unique for this virtual machine.

description

IN

Create

  • Local parameter: description

  • Source parameter: snapshotDescription[attribute]

  • Type: string

  • Description: A description for this snapshot.

memory

IN

Create

  • Local parameter: memory

  • Source parameter: snapshotMemory[attribute]

  • Type: Boolean

  • Value: no

  • Description: If TRUE, a dump of the internal state of the virtual machine (a memory dump) is included in the snapshot.

quiesce

IN

Create

  • Local parameter: quiesce

  • Source parameter: snapshotQuiesce[attribute]

  • Type: Boolean

  • Value: yes

  • 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.

snapshot

OUT

Create

  • Local parameter: snapshot

  • Source parameter: NULL

  • Type: VC:VirtualMachineSnapshot

  • Description: The snapshot taken.

errorCode

Exception

Create

Local parameter: errorCode

VM Snapshots Scriptable Task Element

The VM Snapshots scriptable task element adds the snapshots to an array. The following table shows the bindings that the VM Snapshots scriptable task element requires.

Table 8. Bindings of the VM Snapshots Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local parameter: vm

  • Source parameter: vm[attribute]

  • Type: VC:VirtualMachine

  • Description: An active virtual machine of which to take a snapshot.

snapshotVmArray

IN

Bind

  • Local parameter: snapshotVmArray

  • Source parameter: snapshotVmArray[attribute]

  • Type: Array/VC:VirtualMachine

  • Description: The Array of virtual machines of which snapshots have been taken

snapshotVmArray

OUT

Bind

  • 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 Orchestrator database 
Server.log("Successfully took snapshot of the VM '"+vm.name);
//Inserts the VM snapshot in an array
snapshotVmArray.push(vm);

Increment Scriptable Task Element

The Increment scriptable task element increments the counter that counts the number of virtual machines in the array. The following table shows the bindings that the Increment scriptable task element requires.

Table 9. Bindings of the Increment Scriptable Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vmCounter

IN

Bind

  • Local parameter: vmCounter

  • Source parameter: vmCounter[attribute]

  • Type: number

  • Description: The counter of the virtual machines inside the array

allVMs

IN

Bind

  • Local parameter: allVMs

  • Source parameter: allVMs[attribute]

  • Type: Array/VC:VirtualMachine

  • Description: The virtual machines in the resource pool.

vmCounter

OUT

Bind

  • Local parameter: vmCounter

  • Source parameter: vmCounter[attribute]

  • Type: number

  • Description: The counter of the virtual machines inside the array

vm

OUT

Bind

  • Local parameter: vm

  • Source parameter: vm[attribute]

  • Type: VC:VirtualMachine

  • Description: The current virtual machine having a snapshot taken

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];

Log Exception Scriptable Task Element

The Log Exception scriptable task element handles exceptions from the workflow and action elements. The following table shows the bindings that the Log Exception scriptable task element requires.

Table 10. Bindings of the Log Exception Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

vm

IN

Bind

  • Local parameter: vm

  • Source parameter: vm[attribute]

  • Type: VC:VirtualMachine

  • Description: The current virtual machine having a snapshot taken

errorCode

IN

Bind

  • 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 Orchestrator database
Server.error("Coudln't snapshot the VM '"+vm.name+"', exception: "+errorCode);

Set Output Scriptable Task Element

The Set Output scriptable generates the workflow's output parameter, that contains the array of virtual machines of which snapshots have been taken. The following table shows the bindings that the Set Output scriptable task element requires.

Table 11. Bindings of the Set Output Task Element

Parameter Name

Binding Type

Bind to Existing or Create Parameter?

Binding Values

snapshotVmArray

IN

Bind

  • Local parameter: snapshotVmArray

  • Source parameter: snapshotVmArray[attribute]

  • Type: Array/VC:VirtualMachine

  • Description: The Array of virtual machines of which snapshots have been taken

snapshotVmArrayOut

OUT

Bind

  • Local parameter: snapshotVmArrayOut

  • Source parameter: snapshotVmArrayOut[out-parameter]

  • Type: Array/VC:VirtualMachine

  • Description: The Array of virtual machines of which snapshots have been

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;