Python: list clusters, hosts and VMs

Just following on from my previous article (HERE) on using Python Pyvmomi SDK wrapper for the vSphere Web Services API this time I show you how to iterate through the Web Services API tree. In numerous posts and VMUG sessions, I have given dating back to 2007 I have discussed that the objects in vSphere Web API are laid out in a hierarchical tree. Probably using the same relationship that objects have inside the vCenter Database. Here is the current diagram form the Vmware documentation. At the root of the tree, there is a folder; it contains the datacenter object. Underneath the Datacenter object is several other folders containing related objects. One for hosts, one for VMs, one for Networks and one for Storage. Click HERE to read more.