A collection of python scripts to automate and extract reporting information from vCenter
TOC
- Requirements
- Install
- Script Index
- snapshot.py - list and manage VM snapshots
- sessionCtrl.py [DEPRECATED] - manage vCenter sessions
- Python 3.8+
pip packages:
Full tested package requirements are defined in requirements.txt
These scripts have been tested on VMware vSphere 7.0.3 using Python 3.11.
Using a virtualenv is highly recommended.
- Install packages in
requirements.txt
. - Clone this repo.
- Copy
vmware-pyscripts.conf-dist
tovmware-pyscripts.conf
and edit as needed:
[main]
# Enable debugging output (yes|no)
EnableDebugging = yes
# Timezone for output (format: America/Los_Angeles)
Timezone = America/Los_Angeles
# vSphere hostname
VSphereHost = changeme
# vSphere port
VSpherePort = 443
# Enable verification of vSphere SSL certificate (yes|no)
VSphereVerifySSL = yes
- Set vSphere API credentials as environment variables:
VSPHERE_USERNAME
VSPHERE_PASSWORD
Usage:
snapshot.py list [VM_NAME ...] [--older-than=DAYS_AGO] [--output-width=CHARS]
snapshot.py create VM_NAME SNAP_NAME [SNAP_DESC] [--snap-mem] [--quiesce]
snapshot.py delete VM_NAME (SNAP_NAME | --all)
A script for managing vCenter sessions: view current sessions, terminate a session, or terminate sessions idle longer than a given amount of time.