Skip to content

Generic elements

These are the elements you’ll use in almost every workflow. To add one, drag it from the Generic group onto the canvas, or onto an arrow to drop it between two elements. Select it to edit it in the properties pane on the right. Most elements have a Business status box on their Details section: a short label the run shows while it is on that element.

Which arrows an element can have. Most elements have one outgoing arrow, to the next element, and an optional red dashed exception arrow for when they fail. A few are different:

  • Decision: a true arrow and a false arrow, nothing else.
  • Switch: one arrow per case plus the default. When you select it, there’s no exception handle next to it, unlike a scriptable task.
  • End workflow and Throw exception: no outgoing arrow at all. Throw exception fails the run with the one string you bind under Exception handling.
  • Default error handler: no incoming arrow. It catches failures from every element that has no exception arrow of its own.

The examples come from small lab workflows in VCF Orchestrator Guide/Reference and VCF Orchestrator Guide/Chapter 3. The first one, Describe a running VM, uses four of them at once:

Canvas of Describe a running VM: Start, Get the VM facts (action element, a gear with a play symbol), Read the power state (scriptable task), Which state? (switch), then Describe a VM (workflow element) to End, and a second path from the switch down to Explain the skip and back to End.
Figure R.1. Describe a running VM: an action element, a scriptable task, a switch, and a workflow element.

Run it on a powered-on VM and it returns rockylinux9: poweredOn, 1 vCPU, 2048 MB. Run it on a powered-off VM and it returns testvm01 is poweredOff, so it was skipped.

Scriptable task

Runs a piece of script, in JavaScript by default. Its Inputs/Outputs section says which workflow variables the script reads and writes; anything else in the script is local. Use it for the small glue between steps, like Read the power state in figure R.1. Once the same code appears in two workflows, move it into an action.

Used in 3.2 Scriptable tasks and the schema canvas.

Decision

Splits the path in two: the run follows the green arrow when the decision is true, and the red dashed arrow when it is false. The Decision type switch picks how you write the test. In Simple mode you pick a variable, a comparison, and a value. Turn it off and you write a script that returns true or false, in JavaScript or any other runtime the server offers.

Try again? selected on the canvas of Wait for a web page. Properties: Decision type switch labelled Simple, turned off; input attemptsLeft bound to attemptsLeft; Decision section with Runtime Environment JavaScript and the script return attemptsLeft > 0;
Figure R.2. Try again?, a decision with a one-line script, in Wait for a web page.

Older guides call the scripted version a custom decision. In 9.1 it is the same Decision element with Simple turned off.

Used in 3.3 Decisions, switches, and loops.

Decision activity

A decision whose answer comes from a workflow or an action. Under Select Activity you pick one; the element runs it, and under Decision you pick one of its outputs and the value that means true, such as isOn is true. Use it when the same yes-or-no check is shared by several workflows.

Canvas of Describe a VM if it is on: Start, Is it on? (decision activity), Describe it to End along the top; a red dashed arrow down to Explain the skip and its own End; a yellow note beside the lower path reads A powered-off VM is skipped, not failed: the run still completes. Is it on? is selected: Inputs vm bound to vm; Decision: If isOn is true.
Figure R.3. Describe a VM if it is on: a decision activity that runs Is a VM powered on, and a workflow note.

The lab workflow Is a VM powered on has one output, isOn, and nothing else; Describe a VM if it is on reuses it. After a reload, Select Activity can show Select workflow or action even though it’s set; the inputs and the decision below it show what it runs.

Switch

Picks one of several paths. On the Cases tab, each case compares a variable with a value; the first match wins, and By default go to catches everything else. Use it instead of a chain of decisions.

Which state? selected. Cases tab: If powerState equals poweredOn then go to item4: Describe a VM; By default go to item5: Explain the skip; an Add new switch case button above.
Figure R.4. Which state?, a switch with one case and a default path.

Used in 3.3 Decisions, switches, and loops.

Action element

Calls an action. The action’s inputs and return value show up as the element’s inputs and outputs, ready to bind. In figure R.1, Get the VM facts calls com.vcfguide.chapter4/getVmFacts and stores the result in the variable facts. This is how one action is shared by many workflows.

Used in 4.2 Writing and reusing actions.

Workflow element

Runs another workflow and waits for it to finish. Its inputs and outputs map onto the caller’s variables. In figure R.1, Describe a VM runs the chapter 3 workflow of the same name. Use it to build big workflows from small, tested ones.

Foreach element

Runs a workflow once for every item in an array, one after another. For each item in array picks the array; inputs bound with a * in front, like *vm, take one item per run, and outputs bound the same way collect one result per run. Turn on Iteration error handler to carry on when one run fails.

Describe a VM selected on the canvas of Describe several VMs; item1: Foreach element. For each item in array: vm. Workflow: Describe a VM. Input vm (VC:VirtualMachine) bound to *vm; output summary (Array/string) bound to summary; Iteration error handler switched off.
Figure R.5. The foreach element of Describe several VMs, running Describe a VM once per VM.

Used in 3.3 Decisions, switches, and loops.

Asynchronous element

Starts a workflow and carries on without waiting. Its one output, under Options > Output Options, is wfToken, a WorkflowToken you can use later to check the run or wait for it. The element takes the name of the workflow it calls.

Start a VM description: Start, Describe a VM (asynchronous element), Report the token, End. Output Options: wfToken (WorkflowToken) bound to describeToken. Inputs: vm bound to vm.
Figure R.6. Start a VM description: an asynchronous element that starts Describe a VM and binds its token.

