This article is based on the Java-client in vRealize Orchestrator v6/7. For an updated article that contains the instructions for the HTML-based client in version 7.7 and version 8 click here.
This article will help you creating your first vRealize Orchestrator Workflow. The starting point for the article is that you have vRealize Orchestrator installed and that you can start and login to the Orchestrator Client. (vRealize Orchestrator was formerly named vCenter Orchestrator.)
If you follow this article you create a workflow in vRealize Orchestrator that makes modifications to an existing Virtual Machine.
– Shut Down the Guest Operating System
– Rename the Virtual Machine
– Modify the memory to a new value
– Power On the Virtual Machine
After logging in to the Orchestrator Client select the Design-mode. Next open the list of available workflows and expand the existing folder structure of the library. Create a new folder to store your workflows.
Right click your new folder and select Create New Workflow.
In this example I have named the new workflow ModifyVM.
In the General-tab click the add New Attribute icon. In the line of the newly added attribute click the default name of att0 and change it to newNameModified. Leave the type to the default of String.
Important: This attribute will be used to store the value of the modified new name that we generate elsewhere in this workflow. In all the elements you create in this workflow the variables used in those elements are local and only available to that element so we sometimes need a global variable for the workflow and this is where we declare that.
The next thing we need is an input parameter to be able to tell the workflow which Virtual Machine we want to modify. Select the Inputs-tab and click the Add Input Parameters icon.
Click the new arg_in_0 entry and rename it to VM. Next click the String-type and change it to the VC:VirtualMachine type. The Virtual Machine we want to modify is represented not simply by a text-based string we could use but it references an object in your vCenter Inventory. As you can see in the picture above you type vc:virtualm in the search box to filter the list and quickly find the correct type.
Next create another input parameter with the name of newName and leave the default type of String in place. This is a simple text-based string of characters that represents the new name of the Virtual Machine. And the third step is to create another input parameter with the name of newMemory and set the type to Number. This is the type that will only allow numbers to be entered. Your list of input parameters should match this picture:
Next click the Schema-tab and drag a Workflow-element in between the start and end icons.
In the element chooser dialog window type shut in the search window, the workflow we need will be found: Shut down guest OS and wait. Select this workflow from the list.
Note: This workflow will fail if the Virtual Machine is in a powered off state because in that power state the shutdown guestOS action doesn't work. It would be possible to add logic into the workflow to detect the power state of a virtual machine but that is beyond the scope of this article to explain a simple first workflow.
Hover your mouse over the top of the newly added workflow element and select the pencil-icon to edit the element.
Next click the IN-tab. Click the line for the vm local parameter and link it to the VM parameter that we have created in the main workflow
Next drag a Scriptable Task in between the newly created shutdown element and the end of the workflow. Edit this scriptable task the same way as you did with the workflow.
Click the IN-tab and click the icon to link an input parameter to the main workflow input parameter named newName.
Next click the OUT-tab and link the workflow attribute with the name newNameModified to this script as an output parameter.
Click the Scripting-tab and enter this line of code into the scripting area:
var newNameModified = newName + “-Renamed”;
As you can see in the image below the parameter names we used are represented in purple. If not than check the syntax. The automatically turn purple when the name matches the correct parameter name.
You would not really need this part of the workflow but I have added it to show you how to add a simple scriptable task. It takes your new name and adds the -Renamed suffix.
Click Close to finish editing this element.
Double click the name Scriptable Task and rename it to Modify Name. This will help to identify scriptable task elements and makes the workflow easier to read.
Next drag another workflow element in between the scripting element and the end of the workflow. In the chooser search field type rename and select the Rename virtual machine workflow. Edit this workflow element and link the two Input-parameters we need to the VM input parameter of the main workflow and to the newNameModified attribute of the main workflow.
The next workflow element to drag into the workflow in between the Rename-element and the End-object is a workflow that you will find under the name of: Change RAM. For this workflow assign the two parameters that reference the VM and the new amount of RAM to assign.
The final workflow to add is the one to power on the Virtual Machine. Drag a new workflow element into your workflow near the end and search for the workflow with the name of: Start virtual machine and wait. This workflow also needs input parameters. Edit the workflow and assign the VM input parameter. For the optional Host-parameter click not set and assign it a NULL-value. We don't need to specify the host where to start the VM.
Your workflow should now look similar to the one in this picture.
Click Save and close.
In the dialog window that explains that you can update the version history for now just click Continue anyway.
It is now time to execute this workflow. Right-click your workflow and select Start workflow.
In the dialog box you will be asked to select a virtual machine, enter a new name and a new amount of RAM (in Mb).
You will be able to see in the schema-pane that the workflow elements that are executed are light-green when running.
While the workflow runs the icon of the workflow runner will be a green arrow-point. When the execution was successful it will turn into a green check box and when it failed it will display a red circle with a white X.
When the workflow is done go to the vSphere Web Client and check the result of your work.
Please enter a valid email!