VMware Cloud Community
ElVirtualJefe
Contributor
Contributor

vRO 8.1 Python Code Samples

Can anyone point me to some basic documentation on how to get started writing Scriptable Tasks in vRO 8.1 with Python?

I'm specifically looking for any information on getting the vAPIEndPoint setup to be utilized in Python.  I have asked The Great Google Machine to no avail.  I'm assuming since the feature is new in vRO, that there is little to no samples or documentation on how it is setup.

Any help would be much appreciated.  Thank you in advance!

4 Replies
maverix7
VMware Employee
VMware Employee

Apart from the official ical documentation - Create a Python Script That Calls the vRealize Automation Project API

I have prepared a github repo for the purpose - vro-polyglot-scripts/python at master · tgeorgiev/vro-polyglot-scripts · GitHub

Both are focused on Actions, rather than Scriptable Task, the concept is the same, the only difference is that an Action returns a single value, while the Scriptable Task should return a map, in order to modify the necessary output values. However it is recommended to use an Action, because there you will have the ability to tweak limits, include 3rd party scripts (by bundling them in zip), and you also get nice features like, actions have their own lifecycle, can be updated and ran (even debugged!) independently.

Reply
0 Kudos
ElVirtualJefe
Contributor
Contributor

maverix7,

 

Thank you for this information.  I understand how all of these pieces work, but my ultimate goal is to setup a workflow to be scheduled, so an Action doesn't really help me.

 

Specifically, I'm trying to figure out how to interact with the VAPI:* objects in Python.  Based on my research, it looks like there may not be an exposure of the VAPI:* objects to Python, which I'm guessing that means I will have to create some intermediary steps and use JavaScript to interact with the VAPI:* objects and convert them to something that Python can work with.

 

Does this sound right?

 

Thanks!!

Reply
0 Kudos
maverix7
VMware Employee
VMware Employee

ah ok then. In Python (and the other new runtimes) you don't have the same access to the inventory and system objects as with the standard JavaScript. You may have to think of your own mechanism to interact with them, such as maybe providing the ID, name as strings. You can also try passing the whole object, but only serialisable fields will be converted to a Map object in Python.

Reply
0 Kudos
ElVirtualJefe
Contributor
Contributor

This is essentially what I figured, based on the research I have done...

 

Essentially, what I believe I will need to do, is create "helper" scripts in JavaScript to handle the VAPI:* Objects, and then pass them in and out of the Python Scripts.  Basically use JavaScript to convert the input VAPI:* objects to something Python can handle, and then use JavaScript to receive the output of Python, and convert them back into VAPI:* objects.  This should allow me to continue with our internal standard of using Python for scripting, but still get the full featureset of Automation/Orchestrator.

 

Thanks for your response, and time.  Hopefully in 8.2 or 8.3 they will get this added for Python.