Jan 30

VMware control from Python

Category: Tool
.!.

Peach 2.0 development is blazing along, at some point I needed a python module to control a vmware server to allow for automatic start, stop and reverting.  I figured I’d release this useful bit of code as a python module.

Available here

from vix import Vix
import time
vm = Vix()

print "Connecting"
vm.Connect()

print "Opening vm"
vm.Open("E:\\VMs\\Windows XP\\Windows XP Professional.vmx")

#print "Powering On vm"
#vm.PowerOn()
#print "Waiting a bit..."
#time.sleep(10)
#print "Powering off vm"
#vm.PowerOff()

print "Reverting to snapshot 0"
vm.GetRootSnapshot()
vm.RevertToSnapshot()

print "Sleeping"
time.sleep(10)

print "Disconnecting"
vm.Disconnect()
2 comments

2 Comments so far

  1. Noah Gift November 18th, 2007 5:38 am

    Any chance you have the source code available?

  2. Michael Eddington May 23rd, 2008 9:58 am

    Yes, if you follow the provided link you will find the source available.

Leave a comment