Tag Archives: vRO

Accessing Content from Variables of Type Any in the vRO Client

One of my colleagues showed me how to do this, so I thought it worth sharing since it has bugged me ever since I started using vRO.

If you have run a vRO workflow and are looking at the output, specifically the Variables tab:

you can then view what values each variable was at the time of workflow completion. If the value is a string or something else simple you will get a nice view of it. However, if it is say a collection of properties you will see something similar to the below and typically you will not be able to scroll across to view them all.

What I have typically done until now is add a Scriptable Task as the next step in the workflow and log all of the properties out. However, she demonstrated to me that it is possible to copy them and then paste into a text editor.

Step:

  1. Bring up the above view by clicking on the ‘i’, next to the magnifying glass
  2. Click once on the white section – in this example the word ‘Properties’
  3. Ctrl-A
  4. Ctrl-C

Even though there is no visual indication that everything was highlighted to be made available for copy, like in say a text editor, it has actually done it. The below is the copied output from the above:

Properties##[#sections#=#Properties##[#section#=#Properties##[#generationNumber#=#number#1.511870334212E12#+#name#=#string#TEST01#+#rule#=#Properties##[#appliedToList#=#Properties##[#appliedTo#=#Properties##[#isValid#=#boolean#true#+#name#=#string#TEST02#+#type#=#string#SecurityGroup#+#value#=#string#securitygroup-530#]##]##+#packetType#=#string#any#+#_disabled#=#boolean#false#+#_logged#=#boolean#false#+#destinations#=#Properties##[#destination#=#Properties##[#isValid#=#boolean#true#+#name#=#string#TEST01#+#type#=#string#SecurityGroup#+#value#=#string#securitygroup-101#]##+#_excluded#=#boolean#false#]##+#name#=#string#Test01#+#action#=#string#allow#+#id#=#number#2758.0#+#sectionId#=#number#1252.0#+#services#=#Properties##[#service#=#Properties##[#destinationPort#=#number#3453.0#+#protocol#=#number#6.0#+#protocolName#=#string#TCP#+#isValid#=#boolean#true#]##]##+#direction#=#string#inout#]##+#_class#=#string#section#+#_id#=#number#1252.0#+#type#=#string#LAYER3#+#_timestamp#=#number#1.51134543303912E12#]##]##]#

OK, it is not that easy to read, but it is pretty handy if you just want to quickly grab it and search for something in the list of Properties.

Issues with Mounting a CIFS Share on the vRO Appliance

This article on the vCOTeam site details how to mount a CIFS share on the vRO Appliance so that workflows can write files directly to a Windows File Share rather than using another process to copy the file over there.

This was straightforward to implement in a lab scenario, however within a corporate environment with more restrictions around security and networking it can potentially be more of a challenge. Specifically we encountered the following error response from a Windows Server seemingly configured correctly for Share and NTFS permssions on the folder to mount:

Status code returned 0xc0000022 NT_STATUS_ACCESS_DENIED
CIFS VFS: Send error in SessSetup = -13
CIFS VFS: cifs_mount failed w/return code = -13

This post on a Centos forum helped us track down the problem, i.e. there was at least one Group Policy restricting the use of NTLM.

“It turned out in my case to be a Group policy which was set to Send NTLMv2 responses only. Refuse LM and NTLM. I changed this to Send LM & NTLM -use NTLMv2 session security if negotiated.

Located at: Computer Configuration/Windows Settings/Security Settings/Local Policies/Security Options. The policy is called: Network Security: Lan Manager authentication level.”

In our case there were also other NTLM policies that needed to be considered, so worth checking any of these:

Also worth checking the policy: Microsoft network server: Digitally sign communications (always):

It is also possible to use different security settings within the /etc/fstab file on the vRO appliance, eventually we settled on sec=ntlmssp, however I believe the following are also possibilities: sec=ntlm, sec=ntlmv2, sec=ker5 and sec=ker5i

You may also want to consider using a credentials file rather than the username=xxx,password=xxxx in the /etc/fstab file if you want to get this past your security person 😉

Using Pester and PowervRO as a Unit Test Framework for vRO

vRealize Orchestrator doesn’t have an in-built Unit Test Framework, however I realised that it might be possible to use a combination of Pester and PowervRO for now to achieve similar results. Let’s take a look at an example using a very simple workflow, Workflow1. Workflow1 has two inputs, a and b, both numbers:

unittest01

Workflow1 has a single scriptable task that takes the inputs a and b, multiples them together and stores the result in c, which is output from the workflow.

unittest02

We can write the following PowerShell based test using the Pester framework and PowervRO to test that the result of running Workflow1 with inputs of a and b, should be the value we supply for c. We make a connection to the vRO Server in question, invoke the workflow and then check the result:

We can supply variables to the test via a JSON file, so its simple to then take this test to other vRO servers, or change the values we are testing:

Now we can invoke the Pester tests and check the results:

unittest03

Obviously this process could be scaled out to many more workflows with different inputs and outputs.

 

Change the MIME Type of a vRO Resource Element

When a file is imported into vRO to be used as a Resource Element, a MIME type is automatically set depending on what has been imported. For instance, in the below example a shell script has been imported, the contents of which will be used as part of some vRO automation – notice the MIME type has been set to application/x-sh.

mimetype01

This doesn’t really cause a problem in itself when using the Resource Element in a workflow, however vRO doesn’t display the content of all MIME types when looking at the file in the Viewer tab and may display the message “cannot display this kind of element” instead – *.sh is one of those :

mimetype03

 

 

It is possible to change the MIME type of an existing Resource Element with the following code:

Drop that into a workflow and you can use it like this – supply inputs for which Resource Element and what MIME type to change it to. In this example we’ll use text/plain:

mimetype02

Upon successful completion of the workflow, the type should have changed:

mimetype04

and now the contents are viewable on the Viewer tab:

mimetype05

Exporting and Importing vRO Packages with PowervRO

One thing that I know colleagues and others are keen to automate with PowerShell and vRO is exporting and importing vRO packages. If you’re not familiar with a vRO package it is typically used to bundle up all of the Workflows / Actions / Configuration Elements / Resource Elements which make up the code for a particular project and use the package to transport the code to another system. So you may for instance wish to export a package and copy it to another vRO server or maybe into a version control system, or you may wish to automate the deployment of vRO itself and include importing the code as a final step.

PowervRO includes two functions to assist with this and potentially make use of for your automation of Packages, Export-vROPackage and Import-vROPackage.

To export a package we only need to supply the name of the vRO package and the file path to export it to:

 

powervro21

To import the package into another vRO system, transfer the file to the other system and run the following:

Before:

powervro22

powervro23

After:

powervro24

powervro25

 

Check the help for both functions for additional parameters covering fine tuning options that you might need as part of the export or import.

Export vRO Workflow Schema Images with PowervRO

Aside from any documentation around your vRO workflows, one of the best ways to quickly get up-to-speed with what it does and visualise how it is put together is to look at the schema. Wouldn’t it be handy if you could easily get hold of an image of the schema for one or multiple workflows? Well with PowervRO and your PowerShell console you can!

The REST API supports this, so we have included a function Export-vROWorkflowSchema . In this first example, we will export the Schema of a single workflow Test06.

We can then view the file on our desktop:

powervro19

Or if we want to export multiple vRO Workflow Schemata, say for all Workflows in a particular Category:

Happy Days 🙂

powervro20

 

Exporting and Importing vRO Workflows with PowervRO

There are a number of different ways to get your developed vRO content from one system to another: exporting / importing single items, exporting / importing vRO Packages containing multiple items, synchronising content directly between vRO systems.

In this example I’ll show you how to use PowervRO to export and import workflows from and to vRO.

Export vRO Workflows

To export a single workflow is pretty straightforward with the function Export-vROWorkflow:

However, without much extra effort we can leverage some standard PowerShell functionality and export a whole folder (category) of vRO workflows:

PowervRO14

PowervRO15

PowervRO16

 

Import vRO Workflows

Say we are now working on a new vRO system with the same folder structure, we can import one of the exported workflows with the following (note we need to find the ID of the category that we are importing into first):

PowervRO17

Or with a bit of extra work, we can import all of the exported workflows:

PowervRO18

 

Obtaining vRO Workflow State and Result with PowervRO

In the previous episode we looked at how to invoke a vRO workflow with PowerShell, via PowervRO and the Invoke-vROWorkflow function. Once you have kicked the workflow off you are likely to then want to find out the state of the workflow, when it has finished and any output from the workflow. Here’s how to do this via PowervRO.

Check the Workflow State:

First of all, we need to identify which execution of a particular workflow we want to check the state of. In GUI terms this means “which one of these?”:

PowervRO11

Typically, we will want to look at the active one, i.e. the most recent. We can find that as follows:

You can see there is a State property which gives a basic indication of what’s going on. We can find out more details with Get-vROWorkflowExecutionState:

Get the Workflow Result

If the workflow has Output parameters set we can retrieve the results with Get-vROWorkflowExecutionResult. In this example the workflow will generate a random number and include it as an output:

PowervRO12

PowervRO13b

We simply pipe the output of Get-vROWorkflowExecution into Get-vROWorkflowResult 🙂

Automate vRealize Orchestrator with PowerShell: Introducing PowervRO

For the PowerCLI book 2nd Edition I helped put together a chapter on vRealize Orchestrator. Most of the chapter was focused on running PowerShell scripts from vRO, which was something I’d had a fair bit of experience with in projects I had been on and also thought would be what most people reading would be interested in. At the end of the chapter I added a few functions using the vRO REST API to run things in vRO from PowerShell as a bit of an after-thought.