Used in 3.8 Asynchronous and nested workflows.

Nested workflows

Starts several workflows at the same time and waits until all of them have finished. Click Add workflow once per child, pick the workflow, and bind its inputs and outputs under its own Workflow row. Use it when the steps don’t depend on each other, such as preparing three VMs at once.

Canvas of Describe two VMs at once: Start, Describe both (nested workflows), Report, End. Describe both is selected; Add workflow button; the first Workflow row, Describe a VM, is expanded: input vm bound to firstVm, output summary bound to firstSummary; a second Describe a VM row below.
Figure R.7. Describe two VMs at once: one nested workflows element runs Describe a VM twice, for firstVm and secondVm.

Run it on two VMs and Report logs both summaries, such as rockylinux9: poweredOn, 1 vCPU, 2048 MB and testvm01: poweredOff, 2 vCPU, 4096 MB.

Used in 3.8 Asynchronous and nested workflows.

Schedule workflow

Creates a scheduled task that runs a workflow once, later. Under Options, bind the input workflowScheduleDate to a Date; the output scheduledTask is the Task it created. The current run doesn’t wait. The scheduled run shows up under Activity > Scheduled; for a repeating schedule, see the recipe below.

Canvas of Describe a VM later: Start, Schedule the description (schedule workflow element), Report, End. Options: workflowScheduleDate (Date) bound to runAt; scheduledTask (Task) bound to scheduledTask. Workflow: Select workflow. Inputs: vm bound to vm.
Figure R.8. Describe a VM later: a schedule workflow element, with the date bound to runAt.

In the lab, a run with runAt set five minutes ahead completes in under a second, and Describe a VM runs on its own at the set time. As with the asynchronous element, the Workflow box can show Select workflow after a reload; the element’s inputs show what it calls.

Related: 7.7 Scheduling workflows.

User interaction

Pauses the run and asks a person for input, such as an approval. Under Options, timeout.date sets a deadline and the security.* inputs say who may answer. Under Form Inputs, list the variables the person fills in; the workflow gets an extra tab, named after the element, where you lay out their form. The question appears under Activity > Waiting for Input. Without a deadline the run can wait forever; when the deadline passes, the element fails, so give it an exception path.

Ask for approval selected in Approve a VM description. Options: security.group (LdapGroup), security.assignees (Array/LdapUser), security.assignee.groups (Array/LdapGroup) unbound, timeout.date bound to approvalDeadline. Form Inputs: approved (boolean) and approverComment (string), and an Edit Input Form button.
Figure R.9. Ask for approval, the user interaction of recipe 3.9.

Used in 3.9 User interactions and approvals.

Waiting timer

Pauses the run until the date in its timer.date input. While it waits, the run is stored in the database and uses no thread, so it can safely wait for days.

Waiting timer selected between Work out the wake-up time and Carry on. Inputs: timer.date of type Date bound to wakeDate.
Figure R.10. The waiting timer of Pause until an hour, with timer.date bound to wakeDate.

Used in 3.7 Waiting tasks and custom events.

Waiting event

Pauses the run, without a thread, until a trigger fires: for example the end of a vCenter task, made with task.createEndOfTaskTrigger(timeout) in a scriptable task just before it. Bind the trigger to its one input, trigger.ref (Trigger). Always give the trigger a timeout, in seconds.

Snapshot a VM and wait — Start the snapshot
snapshotTask = vm.createSnapshot_Task("vcfguide-sample", "VCF Orchestrator Guide sample, removed straight away", false, false);
// The trigger fires when the task ends, or after the timeout (seconds)
taskTrigger = snapshotTask.createEndOfTaskTrigger(300);
Canvas of Snapshot a VM and wait: Start, Start the snapshot, Wait for the task (waiting event: an hourglass with an envelope), Report and clean up, End. Wait for the task is selected (item3: Waiting event): Business status Waiting for vCenter; Inputs: trigger.ref (Trigger) bound to taskTrigger.
Figure R.11. Snapshot a VM and wait: a waiting event with trigger.ref bound to the task's trigger, and a business status.

While it waits, the run shows as Waiting Signal with the business status Waiting for vCenter; in the lab, a snapshot of testvm01 took 8 seconds, and the last step removed it again.

Used in 3.7 Waiting tasks and custom events.

End workflow

Ends the run successfully. A workflow can have several, one at the end of each path.

Throw exception

Ends the run as failed. It is the end element with End mode set to Error, throw an exception; the message comes from the variable under Exception handling. Put it at the end of an error path so callers can see what went wrong.

Throw exception element selected after Try again?. Details: End mode Error, throw an exception; Exception handling: Output exception binding errorMessage.
Figure R.12. The Throw exception element of Wait for a web page.

Used in 3.4 Handling errors and exceptions.

Default error handler

Catches any error that no element handles itself. It sits apart from the main path, starts its own short path, such as logging or cleaning up, and then ends the run. A workflow can have one.

Canvas of Find a VM by name: Find the VM to End along the top; a red dashed arrow from Find the VM down to Explain the failure and a Throw exception element; at the bottom, a default error handler (a diamond with a red X) leading to Log unexpected error and a second Throw exception element.
Figure R.13. Find a VM by name: an exception path for one element, and a default error handler for the rest.

Used in 3.4 Handling errors and exceptions.

Workflow note

A coloured box for comments on the canvas. It does nothing at run time. Drag it onto an empty part of the canvas and double-click it to type. Use it to label groups of elements so the next person understands the schema at a glance, like the note in figure R.3.