Skip to content

A simple Python library to interface with VMware vRealize Orchestrator

License

Notifications You must be signed in to change notification settings

mrlindblom/vmwvro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vmwvro

A simple api library to interface with VMware vRealize Orchestrator (vRO).

Features

What you can do with vmwvro:

  • get workflow information
  • start a workflow
  • monitor a workflow run

Dependencies

Installation

vmwvro is available on the Python Package Index

$ pip install vmwvro

Quickstart

This guide will give you an introduction on how to get started with vmwvro.

Connecting to vRO

Connecting to VMware vRealize Orchestrator requires a Client object. The Client object exposes methods to manage Workflows. The following code sample illustrates how to create a Client object:

>>> from vmwvro import Client, Session
>>> vro_url = "https://my_vro_server:8281"
>>> vro_usr = "my_username"
>>> vro_pwd = "my_password"
>>> client = Client(Session(url=vro_url, username=vro_usr, password=vro_pwd))

The Session object can also accept the following optional parameters:

  • verify_ssl -- verifies SSL certification, by default it is set to False
  • disable_warnings -- disables warnings, by default it is set to True

Once you have a Client instance, you can proceed with the following examples.

Run a Workflow

In order to start a Workflow, you will need to know the Workflow Id of the Workflow.

>>> wf_id = "1a20863f-549b-47e4-a9db-361ea4fa2f69"
>>> wf = client.get_workflow(wf_id)
>>> wf_run = wf.start()
>>> print("Workflow state: %s" % wf_run.state)
Workflow state: running

Passing Workflow Parameters

Many Workflows require one or more input parameters. The following code illustrates how to create and pass parameters to a Workflow:

>>> from vmwvro.workflows import WorkflowParameters
>>> param = WorkflowParameters()
>>> param.add(name="vmname", value="some_vm_name", _type="VC:VirtualMachine")
>>> param.add(name="user", value="some_user")
>>> wf_run = wf.start(param)
>>> print("Workflow state: %s" % wf_run.state)
Workflow state: running

The add() method requires the name and value of the parameter. You can also specify the type if it is not a string.

Wait for Workflow to Complete

After starting a Workflow, it may take a few seconds to a few minutes to complete. The following code illustrates how to wait for the Workflow to finish:

>>> wf_run.wait_until_complete()
>>> print("Workflow completed with state: %s" % wf_run.state)
Workflow completed with state: completed

About

A simple Python library to interface with VMware vRealize Orchestrator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages