This is actually a script I built to test out various things at once.  I was testing (and learning) how the vRealize Automation REST API calls work.  There are other good resources on the web for getting started.  While not a vRealize Automation example, I enjoyed this blog entry on Python and vSphere REST API calls with Python.    Between that, and the official documention, and some Postman experimentation, I was able to get things going.

The script itself as I use it is currently called within a simple Flask application, and served up by a NGINX container.  

Some other notes:

  • Import Credentials requires you to make a simple python file with a dictionary I called “login.”
  • You need a bearer token to authenticate with vRA.  So the first function grabs one.
  • Main work is done in the “get_resource_views,” where we grab all of the VMs created, get the information we desire, and then sort it.
  • “get_csv” creates a .csv file that I then save.  I link to the .csv file on the internal web page so that the report can be downloaded by those that need it.

The code can probably be tweaked further, but this should be enough to get most up and running.  I welcome any and all comments.