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.