Run vRealize Orchestrator Workflow from PowerCLI

This post is the first of many that will talk about VMware vRealize Orchestrator and the power that can give us to automate our environment.

First things first, let’s see a short description of the product:

vRO_logo

VMware vRealize Orchestrator Automates Complex IT Processes, simplifies the automation of complex IT tasks, it can be integrated with vRealize Suite and vCloud Suite to further improve service delivery efficiency, operational management and IT agility. vRealize Orchestrator can be not only integrated with VMware products, vendors integrating their products are growing everyday.

 

We can find VMware full description at: http://www.vmware.com/products/vrealize-orchestrator.html

We will see in future posts the programming philosophy and the workflow structure used by vRO, but to start, I’m going to deal with the need of running our vRealize Orchestrator workflows from outside of Orchestrator Client to automate even more our IT Processes. Here you can find a聽 script to run a vRO workflow from PowerCLI and monitor the result of the execution:


# Author: Juan Vicente Lopez
# Description: Call vRealize Orchestrator workflow and control exit
# Example: ./Run_Orchestrator_Workflow.ps1 -WorkflowName "Workflow to be executed"

param(
[Parameter(Mandatory=$True)]
[string]$WorkflowName
)
$user='your_user'
$password='your_password'
$vROserver='http://FQDN_YOUR_VRO_SERVER:8280/vmware-vmo-webcontrol/webservice?WSDL'

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

# First of all connect to vCO and generate Proxy on $vcoWS
$vcoWS = New-WebServiceProxy -Class VCO -Namespace VCO -Uri $vROserver

# Find Workflows with specified name, keep in mind that it returns an array
$workflows = $vcoWS.getWorkflowsWithName($WorkflowName, $user , $password)

if ($workflows -eq $null) {
Write-Host "Workflow does not exist"
exit (1)
}

# Select the first workflow of the array
$workflow = $workflows[0]

# Execute workflow
$workflowToken = $vcoWS.executeWorkflow($workflow.id, $user, $password, $null)

# Monitor the execution and return the result
do { Start-Sleep -Seconds 2 }
while ( $vcoWS.getWorkflowTokenStatus(@($workflowToken.id), $user , $password) -eq "running")

if ( $vcoWS.getWorkflowTokenStatus(@($workflowToken.id) , $user , $password) -eq "completed") {
Write-Host "Workflow successfully executed"
exit (0)
}
else{
Write-Host "Workflow execution failed"
exit (1)
}

This is script is just an example of how to deal with the need of running a vRO workflow from PowerCLI.

We can find more ways to work with workflows from PowerCLI, another example is PowervRO, a Powershell module built on top of the services exposed by the vRealize Orchestrator REST API.

You can find more info of PowervRO here:

How to install: https://www.powershellgallery.com/packages/PowervRO/1.0.0
Github: https://github.com/jakkulabs/PowervRO

Thanks for sharing 馃檪

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInBuffer this pageEmail this to someonePrint this page

Deja un comentario

Tu direcci贸n de correo electr贸nico no ser谩 publicada. Los campos obligatorios est谩n marcados con *