Oddthesis-logo

VM2: Like EC2, but local

EC2 is awesome, but...

While I've been working towards getting stuff to work on Amazon EC2, I'm living a bandwidth-challenged lifestyle where DSL doesn't reach.  Shuffling images back and forth to Amazon is not awesome.

After discovering vmrun, I knocked together a handful of scripts to provide a workflow similar to EC2, but locally, using VMWare on my workstation.

VM2: Virtual Machine Mesh

I present VM2: Virtual Machine Mesh.

It is not intended to be exactly compatible with EC2, but to provide "close enough" match in workflow and functionality, particularly spinning up multiple instances from a single image, and boot user-data for configuration injection.

The JBoss-Cloud project can generate a VMWare bundle, which we register in VM2:

leonard:vm2 bob$ vm2 register /Users/bob/oddthesis/jboss-cloud/build/appliances/jboss-as5-appliance-1.0.0.Beta2-1.tgz
registering jboss-as5-appliance-1.0.0.Beta2-1 as vmi-b175c299b3

We can poke around and see the registered images

leonard:vm2 bob$ vm2 describe-images
VMI Name User Date
----------------------------------------------------------------------------------------------------
vmi-7839267fe0 postgis-appliance-1.0.0.Beta2-1 bob Wed Dec 31 15:08:23 -0500 2008
vmi-b175c299b3 jboss-as5-appliance-1.0.0.Beta2-1 bob Wed Dec 31 16:55:12 -0500 2008
----------------------------------------------------------------------------------------------------
2 images

When registered, the image bundle gets stashed away in ~/.vm2/images/ for safe-keeping.

From there, we can launch instances from the image.  The bundle is expanded into a unique directory under ~/.vm2/instances/ for each instance you want to spin up.

Here we spin up 2 instances of the jboss-as5-appliance.

leonard:vm2 bob$ vm2 run-instances vmi-b175c299b3 -n 2

You can review the status of your instances

leonard:vm2 bob$ vm2 describe-instances
Instance ID VMI State IP Address User Created
---------------------------------------------------------------------------------------------------------------
i-c160b05b43 vmi-b175c299b3 PREPARING - bob Wed Dec 31 16:59:42 -0500 2008
---------------------------------------------------------------------------------------------------------------

It'll go through the the following states

  • PREPARING as it expands the image bundle for the instance
  • STARTING as it boots up enough to know an IP address
  • RUNNING when it's fully launched (init.d may still be churning)
  • STOPPED when it's not actually running

Once they're running, vm2 describe will show you their addresses:

leonard:vm2 bob$ vm2 describe-instances
Instance ID VMI State IP Address User Created
---------------------------------------------------------------------------------------------------------------
i-c160b05b43 vmi-b175c299b3 RUNNING 192.168.237.153 bob Wed Dec 31 16:59:42 -0500 2008
i-d864f89097 vmi-b175c299b3 RUNNING 192.168.237.152 bob Wed Dec 31 17:00:33 -0500 2008
---------------------------------------------------------------------------------------------------------------

At this point, the guest images require open-vm-tools and a special RPM called vm2-support that is available in the jboss-cloud project.  Thankfully, all of the JBoss-Cloud images automatically include both.  Gee whiz.

It all operates on the local filesystem, and is not multi-user safe.  I also need to master some fork/exec Zen, to make it less blockfull.  It also assumes root's password is "thincrust" since I'm using the Thincrust tooling to create these images.

In addition to the EC2-alike commands of run-instances and terminate-instances, there's shutdown-instances which allow you to shutdown but retain the image for future use with start-instances.

Boot user-data gets injected into /etc/vm2-user-data.conf at this point.  I may try to add an EC2-alike magic metadata webserver, but I think the direct file inject will play friendly enough with Puppet for now.

Get it

You can track VM2 from the bobmcwhirter/vm2 GitHub repository.

Comments

Chris Pilsworth, 09:40pm UTC, 05 January 2009

Hi Bob,

How did you convert the virt image to a vmx? I have been trying to convert it, but virt-pack complains that the descriptor needs to contain a name and version number. I can run the image OK on Fedora, but would like to move it across to Fusion on the Mac.

Keep up the good work

Chris

Bob McWhirter 09:56pm UTC, 05 January 2009

@Chris--

A-ha, yes, that is a problem. The JBoss-Cloud stuff does an explicit fix-up of the original .xml created by appliance-creator. If you're using the JBoss-Cloud rakefile, just add ":vmx" to end of the target. You'll notice a .xml.vmx-input created with some changes that are fed into virt-pack.

You need to add a <name> tag with a 'version' attribute in the .xml. I also make sure there's a <description> element.

For instance


<name version='1.0.0.Beta2-1'>jboss-as5-appliance</name>
<description>jboss-as5-appliance Appliance</description>

Chris Pilsworth, 09:49am UTC, 06 January 2009

Thanks Bob - that worked a treat. I couldn't much documentation for the virt-pack and virt-convert programs. All the best for the Virtual Experience - the slides look great.

Chris

Bob McWhirter 01:19pm UTC, 06 January 2009

@Chris--

The Thincrust guys hang on #thincrust on irc.freenode.net. They've been super helpful in assisting me in getting everything running.

Login to avoid moderation.

Sign up if you need an account.

Creative Commons License Copyright 2008. Odd Thesis by Bob McWhirter is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.