Vra
Vra
Vra
Table of Contents
Lab Overview - HOL-1921-06-CMP - vRealize Orchestrator - Advanced ............................ 2
Lab Guidance .......................................................................................................... 3
Module 1 - Creating Advanced vRealize Orchestrator Workflows (45 min)........................ 9
Introduction........................................................................................................... 10
Prompting User Input In Workflows ....................................................................... 12
Using Conditional Execution and Loops................................................................. 27
Bring it together: Sample Advanced Workflow ...................................................... 42
Asynchronous Workflows....................................................................................... 80
Conclusion............................................................................................................. 90
Module 2 - Integrating with REST APIs (45 min) .............................................................. 92
Introduction........................................................................................................... 93
Configuring the vRealize Orchestrator Plug-in for REST ........................................ 95
Invoking REST operations via vRealize Orchestrator........................................... 106
Conclusion........................................................................................................... 114
Module 3 - Launching Workflows from Outside vRealize Orchestrator (45 min)............ 116
Introduction......................................................................................................... 117
Start a simple workflow....................................................................................... 123
Start a workflow with complex inputs ................................................................. 134
Conclusion........................................................................................................... 148
Module 4 - Automating vRealize Automation with vRealize Orchestrator (45 min) ....... 150
Introduction......................................................................................................... 151
Explore out-of-the-box workflows ........................................................................ 153
Create an automated onboarding process .......................................................... 166
Conclusion........................................................................................................... 193
Module 5 - Running In-Guest Operations with vRealize Orchestrator (45 min) ............. 195
Introduction......................................................................................................... 196
Prepare the environment .................................................................................... 197
Use Guest Operations ......................................................................................... 202
Use Guest Script Manager................................................................................... 219
Clean Up the Environment .................................................................................. 250
Conclusion........................................................................................................... 252
Module 6 - Error Handling and Troubleshooting (45 min) .............................................. 254
Introduction......................................................................................................... 255
Error handling and why is it important? .............................................................. 257
Adding Error Handling to workflows .................................................................... 261
Basic Workflow Troubleshooting .......................................................................... 297
Logging in Workflows .......................................................................................... 311
Conclusion........................................................................................................... 320
HOL-1921-06-CMP Page 1
HOL-1921-06-CMP
Lab Overview -
HOL-1921-06-CMP -
vRealize Orchestrator -
Advanced
HOL-1921-06-CMP Page 2
HOL-1921-06-CMP
Lab Guidance
Note: It may take more than 90 minutes to complete this lab. You should
expect to only finish 2-3 of the modules during your time. The modules are
independent of each other so you can start at the beginning of any module
and proceed from there. You can use the Table of Contents to access any
module of your choosing.
The Table of Contents can be accessed in the upper right-hand corner of the
Lab Manual.
Use vRealize Orchestrator to perform advanced tasks such as integrating with REST
APIs, perform actions in guest operating systems using VMware Tools and automate
vRealize Automation tasks.
Lab Captains:
HOL-1921-06-CMP Page 3
HOL-1921-06-CMP
This lab manual can be downloaded from the Hands-on Labs Document site found here:
http://docs.hol.vmware.com
This lab may be available in other languages. To set your language preference and have
a localized manual deployed with your lab, you may utilize this document to help guide
you through the process:
http://docs.hol.vmware.com/announcements/nee-default-language.pdf
1. The area in the RED box contains the Main Console. The Lab Manual is on the tab
to the Right of the Main Console.
2. A particular lab may have additional consoles found on separate tabs in the upper
left. You will be directed to open another specific console if needed.
3. Your lab starts with 90 minutes on the timer. The lab can not be saved. All your
work must be done during the lab session. But you can click the EXTEND to
increase your time. If you are at a VMware event, you can extend your lab time
twice, for up to 30 minutes. Each click gives you an additional 15 minutes.
Outside of VMware events, you can extend your lab time up to 9 hours and 30
minutes. Each click gives you an additional hour.
HOL-1921-06-CMP Page 4
HOL-1921-06-CMP
During this module, you will input text into the Main Console. Besides directly typing it
in, there are two very helpful methods of entering data which make it easier to enter
complex data.
You can also click and drag text and Command Line Interface (CLI) commands directly
from the Lab Manual into the active window in the Main Console.
You can also use the Online International Keyboard found in the Main Console.
1. Click on the Keyboard Icon found on the Windows Quick Launch Task Bar.
HOL-1921-06-CMP Page 5
HOL-1921-06-CMP
In this example, you will use the Online Keyboard to enter the "@" sign used in email
addresses. The "@" sign is Shift-2 on US keyboard layouts.
HOL-1921-06-CMP Page 6
HOL-1921-06-CMP
When you first start your lab, you may notice a watermark on the desktop indicating
that Windows is not activated.
One of the major benefits of virtualization is that virtual machines can be moved and
run on any platform. The Hands-on Labs utilizes this benefit and we are able to run the
labs out of multiple datacenters. However, these datacenters may not have identical
processors, which triggers a Microsoft activation check through the Internet.
Rest assured, VMware and the Hands-on Labs are in full compliance with Microsoft
licensing requirements. The lab that you are using is a self-contained pod and does not
have full access to the Internet, which is required for Windows to verify the activation.
Without full access to the Internet, this automated process fails and you see this
watermark.
HOL-1921-06-CMP Page 7
HOL-1921-06-CMP
Please check to see that your lab is finished all the startup routines and is ready for you
to start. If you see anything other than "Ready", please wait a few minutes. If after 5
minutes you lab has not changed to "Ready", please ask for assistance.
HOL-1921-06-CMP Page 8
HOL-1921-06-CMP
Module 1 - Creating
Advanced vRealize
Orchestrator Workflows
(45 min)
HOL-1921-06-CMP Page 9
HOL-1921-06-CMP
Introduction
vRealize Orchestrator can be used to automate complex processes that require various
steps, branching, and even looping.
In this module, conditional execution, loops, and asynchronous presentation are covered
using real-life examples in relation with vRealize Automation. This module begins with
details on how to implement these concepts in a workflow, and it is followed by a real-
life example on how to request a vRealize Automation catalog item, wait for the
provisioning to finish, and retrieve the newly created machine.
This type of use case is particularly useful for automated blueprint testing, or for
provisioning load testing.
Note: Use drag and drop to enter code in scriptable tasks to avoid any mistakes.
HOL-1921-06-CMP Page 10
HOL-1921-06-CMP
HOL-1921-06-CMP Page 11
HOL-1921-06-CMP
HOL-1921-06-CMP Page 12
HOL-1921-06-CMP
Name Workflow
HOL-1921-06-CMP Page 13
HOL-1921-06-CMP
1. Click the Add parameter icon to add the second parameter to the list
2. Click the default parameter name arg_in_0 to rename it
3. In the Choose attribute name... window, enter list for Attribute name
4. Click Ok
HOL-1921-06-CMP Page 14
HOL-1921-06-CMP
1. Click the Add parameter icon to add the third parameter to the list
2. Click the default parameter name arg_in_0 to rename it
3. In the Choose attribute name... window, enter num for Attribute name
4. Click Ok
HOL-1921-06-CMP Page 15
HOL-1921-06-CMP
HOL-1921-06-CMP Page 16
HOL-1921-06-CMP
HOL-1921-06-CMP Page 17
HOL-1921-06-CMP
HOL-1921-06-CMP Page 18
HOL-1921-06-CMP
1. Click on the default value of Not set to open the Array of string window
2. Click the upper left corner of the Array of string window, and drag it down and to
the right to resize it. Click the title bar of the window to move it up until the
Cancel and Accept buttons are visible
3. Enter Small into the New value field
4. Click Insert value.
Repeat step 3 and for 4 with the following values: Medium and Large
5. Click Accept
HOL-1921-06-CMP Page 19
HOL-1921-06-CMP
HOL-1921-06-CMP Page 20
HOL-1921-06-CMP
These properties have default values of 0.0 for Minimum number value, and 100.0 for
Maximum number value. These default values will suffice for this exercise.
HOL-1921-06-CMP Page 21
HOL-1921-06-CMP
Unlike the previous modules, attempting to save and close this workflow will result in a
Validation warning. This is because the 3 parameters defined in the previous steps are
not actually used by this workflow. Click the View details button if you wish to see the
specific information.
HOL-1921-06-CMP Page 22
HOL-1921-06-CMP
1. Since we know that we can proceed despite this warning, click Continue
anyway
HOL-1921-06-CMP Page 23
HOL-1921-06-CMP
The name parameter has been designated as mandatory, as noted by the red * next to
the parameter name. Attempting to skip the name parameter will generate an error.
1. Click the name text box, but do not enter any value
2. Click another field (such as the num text box) and observe the error message at
the top of the parameter list
Notice that the Submit button is greyed out.
3. Enter a value in the name field, and the error message will be dismissed.
HOL-1921-06-CMP Page 24
HOL-1921-06-CMP
The list parameter has a predefined set of values. For this reason, the list parameter on
this screen is a dropdown menu of the values defined previously, and only these values
may be chosen.
1. Choose a value for the list parameter from the dropdown menu
HOL-1921-06-CMP Page 25
HOL-1921-06-CMP
The num parameter has both a minimum and a maximum defined value, with the
minimum of 0.0 and the maximum of 100.0.
1. Enter a number greater than 100.0 and observe the error message at the top
of the parameter list.
2. Click on Cancel button
To go Further
Many more presentation properties are available, not limited to but including hide/show,
dropdown list from Actions, and choices related to other fields. Feel free to take more
time to explore all of the possibilities.
HOL-1921-06-CMP Page 26
HOL-1921-06-CMP
HOL-1921-06-CMP Page 27
HOL-1921-06-CMP
A decision box is the equivalent of an IF, ELSE conditional branch. The green arrow is the
path if the condition is true, and the red dotted arrow is the path if the condition is false.
HOL-1921-06-CMP Page 28
HOL-1921-06-CMP
1. Make sure the Decision workflow element in the schema is selected (not
shown)
2. Select the Decision tab in the lower left corner
3. Click Not set (NULL) to open the Chooser... window
4. In the new window, click Create parameter/attribute in workflow
HOL-1921-06-CMP Page 29
HOL-1921-06-CMP
HOL-1921-06-CMP Page 30
HOL-1921-06-CMP
Configure Decision
1. In the Decision tab in the lower pane, click the dropdown menu and change the
value to greater or equals
2. Enter a value of 10 in the blank text field
The counter attribute defined in the previous step is used to defined how the Decision
behave:
• If the counter value is less than 10, the path will be the red dotted one.
• If the value is greater than or equal to 10, the path will be the green one.
HOL-1921-06-CMP Page 31
HOL-1921-06-CMP
Bind Variables
1. Click the Setup... button in the upper right to proceed with the binding of the
parameters of the element.
2. Click Promote to import all parameters from the Increase counter object to the
workflow
This automatically binds the attribute counter to the IN and the OUT parameters of the
element.
HOL-1921-06-CMP Page 32
HOL-1921-06-CMP
In order to make a loop, the second end of the workflow must be deleted. An End
element can't be deleted by selecting it, so instead, the arrow preceding the element
must be deleted.
HOL-1921-06-CMP Page 33
HOL-1921-06-CMP
HOL-1921-06-CMP Page 34
HOL-1921-06-CMP
HOL-1921-06-CMP Page 35
HOL-1921-06-CMP
3. Click the X to close the window and return to the Schema pane
HOL-1921-06-CMP Page 36
HOL-1921-06-CMP
1. Move the mouse over the Scriptable task, then over the blue arrow that
appears along the right side of the object
2. Drag and drop the blue arrow to the Decision box
(Note: if necessary, click the dropdown menu above the schema to increase the zoom
% from the present 50.)
HOL-1921-06-CMP Page 37
HOL-1921-06-CMP
HOL-1921-06-CMP Page 38
HOL-1921-06-CMP
Sometimes, an error in developing a workflow can lead to an infinite loop. Let's see how
it can happen.
HOL-1921-06-CMP Page 39
HOL-1921-06-CMP
With the counter output parameter removed, the value of the counter is never updated.
The condition in the decision will thus always be false (it is never greater or equal than
10), and this workflow will result in an infinite loop.
To observe this, run the workflow.
HOL-1921-06-CMP Page 40
HOL-1921-06-CMP
Cancel Workflow
This workflow will continue to run indefinitely. In order to stop the workflow execution,
the only way is to cancel the workflow.
This exercise is complete. Out-of-the-box workflow elements allow very easy and visual
conditional creation and execution sequences in any workflows. As always, with loops
there is a risk of an infinite loop with an improperly configured workflow, but it can be
easily detected and stopped by canceling the workflow manually.
HOL-1921-06-CMP Page 41
HOL-1921-06-CMP
Remember, Drag and Drop can be used to enter code from HOL manual to workflow
Scriptable tasks.
HOL-1921-06-CMP Page 42
HOL-1921-06-CMP
After completion of the previous exercise, the schema section may be set to a lower
zoom level than usual. Before starting, the zoom can be can be changed.
HOL-1921-06-CMP Page 43
HOL-1921-06-CMP
HOL-1921-06-CMP Page 44
HOL-1921-06-CMP
Bind Parameters
In this situation, the OUT parameter request is used inside the workflow, so it is
configured as a Local variable instead of an output parameter.
Now that the request has been configured to request a vRealize Automation catalog
item, a loop is required to wait for the end of the provisioning of the machine. In
addition, a timeout will be implemented to fail the workflow if the machine takes too
much time to provision.
HOL-1921-06-CMP Page 45
HOL-1921-06-CMP
HOL-1921-06-CMP Page 46
HOL-1921-06-CMP
1. Select the IN tab in the lower pane (note that upon changing tabs, the Custom
decision object name has changed)
2. Click the Bind to workflow parameter/attribute icon
3. In the Chooser... window that opens, click the checkbox next to request
4. Click Select
Configure Decision
HOL-1921-06-CMP Page 47
HOL-1921-06-CMP
By setting this condition, the green path will be used only when the execution of the
request is stopped (which means the provisioning has either succeeded or failed.)
HOL-1921-06-CMP Page 48
HOL-1921-06-CMP
This sleep box allows the workflow to wait 20 seconds between each request status
check.
HOL-1921-06-CMP Page 49
HOL-1921-06-CMP
1. Drag and Drop Increase counter workflow element after the Sleep element
added previously (but do not click the Setup... button this time)
HOL-1921-06-CMP Page 50
HOL-1921-06-CMP
HOL-1921-06-CMP Page 51
HOL-1921-06-CMP
HOL-1921-06-CMP Page 52
HOL-1921-06-CMP
HOL-1921-06-CMP Page 53
HOL-1921-06-CMP
Note: If clicking on the arrow is difficult, it is possible to change the zoom level using
the dropdown at the top, as done at the start of this exercise.
HOL-1921-06-CMP Page 54
HOL-1921-06-CMP
HOL-1921-06-CMP Page 55
HOL-1921-06-CMP
Rename Decision
HOL-1921-06-CMP Page 56
HOL-1921-06-CMP
HOL-1921-06-CMP Page 57
HOL-1921-06-CMP
HOL-1921-06-CMP Page 58
HOL-1921-06-CMP
1. Click and drag the Scriptable task element above the decision box. Note that
the arrow follows the element as you drag it to the new location.
This is a best practice to re-arrange the workflow elements to make the overall workflow
more readable.
HOL-1921-06-CMP Page 59
HOL-1921-06-CMP
HOL-1921-06-CMP Page 60
HOL-1921-06-CMP
HOL-1921-06-CMP Page 61
HOL-1921-06-CMP
Add javascript
//Refresh request
var host = vCACCAFEEntitiesFinder.getHostForEntity(request)
request = vCACCAFEEntitiesFinder.getCatalogItemRequest(host , request.id)
//Log state and execution status
System.log(request.getStateName() + " (" + request.getExecutionStatus().value() + ")");
3. Click the X to close the window and return to the schema pane
This step updates the request object to make sure that it contains an updated version
with the latest status. Depending of the plugin used, this step may or may not be
required. There is no golden rule, so the only way to know if this is needed or not is to
test the behavior.
HOL-1921-06-CMP Page 62
HOL-1921-06-CMP
1. Move your mouse over Scriptable task, then on the blue arrow
Drag and drop the blue arrow to the decision box "Request done?"
HOL-1921-06-CMP Page 63
HOL-1921-06-CMP
HOL-1921-06-CMP Page 64
HOL-1921-06-CMP
HOL-1921-06-CMP Page 65
HOL-1921-06-CMP
Add IN Parameters
HOL-1921-06-CMP Page 66
HOL-1921-06-CMP
Add javascript
HOL-1921-06-CMP Page 67
HOL-1921-06-CMP
1. Drag and drop an additional Scriptable task element onto the arrow between
the decision box and the end of the workflow
HOL-1921-06-CMP Page 68
HOL-1921-06-CMP
Add IN Parameters
HOL-1921-06-CMP Page 69
HOL-1921-06-CMP
HOL-1921-06-CMP Page 70
HOL-1921-06-CMP
Add javascript
//Prepare Filter
var filter = new Array();filter[0] = vCACCAFEFilterParam.equal("request/id",
vCACCAFEFilterParam.string(request.getId()));
filter[1] = vCACCAFEFilterParam.equal("resourceType",
vCACCAFEFilterParam.string("Infrastructure.Virtual"));
var query = vCACCAFEOdataQuery.query().addFilter(filter);
// get items
var items = service.getResourcesList(new vCACCAFEPageOdataRequest(query));
resource = items[0];
This code allows the task to retrieve the newly provisioned item from the request.
HOL-1921-06-CMP Page 71
HOL-1921-06-CMP
1. Click the Run button to execute the workflow. This will open the Start Workflow
window and prompt for input.
HOL-1921-06-CMP Page 72
HOL-1921-06-CMP
HOL-1921-06-CMP Page 73
HOL-1921-06-CMP
Before the workflow completes make sure you go to the next step. The workflow
execution can take 5 to 15 minutes to complete (depending of the load on the HOL
platform).
Observe how the schema is flowing, and the log messages as they appear in the Logs
tab.
HOL-1921-06-CMP Page 74
HOL-1921-06-CMP
Let’s take a look at the status of the VM creation process within vRA.
1. In the Windows Quick Launch task bar, click the Google Chrome icon to open
the browser
HOL-1921-06-CMP Page 75
HOL-1921-06-CMP
HOL-1921-06-CMP Page 76
HOL-1921-06-CMP
2. Note the request for a CentOS item, with the description of automated
creation as noted upon requesting in the workflow.
The request will show a Status of In Progress until provisioning of the machine is
complete. When it is complete, the vRealize Automation request will show a Status of
Successful or Failed.
Return to vRealize Orchestrator, and observe the status of the completed workflow.
1. If necessary, expand the right pane to see the values of the variables.
2. Note that in the Variables tab, the resource parameter is now set to a value of
the machine's name (this name was generated as part of the vRealize
Automation blueprint requested by this workflow).
HOL-1921-06-CMP Page 77
HOL-1921-06-CMP
1. Switch to vRealize Automation in the Chrome browser (not shown,) and navigate
to the Items tab
HOL-1921-06-CMP Page 78
HOL-1921-06-CMP
2. Select the line containing the CentOS item (do not click on the Name itself, or
you will be taken to the Item Details screen)
If nothing is shown, make sure the request was successful.
3. Click Actions
4. From the dropdown menu, select Destroy
Interacting with vRealize Automation is easy using out-of-the-box workflows and basic
concepts, such as loops.
For more examples of additional options beyond machine creation, see the other
vRealize Automation hands-on labs.
HOL-1921-06-CMP Page 79
HOL-1921-06-CMP
Asynchronous Workflows
Asynchronous workflows allow multiple tasks within a workflow to be launched without
waiting for an individual task to complete! This is a good way to trigger multiple actions
in parallel, or to track different parts of a process as separate workflow tokens.
HOL-1921-06-CMP Page 80
HOL-1921-06-CMP
HOL-1921-06-CMP Page 81
HOL-1921-06-CMP
Choose Workflow
HOL-1921-06-CMP Page 82
HOL-1921-06-CMP
Bind Parameters
HOL-1921-06-CMP Page 83
HOL-1921-06-CMP
1. Click Run to execute the workflow and open the Start Workflow window
Notice that the input prompt is the same as the previous exercise. The same workflow
is executed, but this time it is done from a parent workflow and in an asynchronous
manner.
HOL-1921-06-CMP Page 84
HOL-1921-06-CMP
HOL-1921-06-CMP Page 85
HOL-1921-06-CMP
1. In the Workflows list, expand the Asynch workflow to observe the recent run
2. Note the green checkmark indicating that this workflow execution was
successful. Click on the specific Asynch item to view the results
3. Select the Variables tab on the right
4. Observe the wfToken attribute, it is set to Create Machine and Wait and
represent the workflow asynchronously executed.
1. Expand the Create Machine and Wait workflow to observe recent activity for
that workflow.
2. Locate the most recent run of this workflow. Note that it is still running, while the
Asynch workflow has already completed.
Let’s return to vRealize Automation and remove the newly created instance.
HOL-1921-06-CMP Page 86
HOL-1921-06-CMP
1. In the Windows Quick Launch task bar, click the Google Chrome icon to open
the browser
HOL-1921-06-CMP Page 87
HOL-1921-06-CMP
HOL-1921-06-CMP Page 88
HOL-1921-06-CMP
The exercise is complete. To go further, it is possible to use a loop to wait for the end of
the asynchronous workflow by monitoring the workflow token state value.
HOL-1921-06-CMP Page 89
HOL-1921-06-CMP
Conclusion
vRealize Orchestrator can be used to automate complex processes that
requires polling for status, launching multiple tasks at the same time (or
asynchronously,) and using advanced input presentation. In conjunction with
vRealize Automation, it can be very useful to automate processes around
machine provisioning by using the power of vRealize Automation for the
creation and the flexibility of Orchestrator for input parameters or third party
integrations.
If you are looking for additional information on vRO Coding Guidelines , try one of
these:
• Go to http://bit.ly/2tKxJU6
• Or use your smart device to scan the QRC Code.
• Module 2 - Integrating with REST APIs (45 min) (Advanced) Learn how to
unleash the power of vRealize Orchestrator by integrating it with REST APIs
provided by external systems.
• Module 3 - Launching Workflows from Outside vRealize Orchestrator (45
min) (Advanced) Learn how you can call into vRealize Orchestrator to invoke the
workflows you've created from external systems.
• Module 4 - Automating vRealize Automation with vRealize Orchestrator
(45 min) (Advanced) vRealize Automation is an extremely powerful automation
platform - but what if you want to help automate the automation? Learn how to
orchestrate common tasks in vRealize Automation using vRealize Orchestrator.
HOL-1921-06-CMP Page 90
HOL-1921-06-CMP
HOL-1921-06-CMP Page 91
HOL-1921-06-CMP
Module 2 - Integrating
with REST APIs (45 min)
HOL-1921-06-CMP Page 92
HOL-1921-06-CMP
Introduction
According to Wikipedia, Representational State Transfer (REST) is an architectural style
that defines a set of constraints and properties based on HTTP. Web Services that
conform to the REST architectural style, or RESTful web services, provide
interoperability between computer systems on the Internet. REST-compliant web
services allow the requesting systems to access and manipulate textual representations
of web resources by using a uniform and predefined set of stateless operations. Other
kinds of web services, such as SOAP web services, expose their own arbitrary sets of
operations.
vRealize Orchestrator provides a plugin to interact with REST web services easily and
efficiently.
HOL-1921-06-CMP Page 93
HOL-1921-06-CMP
1. Click the dropdown menu at the top of the client, and select the Design View
HOL-1921-06-CMP Page 94
HOL-1921-06-CMP
Note: NSX has its own plugin which is better and easier to use than the REST API.
However for the purpose of this lab, this REST API will be studied.
Interacting with a NSX Manager via REST requires to add NSX Manager as a REST host in
vRealize Orchestrator.
The REST host needs to be added only once.
HOL-1921-06-CMP Page 95
HOL-1921-06-CMP
Host Properties
1. Type NSX for the REST host name. This is the user friendly name that will appear
in the vRealize Orchestrator inventory view
2. Type https://nsxmgr-01a.corp.local for the URL This is the URL to the NSX
Manager in the lab environment.
3. Select Yes to accept the hosts certificate silently.
4. Click the Next button
HOL-1921-06-CMP Page 96
HOL-1921-06-CMP
Host Authentication
There are several options for authentication, for NSX we need to use Basic. Take a
moment to look through the other authentication method options.
1. Click the drop down menu and select Basic for the authentication type
2. Click the Next button
HOL-1921-06-CMP Page 97
HOL-1921-06-CMP
User Credentials
Select a session mode of either a Shared Session or Per User Session. In Per User
Session, the credentials are used from the currently logged in user. In this case, Shared
Session is the chosen option as every person using vRO should be able to execute a
workflow against NSX manager API regardless of their own privileges in NSX.
HOL-1921-06-CMP Page 98
HOL-1921-06-CMP
Proxy Settings
HOL-1921-06-CMP Page 99
HOL-1921-06-CMP
The workflow token Add a REST host should have a green checkmark next to it, this
shows that the workflow completed successfully.
A REST operation is how you interact with a REST api. For example, you use a GET
operation to make an inquiry or a POST operation to update data or a configuration.
Operation Properties
This allows to select the NSX Manager REST host previously added.
Operation Properties
/api/2.0/services/securitytags/tag
Notice the URL is not a full URL. vRealize Orchestrator will concatenate the REST host
URL and the template URL.
3. Select POST from the drop down for the HTTP method. Take a moment to look
through the other HTTP methods available.
4. Enter application/xml for the Content type
5. Click the Submit button
The workflow token Add a REST operation should have a green checkmark next to
it, this shows that the workflow completed successfully.
Input Content
The code comes from the NSX API guide. The code is creating a NSX Security Tag called
FinanceApp with the description of Component of the Finance Application.
<securityTag>
<objectTypeName>SecurityTag</objectTypeName>
<type><typeName>SecurityTag</typeName></type>
<name>FinanceApp</name>
<description>Component of the Finance Application</description>
<extendedAttributes></extendedAttributes>
</securityTag>
The Invoke a REST operation run should have a green checkmark next to it, this
shows that the workflow completed successfully.
1. Click on the Chrome Icon on the Windows Quick Launch Task Bar.
Security Tags
Conclusion
The REST web services are a good way to integrate with a lot of systems. With vRealize
Orchestrator, the out-of-the-box REST plugin provides a quick and efficient solution to
easily integrate with these systems.
If you are looking for additional information on vRealize Orchestrator REST API plugin try
one of these:
troubleshooting and more resilient workflows. Learn about and create exception
binding to your workflows.
Module 3 - Launching
Workflows from Outside
vRealize Orchestrator (45
min)
Introduction
vRealize Orchestrator has tight integration with a lot of VMware products but it can also
be easily integrated with any other system by using its REST API.
In this exercise, Postman is used to demonstrate the few REST call needed to integrate
with vRealize Orchestrator.
Launch Postman
Postman is a powerful HTTP client for testing web services. Postman makes it easy to
test, develop and document APIs by allowing users to quickly put together both simple
and complex HTTP requests.
1. The HTTP method and the url can be specified in this form
2. Different aspect of the HTTP request can be configured such as Authentication,
Headers and Body.
3. When the HTTP request has been sent, the response is available on the same
page.
4. It is possible to store a list of HTTP requests in a Collection
5. Each HTTP Request can use variables that can be stored in an environment
configuration.
1. Click on the Chrome Icon on the Windows Quick Launch Task Bar.
https://vra-01a.corp.local/vco/api/docs/index.html
1. Scroll down
2. Click on workflow-controller to expand the operations
By clicking on one operation, it is possible to see the details of the input
parameters and a sample of the response message.
vRealize Orchestrator API has multiple controllers, each controller allows to interact with
a type of object. In the next step of this module,
workflow-controller will be used to retrieve a workflow definition.
inventory-service-controller will be used to retrieve objects from vRO inventory that
can be used as input for a workflow.
execution-controller is used to start a workflow and monitor its status.
1. Click the dropdown menu at the top of the client, and select the Design View
Switch to Postman
Execute workflow
{}
vRealize Orchestrator API doesn't accept an empty body for a POST request, so, even if
there are no inputs, it must be an empty JSON object.
1. Status: 202 Accepted indicates that the workflow has been successfully started
2. Click the Headers tab
3. Look for the Location header and Copy the link (select the link and Press Ctrl
+ C)
The Location header contains a link to the workflow execution, this link allows to
monitor the workflow status
Analyze response
All requests were executed against vRealize Orchestrator using Basic Authentication.
This authentication was configured at the Collection level.
Quick summary
• Get the details regarding a workflow, especially the expected inputs and outputs
• Start a workflow
• Monitor the workflow status
Get the ID
Switch to Postman
Get VM object
The following URL is used to browse vRO inventory to find object where the type is
VC:VirtualMachine and the name of the machine is "base-linux-cli"
https://vra-01a.corp.local/vco/api/catalog/VC/VirtualMachine?conditions=name=base-
linux-cli
• VC is the plugin namespace (found before ':' in the complex object type)
• VirtualMachine is the object type (found after ':' in the complex object type)
• conditions allows to narrow down the research to one machine by filtering by
name
Execute a workflow
vcsa-01a.corp.local/vm-221
1. Status: 202 Accepted indicates that the workflow has been successfully started
2. Click on Headers tab
3. The Location header contains a link to the execution, this link allows to monitor
the workflow status
Copy the link (select the link and Press Ctrl + C)
Analyze response
If the workflow is not completed, you can send this request multiple time to see the
status change.
Conclusion
On top of a lot of out-of-the-box capabilities, vRealize Orchestrator provides
an easy to use REST API to integrate the orchestrator with any other
products. vRealize Orchestrator is definitely a central tool to build around for
every automation project.
If you are looking for additional information on vRealize Orchestrator REST API try one of
these:
Proceed to any module below which interests you most. [Add any custom/optional
information for your lab manual.]
Module 4 - Automating
vRealize Automation with
vRealize Orchestrator (45
min)
Introduction
Rainpole company has to dedicate a lot of resources to maintain and manage their
vRealize Automation implementation. Each time a new project is on boarded there are
many tasks that need to be performed. These tasks include business group creation,
creating reservations, building and assigning entitlements, etc...
It is very time consuming and it is also prone to human errors, delaying the on boarding
and creating frustration for end-users.
Peter, the head of the Cloud Automation team, is thinking about automating this
process. Unfortunately he has only a few employees, and they don't have time to spend
on exploring vRealize Automation API to find out how to automate this process. They
are, however, already using vRealize Orchestrator to integrate their CMDB and IPAM
with virtual machine provisioning. Fortunately vRealize Orchestrator already contains a
lot of out-of-the-box content to automate vRealize Automation configuration.
With their vRO knowledge and the existing content, the automation of the onboarding
process should be quick!
1. Click the dropdown menu at the top of the client, and select the Design View
1. Click on Not set for vRA CAFE host field (not shown in the screenshot)
2. Expand vRealize Automation
3. Select vRA - CloudAdmin
4. Click on Select button
Let’s open vRealize Automation and see how the Business Group was added.
1. Click on the Chrome Icon on the Windows Quick Launch Task Bar.
Explore the business group configuration and verify it matches what was used in the
workflow.
Verify Entitlement
Navigate to Library > vRealize Automation > Administration and observe all the
pre-existing content that can help cloud administrator to better manage vRealize
Automation every day. Note that some workflow folder might be already expanded.
In this exercise, the final workflow will provide this end-to-end service for onboarding a
new group of users to vRealize Automation through vRealize Orchestrator.
To make the on-boarding process quick and easy, the number of mandatory inputs will
be reduced to a minimum. Each input that are not required will be set to null (Skip) or
hardcoded.
Create an Entitlement
Bind inputs
1. Make sure the workflow element Assign all users and groups to an
entitlement is selected (dark blue)
2. Click the Setup... button
3. Click the Promote button
Assign Services
Create Reservation
Creating a reservation is not something provided out of the box, however in this lab, this
very simple workflow is provided as a workaround. This workflow doesn't allow to setup
all the aspect of a reservation but instead take an existing reservation as a "template"
and create a copy assigned to a given business group.
1. Make sure the workflow element Create Reservation is selected (dark blue)
2. Click on Setup... button
3. Select group from the dropdown list for the first parameter
4. Rename the 2nd parameter to reservationName and Select Value
5. Rename the 3rd parameter to reservationToDuplicate and keep it as Input
6. Click the Promote button
Manage Naming
Bind input/outputs
Assign names
Fill inputs
For this example, the QE team will be on boarded to vRA to be able to test the
MyCommerce blueprint.
Fill inputs
Select Services
Let's look at vRealize Automation to check if the onboarding process has been
successful.
1. Click on the Chrome Icon on the Windows Quick Launch Task Bar.
QE User catalog
Conclusion
By automating the administrative aspects of vRealize Automation with
vRealize Orchestrator, it is very easy to get the most out of vRealize
Automation with the minimum time spent on operating the platform.
If you are looking for additional information on vRealize Automation API, try one of
these:
troubleshooting and more resilient workflows. Learn about and create exception
binding to your workflows.
Introduction
Cloud administrators often perform operations within the guest operating system of the
virtual machines they manage. They don't always have network connectivity and going
through the vSphere console is very cumbersome to perform these tasks.
vRealize Orchestrator is here to help, with its native support of the vSphere Guest
Operations and the Guest Script Manager, it is now quick and easy to perform operation
within the guest of a virtual machine without requiring network connectivity or third
party agent. It is free and out of the box.
1. Click on the Chrome Icon on the Windows Quick Launch Task Bar.
1. Click on ACTIONS
2. Click on Power
3. Click on Power On
Wait a few seconds until VMware Tools changes from "Not running" to “Running” status.
Start putty
1. Click the dropdown menu at the top of the client, and select the Design View
Common parameters
The first step requires information regarding the machine. The credentials are guest
credentials, they are required to let VMware Tools impersonate this user to run the
command. This also adds a layer of security as you need to know vCenter credentials
AND guest credentials to use this feature.
Select linux VM
Program path
A bash command will be run, so the path where bash is needs to be inputed.
/bin/bash
Arguments
Working directory
Environment
1. Make sure the workflow run is selected (with the green checkmark)
2. (if needed) Drag and Drop the lower panel to expand it
3. Make sure the Variables tab is selected.
4. Observe the result attribute and save the value (it will be used in the next steps)
The result attribute is the unique process ID (PID) of the process created by guest
operations.
This workflow is the same as the one in Library > vCenter > Guest Operations >
Processes > Get processes from guest, but for the purpose of this lab, it contains
one more line of code to log the results in vRO logging panel.
1. Scroll up if necessary
2. Navigate to the workflow HOL > Module 1921-06-CMP > Module 5 > Get
processes from guest with logging
3. Click on Start workflow... button
Select linux VM
1. Make sure the workflow run (with the green checkmark) is selected
2. Click on Logs tab
3. Scroll up to see the beginning of the logs
4. process with the same pid should be found at the top
If there is no process with an exitCode: 0 at the beginning of the log, look at all the line
in the logs.
Even if the pid is not found, the lab can be pursued.
cat /root/hol.txt
3. Press Return
Guest Script Manager is a community package simplifying the use of vSphere Guest
Operations in vRealize Automation. It can be found by following this link:
https://communities.vmware.com/docs/DOC-25474
Note that ifconfig is used to change network configuration. This change is not persistent
for the benefit of the lab. In real-life, the proper command should be run to obtain a
persistent configuration.
2. Press Return
After couple of minute, Putty throw an error "Network error: Software caused connection
abort". The error message can be closed.
Guest Script Manager requires the creation of a "script configuration" before being able
to execute a command in the guest os. This allows for the user to specify different
parameters as well as upload files (like script file).
Configuration name
Script
Note that the script contains a placeholder {{ipAddress}} that will be replaced
dynamically during the execution of the script. This feature allows for the creation of
modular script for better re-usability and scalability.
Select linux VM
Enter inputs
Enter variables
1. Click on Not set link for Variables to replace in the script field
Submit workflow
Switch to putty terminal (click on Putty in the taskbar, not show in the screenshot)
Session is re-established
The session is successfully re-established, proving the network configuration has been
restored.
After running one script on one virtual machine, let see how to do the same on multiple
machine at the same time. It can be very useful to perform IP change in case of DR or
datacenter migration.
Name Workflow
Configure input/outputs
Make sure the workflow element in the design canvas is selected (not shown)
Setup inputs/outputs
Make sure the workflow element Run script in VM guest in the design canvas is
selected (not shown)
This workflow will be launched through the other workflow element "Start workflows in
parallel" so it is not needed in this workflow. However it was helpful to use it in order to
setup all the required attributes and inputs. By this way, it is more reliable than setting
each attributes and input manually one by one.
Configure attributes
1. Click on arg_in_0
2. Enter ipAddresses
3. Click on Ok button
Configure IN
1. Select IN tab
2. Click on Bind to workflow parameter/attribute button
3. Check the checkbox for the following parameter/attribute
vm, ipAddresses, vmUsername, vmPassword,
scriptConfigurationResource
4. Click on Select button
Configure OUT
Configure Scripting
parameters = [];
for (var i = 0; i < vm.length; i++){
var wfParams = new Properties();
wfParams.put("vm", vm[i]);
wfParams.put("vmUsername", vmUsername);
wfParams.put("vmPassword", vmPassword);
wfParams.put("scriptConfigurationResource", scriptConfigurationResource);
wfParams.put("scriptVariables",
[{"stringToReplace": "{{ipAddress}}",
"replacingString": ipAddresses[i]}]);
parameters.push(wfParams);
}
This script creates a parameter array. Each element of the array is the list of inputs
required for the workflow "Run a script in VM guest".
Finally, note the specific formatting for the scriptVariables variable. It is because this
variable has a type which is an Array of a composite type.
Select linux VM
Select IP Addresses
Note that the number of IP addresses in the list must match the number of machine
selected at the previous step.
Submit workflow
Make sure the number of VM provided matches the number of IP addresses. No check
are performed in the workflow to verify this condition, in a production environment it is
strongly recommended to perform such a verification.
ping 192.168.120.202
ping 192.168.120.101
1. Click on ACTIONS
2. Click on Power
3. Click on Shut Down Guest OS
4. If a popup appears, Click the YES button
Conclusion
vRealize Orchestrator is the perfect tool to get the most out of the vSphere
Guest Operation capabilities. With its ability to easily perform parallel tasks,
it is now easy and safe to perform seamless maintenance operations in any
guest operating systems even without network connectivity or third-party
agents.
If you are looking for additional information on Guest Script Manager try one of these:
troubleshooting and more resilient workflows. Learn about and create exception
binding to your workflows.
Introduction
Error handling and logging are very important concepts in vRealize Orchestrator for the
creation of reliable workflows, to assist with workflow troubleshooting, and ultimately to
make infrastructure more robust.
In this module, error handling, troubleshooting, and logging are covered. This lesson
highlights how easy it is to catch errors, execute remediation actions, and finally to
automate everything in a reliable fashion using vRealize Orchestrator.
1. Click the dropdown menu at the top of the client, and select the Design View
All elements in a workflow, except for decisions and start and end elements, contain a
specific output parameter type that serves only for handling exceptions. If an element
encounters an error during its run, it can send an error signal to an exception handler.
Exception handlers catch the error and react according to the errors they receive. If the
exception handlers you define cannot handle a certain error, you can bind an element's
exception output parameter to an Exception element, which ends the workflow run in
the failed state.
This is important because when your workflows do fail, exception handling allows them
to fail as gracefully as possible and it provides meaningful error messages.
Let’s open vRealize Automation and confirm Log Insight integration configuration.
1. Click on the Chrome Icon on the Windows Quick Launch Task Bar.
Update configuration
Save Configuration
1. Right click the HOL > 1921-06-CMP > Module 6 workflow folder
2. Select New workflow
1. Click Setup
By clicking setup, this is allowing vRealize Orchestrator to bind the inputs/outputs
from Create simple virtual machine to the parent workflow.
Look over the input and output parameters that are being added to the workflow.
2. Click Promote
By dragging the System Error Element onto the workflow, you are linking it to the
workflow. Notice how a red dotted line is created from the workflow to the system error.
Also, the System Error element is connected to a separate End workflow element. This
shows that if the the workflow errors out, it will be loged and the workflow will end.
The text parameter allows you to supply the end user with more information when the
workflow fails.
The reason these parameters are moved to attributes is that they can be configured
with preset values. The end users are not burdened with entering these values at
provisioning time.
1. Click Not Set to set the value for vmFolder (not shown)
2. Navigate to vSphere vCenter Plug-in > https://vcsa-01a.corp.local:443/sdk
> Datacenters > RegionA01 > vm
3. Click the Select button
1. Click Not Set to set the value for vmResourcePool (not shown)
2. Navigate to vSphere vCenter Plug-in > https://vcsa-01a.corp.local:443/sdk
> Datacenters > RegionA01 > host > RegionA01-COMP01 > Resources
3. Click the Select button
1. Click Not Set to set the value for vmHost (not shown)
2. Navigate to vSphere vCenter Plug-in > https://vcsa-01a.corp.local:443/sdk
> Datacenters > RegionA01 > host > RegionA01-COMP01 >
esx-01a.corp.local
3. Click the Select button
1. Click Not Set to set the value for vmNetwork (not shown)
2. Navigate to vSphere vCenter Plug-in > https://vcsa-01a.corp.local:443/sdk
> Datacenters > RegionA01 > network > none
(since no connectivity is required for this exercise)
3. Click the Select button
1. Click Not Set to set the value for vmDatastore (not shown)
2. Navigate to vSphere vCenter Plug-in > https://vcsa-01a.corp.local:443/sdk
> Datacenters > RegionA01 > datastore > RegionA01-ISCSI01-COMP01
3. Click the Select button
Let's do a test run of the workflow to see the effects of adding the System Error
element.
Note that .5 is used for the CPU count (which is invalid) to test the results of a failed
workflow run with the added System Error element.
1. Make sure the Logs tab is selected (on the right side)
Note that the workflow failed, and a few things were logged:
This is great, but now let's change an incorrect CPU count to 1 CPU if the user provided
an invalid value, and proceed with the workflow.
This is a good example of error handling, and you will be building this into your workflow
next.
By dragging the Decision Element onto the line it is linked to the other elements. The
red dotted line is created from the workflow to a End Workflow element. The Decision
Element is connected to the System Error element with a green line.
If the Decision Element is false it needs to be connected to the System Error, so let's do
some cleanup.
1. Right click the red dotted line between the Decision Element and a End
Workflow Element
2. Select Delete
This will delete the red dotted line and the End Workflow Element that is connected to it.
If the Decision Element is false it needs to be connected to the System Error, so let's do
some cleanup.
1. Right click the green line between the Decision Element and the System Error
Element
2. Select Delete
Finally you now can connect the red dotted line, or false to the System Error Element
Now you will want to give the decision some criteria to look for.
1. Click on the Decision Element to open the edit window in the lower pane
2. Select Decision tab
3. Click the Not set (NULL) link
Now that the decision element has a string value to check, the condition can be
configured
The decision is set to look for the errorCode parameter that includes the string value
"numCPUs".
Input parameters are read-only and cannot be changed once an input value is given,
attributes are read/write. The value of this parameter may need to be updated based on
the outcome of the decision element.
Let's add an input parameter to have the end user provide the CPU count.
1. Double click on the Description field of the vmCPU parameter and type Virtual
Machine CPU count
2. Click the string link for vmCPU parameter
Parameter type needs to be changed to number because this value will be passed to
vmNbOfCpus attribute, which is also of type number and type must match in vRO.
1. Select number
2. Click the Accept button
This Scriptable task is used to pass the value from the vmCPU input parameter to the
vmNbOfCpus attribute (used by the subsequent workflow element).
The scriptable task is going to be renamed to make it more meaningful in the workflow.
Add an IN Parameter
vmNbOfCpus = vmCPU;
This script will convert the vmNbOfCpus attribute to the value of the input parameter
vmCPU.
Let's add an additional Scriptable task to change the value of the vmNbOfCpus attribute
to 1 when there is a failure.
This links the scriptable task to the decision element. When the criteria is met in the
decision element, the workflow continues on to the scriptable task.
The scriptable task is going to be renamed to make it more meaningful in the workflow.
1. Make sure the scriptable task Change CPU Count to 1 is selected (not shown)
2. Select the OUT tab
vmNbOfCpus = 1;
Link the "Change CPU Count to 1" Scriptable task to the "Create simple virtual machine
workflow." This way, if there is an error due to an invalid CPU number, the value is
changed to 1.
1. Hover over the scriptable task and drag the blue arrow from Change CPU
Count to 1 to the Create a simple virtual machine workflow
1. Browse to HOL > 1921-06-CMP > Module 6 > My Workflow Error Handling
, if it is not already selected
2. Expand the workflow to see the workflow runs
3. Right click on the last workflow run
4. Click the Run again... button
Provide Inputs
The values are the same as at the beginning of the exercise. But this time there is some
error handling to correct an invalid CPU count value.
The workflow should proceed as expected and create the virtual machine.
In the logs, an error was thrown because there was an invalid CPU count, but the error
handling task caught it and the workflow completed successfully.
1. Click on the Chrome Icon on the Windows Quick Launch Task Bar.
1. Click the X in the top right hand comer of the browser to close it
1. The workflow token from the failed run can be seen by the red x icon
2. Select Variables tab
3. Look at the Exception message
This is the first clue to understand what happened. Most of the time this message
should be clear enough to have an understanding of what caused the workflow failure.
This variable, which is an array, has not been initialized (Not Set in value). It explains
why the exception message says "Cannot call method "push" of null" - in this case, null
is the array.
1. Select Schema
2. The workflow element where the exception occurred is highlighted
3. In this case, the workflow that failed is not the root workflow, so it is possible to
see the workflow stack
1. Click on Workflow failure 2 button, by this way, the schema and the variables
in the lower panel will reflect this workflow.
2. Select the Variables tab
3. The workflow element in Workflow failure 2 which failed is highlighted
4. The variables are the variables from Workflow failure 2
This helps to understand how variables have flown from the root workflow to the child
workflow.
1. Expand the lower pane by dragging and dropping the separator bar
2. Select Logs tab
3. This shows the variables for root workflow (Workflow failure 2)
4. This shows the variables for child workflow (Workflow failure 1), notice how this
Workflow failure 1 log entry is indented with and |. This helps identify a failure
in a called workflow.
1. Click on the Chrome Icon on the Windows Quick Launch Task Bar.
• Username: admin
• Password: VMware1!
Logging in Workflows
Despite multiple methods for workflow troubleshooting described in the previous
exercise, logging is still very important in order to understand errors, and also to audit a
workflow result.
vRealize has different way for logging, they are described in this exercise.
1. Right click the HOL > 1921-06-CMP > Module 6 workflow folder
2. Select New workflow
1. Select Schema
2. Select Generic category
3. Drag and Drop Scriptable task to the blue arrow
Add Script
1. Select Scripting
2. Enter the following code:
System.log("INFO logging");
System.warn("WARN logging");
System.error("ERROR logging");
System.debug("DEBUG logging");
Server.log("INFO event");
Server.warn("WARN event");
Server.error("ERROR event");
Message Details
• I = INFO
• W = WARNING
• E = ERROR
• D = DEBUG
• black = INFO
• black bold = WARNING
• red bold = ERROR
• black italic = DEBUG
Remember that these log messages have been written by this part of the code:
System.log("INFO logging");
System.warn("WARN logging");
System.error("ERROR logging");
System.debug("DEBUG logging");
These logs can also be found in Server.log file in the vRealize Orchestrator instance. By
default, DEBUG logs are not logged in this file.
In a vRealize Orchestrator cluster, logs are visible only when connected to the vRealize
Orchestrator instance where the workflow instance actually ran.
Events Details
1. Click the red X in the upper right corner to close the vRealize Orchestrator Client
window
2. Click Exit when prompted
Conclusion
In addition to providing an easy way to develop workflows, third party
integrations, and lifecycle extensibility to vRealize Automation, with vRealize
Orchestrator it is easy to troubleshoot workflow failures and to include failure
path in the workflow itself. This make every process automated through
vRealize Orchestrator much more reliable.
If you are looking for additional information on Debugging workflows , try one of
these:
• Go to http://bit.ly/2t53Ijm
• Or use your smart device to scan the QRC Code.
Conclusion
Thank you for participating in the VMware Hands-on Labs. Be sure to visit
http://hol.vmware.com/ to continue your lab experience online.
Version: 20181104-142657