ESXi python module

In this blog, I will be discussing about vmsupport python module, and will be writing simple program to list powered on and regisered vm.

Below is pydoc output.

NAME
  vmsupport
FILE
    /lib/python2.7/site-packages/vmsupport/__init__.pyc
PACKAGE CONTENTS
    action
    archiver
    errlog
    manifest
    performance
    vmtar
    vmutils

Help on module vmsupport.vmutils in vmsupport:
NAME
    vmsupport.vmutils
FILE
    /lib/python2.7/site-packages/vmsupport/vmutils.pyc
FUNCTIONS
 getRegisteredVMPaths()
 getRegisteredVMs()
getVMPaths(vmxFilePath)
 Parses the .vmx file and adds any directories specified by a ‘.*filename = ‘ line
 Ignores the fileSearchPath config option (and all that other crazy stuff that we don’t actually use [i hope]).
 listVMs() List the running VMs.
loadRegisteredVMs(invtPath=’/etc/vmware/hostd/vmInventory.xml’)
DATA
    knownVMs = {}
    vmPaths = {}

Help on module vmsupport.performance in vmsupport:
NAME
    vmsupport.performance
FILE
    /lib/python2.7/site-packages/vmsupport/performance.pyc

FUNCTIONS
gatherPerfSnapshots(manifestLoader, tarObj, interval, duration)
 Gather periodic vsi snapshots (eventually) markLogFiles(snapshotNumber, state)

#!/usr/bin/python
import sys
import os
import vmsupport
from vmsupport import vmutils
from vmsupport.vmutils import listVMs
listVMs()

python vm-list.py

/vmfs/volumes/527e924d-b01c68e8-9c00-18a8056626de/VC/VC.vmx (Running)
/vmfs/volumes/527e924d-b01c68e8-9c00-18a8056626de/node/node.vmx (Registered)