Creating your First Workflow

vRealize Orchestrator workflows allow you to perform a variety of tasks.  Each workflow can have multiple inputs and return multiple outputs. This lesson covers the creation and execution of a simple workflow.

Create a New Workflow

  1. Make sure Design view is selected
  2. Select Workflow tab
  3. Right Click on Workshop workflow folder
  4. Click on New workflow

Naming a Workflow

  1. Type My First Workflow for the Workflow name
  2. Click the Ok button

Configuring the New Workflow: Schema

  1. Select the Schema tab

Workflow schemas are made up of elements. Take a moment to look through the list of available elements.

Configuring the New Workflow: Schema

  1. In the Generic section, Select Scriptable task 
  2. Drag the Scriptable task element onto the Schema between the two existing elements on the canvas

The green arrow represents the Start workflow element and the one to the far right is the End workflow element.
These 2 elements are mandatory, and must be present for the workflow to run.

Configuring the New Workflow: Inputs

  1. Select the Inputs tab
  2. Click the Add parameter icon to add a parameter. The name will default to arg_in_0

Parameters within vRealize Orchestrator are basically input and output variables of a workflow in the simplest of terms.  

Input parameters are needed for most workflows and are values that are passed into the workflow when it starts via a user, application, another workflow, or even an action.

  1. Click on arg_in_0 to change the parameter name
  2. Type vm for the Attribute name to update the name of this parameter
  3. Click the Ok button

Configuring the New Workflow: Inputs

  1. Click on string in the Type column to open the "Select a type..." window
  2. Type VC:VirtualMachine in the Filter box
  3. Scroll Up
  4. Select the VC:VirtualMachine Type (Note: this value should be at the top of the filtered list)
  5. Click the Accept button

Configuring the New Workflow:Description

  1. Double-click on the area under the Description column, and type My vm in the Description field

The description is automatically saved.

Editing a Scriptable Task

  1. Select the Schema tab
  2. Click the Scriptable task to open it in the lower pane
  3. Click the Undock icon in the corner of the lower pane to open the contents in a larger window. This is used because of the low resolution in the lab.

Visual Bindings

  1. Select the Visual Bindings tab
  2. Select the vm input parameter
    Drag it over to the IN field to create the binding

Bindings allow you to connect workflow inputs or outputs to local parameters. This is needed so the local element can process the parameter.  

In this case, the input parameter is passed to a local parameter so it can be used within the Scriptable Task element that is part of the workflow. It is standard practice to have all parameters bound in a workflow. If a variable is not bound anywhere, a warning will appear when the workflow is saved - failing validation. The warning message indicates the parameter that is not bound.

Local IN Parameters

  1. Select the IN tab

Notice that now there is a local IN parameter for the Scriptable task.
Bindings can be done either in Visual Binding tab or here in IN or OUT tabs.

Scriptable Task: Scripting

 

  1. Select the Scripting tab 
  2. Enter the following code (if drag and drop is used, make sure to keep the focus in the scripting tab all the time):
System.log(" Name: " + " " + vm.summary.config.name);
System.log(" Hostname: " + " " + vm.summary.guest.hostName);
System.log(" IP Address: " + " " + vm.summary.guest.ipAddress);
System.log(" Description for VM: " + " " + vm.summary.config.annotation);
System.log(" Number of CPU: " + " " + vm.summary.config.numCpu);
System.log(" Amount of Memory in MB: " + " " + vm.summary.config.memorySizeMB);
System.log(" Number of Network Adapters: " + " " + vm.summary.config.numEthernetCards);
System.log(" Number of Disks: " + " " + vm.summary.config.numVirtualDisks);
System.log(" Guest OS: " + " " + vm.summary.config.guestFullName);
System.log("Is template: " + " " + vm.summary.config.template);

The code will log information available from the API of the virtual machine entered as input into the workflow.  The information logged by the workflow includes:

  • The virtual machine name
  • The virtual machine hostname
  • The virtual machine ip address
  • The virtual machine description field
  • The cpu count for the virtual machine
  • The memory count for the virtual machine
  • The network adapter count for the virtual machine
  • The disk count for the virtual machine
  • The virtual machine guest OS full name
  • Whether or not the virtual machine is marked as a template

It is also taking this data and formatting it in a much more readable format.  

  1. Click the Red X button to close the window and return it to the dock

Configuring the New Workflow: Validation

  1. Click the Validate icon

This allows vRealize Orchestrator to check the workflow and make sure there are not any issues, such as parameters that are not bound or used.

  1. Click the Close button

Save and Close

  1. Click the Save and close button

Running Your Workflow

  1. Click the Workflow tab
  2. Browse to HOL > 1921-05-CMP > Module 2 > My First Workflow
  3. Click on the Start workflow icon

Running Your Workflow

  1. Click Not set to select the virtual machine to use as input into the workflow

Running Your Workflow

  1. Navigate to vSphere vCenter Plu-in > https://vcsa-01a.corp.local:443/sdk > Datacenters > RegionA01 > vm > util-01a
  2. Click the Select button

Running Your Workflow

  1. Click the Submit button

Running Your Workflow

When the workflow completes, the workflow token shows a green check mark next to it.  This indicates successful execution of the workflow.