Friday, August 5, 2016

vRealize Orchestror, "Hello World!" and VM query

In first vRealize Orchestartor post, we connected Orchestrator to vCenter

Now it's time to create our first workflows.

With new tool, you always need to do a 'Hello World' first, so let's do it.

I have created a folder called 'vLAB', and under that, we create new workflow.



Give it a name 'Hello World'



In workflow editor, on Schema tab, drag'n'drop 'Scriptable task' to workflow, between start and end icons.



Click Pencil icon on top of 'Scriptable task' to edit it.


In script editor, on Scripting tab, write:
System.log("Hello World!");

And hit Close.



Now we can run our Workflow, by clicking 'Run' button, on Schema tab of Workflow editor.



And in Log tab, we can see output! We have successfully run our first workflow!


Cool! Now let's do something more productive. Let's get all VM's that we have in our VMware environment.

So, create new Workflow named 'Get All Virtual Machines' and add action 'getAllVMS', that is built-in action, and then add Scriptable Task, so it should look like this:



getAllVMs action will return all VMware Virtual Machines, so we need to set up Attribute (predefined variable) to our workflow. So, go to 'General' tab in workflow editor, and add new Attribute by clicking 'A+' icon



It will create attribute named 'att0'. It's a good idea to rename it, so click that name to rename it, we will name it 'AllVMs'



Then click on 'string', to change type of this Attribute. Set type to 'Array of...' and search 'VC:VirtualMachine'.



Now we need to direct values from 'getAllVMs' action to our attribute 'AllVMs'. So go back to 'Schema' tab, and hit Pencil icon on top of 'getAllVMs' action.

Go to 'Visual binding' tab, select 'actionResult' and 'drag' it to top of 'AllVMs', to connect it.



Next, edit 'Scriptable Task', and go to 'Visual Binding'.

Drag 'AllVMs to empty space in center of windows, at 'IN' side, so it should look like this:



Now we can use information inside 'AllVMs' in our Scriptable task.

Go to 'Script' tab, and write:
System.log(AllVMs);

(Do note, since this is javacript, almost everything is case sensitive....)



And now we can run our workflow, and we should get list of our VMs in 'Log' tab.



So, we have made our first two Workflows. 

In next posts, I'll show how to utilize that data, to do actions against those VMs.