Monday, 31 December 2012

vCenter Orchestrator WorkFlows


Assume that you want to deploy 50 OvDCs or you want to disconnect CD-ROM for 200 VMs. Are you going to do this manually ??? Here is the power of automation tools where vCO is one of them.

vCO automation is based on workflows. Each workflow is a flowchart which defines  how vCO will operate to achieve the desired result.

vCO by default has predefined workflows on installation. However, those  are providing basic functions and won't be sufficient for your custom requirements.

In case vCO Server failed during workflow execution, two options are available:

a. Resume workflow run once the server is back
b. Don't resume workflow run (set as FAILED)
vCO Web View

You can run workflows manually or schedule them to run automatically. Adding to this vCO has capability to create policies for access and authorization to workflows.

Manual execution of vCO workflows can be done using vCO client. Adding to this  vCO server has built-in web view component. This is used to provide front-end web access to orchestrator workflows (without any vCO client installable or java version). vCO web view component has one pre-built front-end page called weboperator.

Advantage of web view: You don't need to create users to access vCO client and define privileges to execute workflows without edit capability. With web view, users can only execute workflows.

To enable web view, from vCO client navigate to Administer > Web Views > Right-Click Web Operator > Publish.
You can also develop your own web view pages (instead of weboperator) and upload them to vCO server to start using them as front-end pages to vCO.

To browse Web View, use the URL http://<vCO-SERVER-IP>:8280/. From there you can select Web View List and choose the desired front-end page (e.g. weboperator). To browse directly to desired front-end page, use the following URL https://<vCO-SERVER-IP>:8281/vmo/<webview-name>/default.html (e.g https://10.156.13.168:8281/vmo/weboperator/default.html).

Note: You can login with vCO Admin Group users credentials.

Creating Workflows

To start with creating workflows, in vCO client you need to select Design from drop-down list. The first tab in inventory is workflow tab. There you can see the default workflows located inside folders. You can create your custom workflows in those folders or preferably, create your own folders (Right-Click > Add Folder).
Right-click on your custom folder and select New Workflow.
In General tab, 

1. Supply the name of your workflow as well as description 
2. For any major change in the workflow, you can  increase the version number. This is important to be able to revert back to the desired version when required. To revert back, you need to select Show Version History hyperlink. This will list all previous versions where you want to select the one to revert.

The core element in your workflow is Schema section. This is the place where the actual programming of your workflow takes place to achieve the desired functionality.
There are many programming elements provided by vCO which can be placed in Schema. All vCO elements are following drag-drop model where you drag them from inventory and drop them in schema. You need to drop the elements between Start & Stop .

Here is the list of common elements:  

- Workflow Element

This allows the usage of predefined workflows (either pre-installed with vCO server or custom created) in your custom workflow. Multiple workflow elements can be placed in your custom one.
Once dropped in Schema, new window will open to select the desired function of your workflow element.  For example, searching with 'Org' keyword, will list all workflows having this keyword (add an organization, upgrade an org vDC capacity, etc).

Each Workflow Element is made of a combination of other Workflows, Action Elements, Sleep Elements, Scriptable Tasks, etc.

- Action Element

Instead of executing full workflow element, you may be looking for specific one-step action such as listing hard disks in VM or listing VMs in a vAPP. For this purpose, you can use Action Element instead of Workflow Element.

In fact Action Element is running a predefined script in the background to do the desired function. If you try to edit the action element and verify the Scripting tab, you will find out the script used. E.g. GetVdcOrg action element in below snapshot is running the script

actionResult = System.getModule("com.vmware.library.vCloud.operation").getVdcsOrg(targetEntityArg) ;
- Scriptable Task

Sometimes you may need to use actions which aren't available in vCO. For this purpose, you may use Scriptable Task and write your own java script to perform the desired function. 
 
Note: Another option is to create your own custom Action Elements.

- Sleep Element

This is used to introduce delays between elements which is required sometimes due to the processing time. We will see this element later when we give detailed example.

- Decision Element

This is acting as IF statement in C/Visual Basic programming where you have two conditions and you want different actions for each one.

In fact before creating schema, there is an important element needs to be present. We said that schema defines the algorithm of your workflow. But what are the elements which will be processed by schema ??

Those are called variables which should be ready before creating schema. There are three types of variables used in vCO:

- Input Variables  (IN Tab) (those should be entered manually by users when workflow is executed)
- Output Variables (OUT Tab) (those are variables passed to the next element in the workflow. It possible as well to pass them between workflows) 
- Attributes (General Tab) (those can be input or output variables however they are pre-set and won't require manual intervention. Those are local to the workflow)


Each type of the above variables can be classified as string, number, Boolean, vcloud:vapp, VC:VM, vcloud:VM, etc. Also, each of these types can be single unit or array.

Variables are bonded to vCO elements in Schema using Visual Binding section.
Finally, I would like to touch on how to present input variables to users when executing workflows. This can customized from Presentation section of your workflow.

From this section you can set the display order of the input variables and display name of each variable. One option I liked is 'Properties'. This enables you to set the properties of input variable such as mandatory, hide input, show input, max value, minimum value, default value, etc. Although this is optional but it very important. For example what will happen if the user executed the workflow and left the input variables 'null'. This will lead to unexpected and undesirable output which can be avoided by setting mandatory option in the properties (the workflow won't execute without entering this variable).
Also, you can group input variables based on your classifications. You will see this classification during workflow execution. You can do this using Right-Click on Display Group and Select New Step.