VMware Cloud Community
seangadson
Contributor
Contributor

vRO Python vRA/vRO 8.1 Actions

Hello,

I am looking for a bit of guidance I am trying to get my python action script to work.  Right now I am getting an error that it can't find the function even though the name of the function is the same name in the Entry Handler

Capture.PNG

picture1.PNG

0 Kudos
6 Replies
inevp
Enthusiast
Enthusiast

You don't need to invoke your function explicitly, so remove the last line that contains handler().

Also, if the name of your python file in the ZIP is 'index.py' in the "Entry handler" field you should put 'index.handler', not 'handler.index'.

0 Kudos
seangadson
Contributor
Contributor

Now I am getting that it can't find the handler function
Capture.PNG

picture1.PNG

0 Kudos
inevp
Enthusiast
Enthusiast

Did you update your existing action? If so, you might have encountered some bug related to updating the action, please try creating a new vRO action where:

1. The ZIP archive has the "index.py" file in its root

2. "Entry handler" is set to "index.handler"

0 Kudos
maverix7
VMware Employee
VMware Employee

As inevp​ wrote. Additionally, since I se you are trying to import the requests lib. If it fails to load this will result to the same error, that handler is missing. Please make sure that you have a lib folder along side index.py with the requests module. To include 3rd party libs like the requests, you can follow the documentation Create a Python Script That Calls the vRealize Automation Project API

0 Kudos
rlabinot
Enthusiast
Enthusiast

In the link you mentioned, it shows how to create a python action package to make requests to vRA API.

But to make these requests API, you need an Access Token and it's only valid for 8 hours.

We can renew it by using the API Token valid for 90 days, but you still need to renew after 90 days. What is the best practise to have a configuration that manages these tokens automatically ?

Can't we have a unlimited lifetime token or should we create a new script that generate a new API and Access token and passing them as inputs to python script at each execution ?

Thanks for your help!

0 Kudos
rmav01
Enthusiast
Enthusiast

Really late to the party on this, but might be worth mentioning if some other Googlers out there scratching their head on this, like I did today.

When you create the zip bundle to upload to the vRO, make sure that you are zipping the files themselves inside the directory, not the directory itself. So if you had a file tree like:

mypolyglot - (do NOT zip here)

  - lib (zip here)

  - index.py (zip here)

If the the parent directory is the top level of the zip, you'll get the "Cannot find module" error.

0 Kudos