Get Virtual Machines from VMware with PySphere

This is a simple example of how to get a list of Virtual Machines from a VMware host, using PySphere.

{% highlight python %} import pysphere

server = pysphere.VIServer() server.connect('vmware.zindilis.net', 'username', 'password')

vms = server.getregisteredvms() for vm in vms: virtualmachine = server.getvmbypath(vm) print virtualmachine.getproperty('name'), virtualmachine.getproperty('ip_address') {% endhighlight %}

Posted on