= Cloud Imaging
== Copyright, license
Copyright (c) 2005-2011 Grameen Foundation USA. All rights reserved.
Mifos Cloud (all source code herein) is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
link:COPYING[] is a complete copy of the GNU General Public License. If you
have trouble viewing this file, see http://www.gnu.org/licenses/.
== What's in here and how to use it
The cloud imaging is divived in two stages.
1. Generate statefile that contains a list of all debian packages and their
versions.
2. From this statefile generate an ec2 bootable image (and in the future a
livecd, etc) from this statefile
The script imaging/create_state.sh is used to accomplish both stages.
The statefile is checked into version control and the exact image can be
generated at any point in the history of the statefile.
A CI job can then poll version control and run the create_state.sh with the
`--build_image` flag to generate a bootable ec2 image.
If desired a CI job could also periodically generate the statefile and check it
in headlessly. Upon checkin this could kick off the above job.
A typical invocation for stage (1) would look like:
sudo ./imaging/create_state.sh --statefile statefiles/lucid_updated_chef_tomcat6_jdk.state
For stage (2) it might look like:
sudo ./imaging/create_state.sh --statefile statefiles/lucid_updated_chef_tomcat6_jdk.state --build_image --imagedir /home/ubuntu/build
`--imagedir` should be an empty ebs volume mounted as ext3.
In addition the validation.pem cert (and other secrets) must be in the private
directory which by default is in `$HOME/private` and can be overriden with the
`--private <dir>` flag.
After an invocation of stage (2) an ami can be created like so:
bash> ec2-create-snapshot -d "<description>" <ebs volume>
SNAPSHOT snap-c38766ae vol-7e16dc16 pending 2010-12-14T00:35:44+0000 790832682666 2 test ec2
bash> ec2-register --kernel aki-407d9529 --root-device-name /dev/sda1 --name "<name>" --snapshot snap-c38766ae
IMAGE ami-6208fe0b
or
ec2-bundle-image -r i386 -i tmp/debian-ami -c <PATH_TO_CERT> -k <PATH_TO_PEM> -u <ACCOUNT>
ec2-upload-bundle -b mifos-amis -m /tmp/debian-ami.manifest.xml -a <KEY> -s <SECRET>