I was quite surprised when during a review phase my co-author Brian Graf suggested swapping the content of the chapter around because he thought there might be more interest in driving vRO with PowerShell, rather than having vRO execute PowerShell scripts. That didn’t quite happen due to time constraints on the book, but I kept that thought in mind having been sparked by the interest.

While putting together PowervRA I had some thoughts about expanding on what I had done in the book around PowerShell and vRO, improving what I had done for the book based on some feedback and incorporating everything we had learnt while putting that toolkit together. Thankfully Craig was up for another project and so PowervRO was born!

Over the course of the last two months or so we have put a toolkit of PowerShell functions together covering a significant portion of the vRO REST API and thankfully it has been a lot more pleasurable than what we have experienced with PowervRA  😉

Initial Release

For the initial release we have 59 functions available covering a sizeable chunk of the vRO REST API. Compatibility is currently as follows:

vRO: versions 6.x and 7.0.1

PowerShell: version 4  and above is required.

You can get it from Github  or the PowerShell Gallery

We have provided an install script on Github if you are using PowerShell v4. If you have v5 you can get it from the PowerShell Gallery with:

Getting Started

Get yourself a copy of the module via one of the above methods or simply downloading the zip, unblocking the file and unzipping,  then copying it to somewhere in your$env:PSModulePath.

PowervRO01

PowervRO02

Import the module first:

You can observe the functions contained in the module with the following command:

Before running any of the functions to do anything within vRO, you will first of all need to make a connection to a vRO server. If you are using self signed certificates, ensure that you use the IgnoreCertRequirements parameter. :

You’ll receive a response, which most importantly contains an encoded password. This response is stored automatically in a Global variable: $vROConnection. Values in this variable will be reused when using functions in the module, which basically means you don’t need to get a new encoded password or server URL each time, nor have to specify it with a function – it’s done for you.

Each of the functions has help built-in, alternatively you can visit this site http://powervro.readthedocs.org

Example Use Case: Invoke a vRO Workflow with a Single Parameter

Having made a connection to vRO, it’s now time to start using some of the functions from the PowervRO module. To invoke a vRO workflow we need to determine the Id of the workflow and whether the workflow requires any parameters to be sent in order to run it correctly. Let’s look at an example of a workflow Test02.

The Id is 5af6c1fd-3d12-4418-8542-0afad165cc08

PowervRO03

The workflow has a single parameter, a, which is a String:

PowervRO04

The schema of the workflow is very simple, there is a single Scriptable Task which logs what the input parameter a was:

PowervRO05

PowervRO06

We can get the ID of a vRO workflow with Get-vROWorkflow:

and we could use that ID directly with Invoke-vROWorkflow. However, we made this easier by adding Pipeline support to Invoke-vROWorkflow, so all you need to do is this:

And here’s the result:

PowervRO07

Example Use Case: Invoke a vRO Workflow with Multiple Parameters

So that was fine for a single parameter, but what to do if the workflow has multiple parameters? The parameter set for Invoke-vROWorkflow that we used in the previous example only supports a single parameter.

Let’s look at another example. The workflow Test03 has two inputs, a and b of different types, String and Number:

PowervRO08

Again it has a single Schema element, which does the following:

PowervRO09

Step forward New-vROParameterDefinition. We can use a combination of this function from PowervRO and Invoke-vROWorkflow and the Parameters parameter to submit the request to run the vRO workflow supplying multiple parameters.

To do this, create an array of parameters using New-vROParameterDefinition and supply them to Invoke-vROWorkflow:

and here’s the result of the workflow execution:

PowervRO10

Stay tuned for more examples on using PowervRO, you can also follow @PowervROModule for updates 🙂

Importing a vRO Package via the API – tagImportMode

I like the new Swagger UI for the vRO API, it makes it really easy to use:

tagImportMode01

While using it to figure out some stuff around importing a package, I hit an issue with the tagImportMode parameter:

tagImportMode02

Depending on which option selected, the following additions to the URL were listed in the documentation as follows:

https://vroserver.fqdn:8281/vco/api/packages?overwrite=false&importConfigurationAttributeValues=true&tagImportMode=Do%20not%20import%20tags.

https://vroserver.fqdn:8281/vco/api/packages?overwrite=false&importConfigurationAttributeValues=true&tagImportMode=Import%20tags%20and%20overwrite%20existing%20values.

https://vroserver.fqdn:8281/vco/api/packages?overwrite=false&importConfigurationAttributeValues=true&tagImportMode=Import%20tags%20but%20preserve%20existing%20values.

However, none of these choices seemed to work, just resulted in 400 (Bad request). Some trial and error followed with different possible combinations, but eventually I found two of them documented in the Developing a Web Services Client for VMware vCenter Orchestrator guide for vCO 5.5.1 and so was able to guess the third.

&tagImportMode=DoNotImport

&tagImportMode=ImportAndOverwriteExistingValue

&tagImportMode=ImportButPreserveExistingValue