For vSphere customers and partners who use the Python programming/scripting language, Christmas may have just arrived early. I just found today, VMware has published an initial release of their vSphere SDK for Python called pyVmomi on Github this past weekend. A Python-based SDK has always been a very popular feature request among customers and partners that I have spoken with in the past. It looks like VMware Engineering has heard you loud and clear and have been working hard to get this released.
pyVmomi Github Repository:
pyVmomi Pypi package:
One of the nice things about releasing pyVmomi on Github versus trying to package it with a particular vSphere release is that the larger VMware community can contribute to the project as well as more frequent updates from VMware. This has also been quite successful for another popular VMware SDK called rbvmomi (vSphere SDK for Ruby) which is seeing a huge uptick with RVC (Ruby vSphere Console) which is built on top of rbvmomi and is a great tool for managing and troubleshooting VMware VSAN.
In this first release, you will notice there is a limited amount documentation and samples exercising the various capabilities of vSphere and you will see further enhancements in these areas with future updates. If there are specific things you would like to see or samples that you think would be useful to have or that you have built, feel free to file an issue or send pull requests to the pyVmomi Github.
If you wish to quickly get started, you can install pyVmomi using a variety of methods including pip, easy_install and pypi package. Below are the steps I took to install pyVmomi on my Mac OS X system using pip and git.
Step 1 - Install pyVmomi using pip by running the following command:
sudo pip install pyvmomi
Step 2 - Clone the pyVmomi Github repo to your system using Git by running the following command:
git clone https://github.com/vmware/pyvmomi.git
After the above command, you will have a folder called pyVmomi which contains the source code as well as the two sample scripts. You can contribute back if you create additional samples or enhancements to pyVmomi by simply sending a pull requests.
Try the getallvms.py sample run the following command:
python sample/getallvms.py --host mini.primp-industries.com --password [PASS]
To try the poweronvm.py sample run the following command:
python sample/poweronvm.py --host mini.primp-industries.com --password [PASS] --vmname [VM]
Ramzan Ali says
what awesome gifts these would make!! Thanks so much to create suggestions to, you're so creative! I'll be trying this out at some part 🙂
Josh Coen says
Worked perfectly. Thanks for the walk-through.
Every few months I google around for 'python vmware' hoping to see something new, this has made me very happy
Guess typo: After the above command, you will not have a folder called pyVmomi which contains - should be you WILL have a folder...
William Lam says
Thanks. I've fixed the typo
Please help me for this issue https://communities.vmware.com/thread/490122
Does pyvmomi support all VASA2.0 calls? If yes, what is plan for VASA3.0 support?.
Sreemannarayana Raju says
Is there a way to modify the ethernet adapter settings of the ESXI host using pyvmomi ??
vivek kumawat says
Is there any way to ssh to a VMware machine through a python script? and that python script we are running on a linux machine.