Sample Exchange

 View Only

Script to fetchAuditRecords 

Nov 03, 2021 03:45 PM

How to use pyVmomi SDK for vSphere 7.0U3 to fetchAuditRecords

 

  1. OSS pyVmomi is hosted in GitHub: https://github.com/vmware/pyvmomi
    The project's main page contains pointers to general instructions for public releases of pyVmomi SDK.
  2. Attached is the sample code, audit.py, that will fetch audit records from ESXi using the OSS pyVmomi SDK.

 

Install pyVmomi SDK

First, you'll need a functioning Python environment. This may differ by operating system and distribution.

  1. Inspect your system and determine if Python 3.5 or later is installed. If not, get the latest Python 3.x
  2. get pip (Note: see the package manager section)

 

You need the pyVmomi SDK module inside your pypath and then import the module in your Python code.

To install the pyVmomi PyPI package:

% pip3 install pyvmomi

(pip3 is for Python 3 or higher)

Or if there is an older version already installed:

% pip3 install pyvmomi -upgrade
 

Please check the pyVmomi samples for usage examples: https://gitlab.eng.vmware.com/api-platform/pyvmomi-community-samples

 

Run audit.py

Make audit.py file executable (chmod +x audit.py).

To get info on audit.py input parms:

% ~/tmp$ ./audit.py --help
usage: Display locally stored audit records. [-h] --host HOST --password PASSWORD --user USER

optional arguments:
-h, --help show this help message and exit
--host HOST The IP address of the ESXi host
--password PASSWORD Password to log in with
--user USER User name to log in with

Run to talk to ESXi box:

% ./audit.py --host IP_addr --user root --password ""

 


#Pyvmomi
#vSphere
#Python
#fetchAuditRecords
#BSD3-Clause
#audit.py
#vSphere
#NIAP

Statistics
0 Favorited
0 Views
1 Files
0 Shares
0 Downloads
Attachment(s)
py file
audit.py   1011 B   1 version
Uploaded - Apr 09, 2024

Tags and Keywords

Related Entries and Links

No Related Resource entered.