In this blog we will go through how we can utilise Python and export the managed machine for vSphere endpoint.
Prerequisites :
- Python 3.x should be installed on machine or Laptop where we want to run below code.
- Connectivity from machine to vRealize Automation Cloud or On-Prem.
- Once Python 3.x is installed we need to install 2 modules by using below commands
pip3 install requests
pip3 install prettytable
If you are using windows then you can follow the this article or we can use any Code editor like Visual Studio also to run this.
- If want to run against On-Prem vRA 8.X then we need below details .
FQDN of vRealize Automation
UserName
Password - for vRA Cloud CSP token which has access to Cloud Assembly and Service Broker.
- If we want to pull details from vRA Cloud then we need Cloud API url details from Specific Region
Below are the Region and their correspond URL.
api.mgmt.cloud.vmware.com -- U.S.A
in.api.mgmt.cloud.vmware.com -- India
uk.api.mgmt.cloud.vmware.com -- Untied Kingdom
au.api.mgmt.cloud.vmware.com -- Australia
sg.api.mgmt.cloud.vmware.com -- Singapore
br.api.mgmt.cloud.vmware.com -- Brazil
de.api.mgmt.cloud.vmware.com -- Germany
ca.api.mgmt.cloud.vmware.com -- Canada
jp.api.mgmt.cloud.vmware.com -- Japan
Implementation:
Download the attach file ,unzip it and open the file with Python IDLE.

Once opened Press F5 or from Menu choose Run

For VRA Cloud Run the below command,In my example i am providung U.S region url.
How to generate the CSP token
________________________________________________________________________________________________
To authenticate vRA Cloud:
authtoken = vRACloud_Login(token='CSP token', cloudurl='api.mgmt.cloud.vmware.com')
________________________________________________________________________________________________
To Authenticate vRA On-Prem:
authtoken = vRAOnPrem_Login(vrafqdn='vra.vmwarecode.com', username='configadmin', password='VMware1!')
________________________________________________________________________________________________
vRA Cloud: To see the List of Managed Machines :
get_Managed_vSphere_VMs(url='api.mgmt.cloud.vmware.com', token=authtoken)
vRA Cloud: To Generate the CSV file :
get_Managed_vSphere_VMs(url='api.mgmt.cloud.vmware.com', token=authtoken, ExportToCSV=True)
vRA Cloud: To Generate the HTML File:
get_Managed_vSphere_VMs(url='api.mgmt.cloud.vmware.com', token=authtoken, ExportToHTML=True)
vRA Cloud: To Generate Json data File:
get_Managed_vSphere_VMs(url='api.mgmt.cloud.vmware.com', token=authtoken, ExpertToJson=True)
vRA Cloud: To generate All Files for vRA Cloud:
get_Managed_vSphere_VMs(url='api.mgmt.cloud.vmware.com', token=authtoken1, ExportToCSV=True, ExportToHTML=True, ExpertToJson=True)
vRA On-Prem: Commands:
get_Managed_vSphere_VMs(url='vra.vmwarecode.com', token=authtoken)
get_Managed_vSphere_VMs(url='vra.vmwarecode.com', token=authtoken, ExportToCSV=True)
get_Managed_vSphere_VMs(url='vra.vmwarecode.com', token=authtoken, ExportToHTML=True)
get_Managed_vSphere_VMs(url='vra.vmwarecode.com', token=authtoken, ExpertToJson=True)
get_Managed_vSphere_VMs(url='vra.vmwarecode.com', token=authtoken1, ExportToCSV=True, ExportToHTML=True, ExpertToJson=True)
Sample screenshot of how report looks like:


6 responses to “Aria Automation(VRA) Cloud / On-Prem — How to Export managed machine using Python in CSV,HTML and Json”
i encountered python error message while executing commands.. would you look into this and help to resolve it ?
LikeLike
At line:1 char:62
+ … uthtoken = vRAOnPrem_Login(vrafqdn=’xxxxx.xxx.’, usernam …
+ ~
Missing argument in parameter list.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingArgument
LikeLike
Can you share which command you used ?
LikeLike
vRA On PREM COMMAND
authtoken = vRAOnPrem_Login(vrafqdn=’vra.vmwarecode.com’, username=’configadmin’, password=’VMware1!’)
LikeLike
you are suppose to replace this with your vRA credentials
LikeLike
If you have replaced with your credentials and make sure you provide local user not domain user
LikeLike