VMWare: automate virtual machines startup and shutdown

At my company we have an in-house server (Win 2008 server) running some virtual machines for our continuous integration process and source hosting. We use VMWare player to run those machines and the problem is that people tend to forget that those virtual machines have to be shut down before the host is shut down.

This windows server was really not bought for this kind of thing, and we quickly had performance problems with our virtual machines. I took the initiative to buy a new linux based server, with a bigger CPU and more RAM. The first thing I tried to do was automate the process of starting and shutting down the virutal machines so that we didn’t face the situation again.

I made the following assumptions:

All virutal machines are stored in the same root directory, like so:




and so one.

At boot time, every virtual machine needs to be started and when shutting down the host, they all need to be stopped (of course they need to be shutdown and not powered off).

I came accross the vmrun utility for vmware products that could help in automating the process.

Basically I scripted a vm-service utility, and a linux service wrapper for vmrun. The vm-service is able to start/stop all virtual machines found in a given directory, or start/stop a given virutal machine in this directory using it’s name or another virtual machine using it’s path.

The linux service’s job is basically automating the process at boot/shutdown.

The sources are available at: https://github.com/aferre/vm-automation


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s