-
Notifications
You must be signed in to change notification settings - Fork 1
Setting up an openstack image
The aim of all this fiddling is to get an Ubuntu OpenStack instance running TsuDAT2.
Sounds easy - why don't we just start an Ubuntu 64bit image and add ANUGA and TsuDAT? That's fine, until you stop and restart the image, which would lose any changes you made.
What you have to do is run a base image, make changes to it, and then create a new image that contains all your additions. When you run this new image you will see all your added software.
This example illustrates the process by creating an image with ANUGA and TsuDAT installed. We use the command line exclusively below.
You can start with any EMI you want. List the available EMIs:
$ euca-describe-images
It's probably best to start with this one:
uec/uec-10.04.manifest.xml ami-0000001a
This is an Ubuntu 10.04 64bit image, which is what we want.
Note the ami-XXXXXXXX number and start the image.
As usual, note the instance number and associate a public IP to the instance.
Now ssh to the running EMI:
$ ssh -i /home/tsudat/.nova/testkey.private ubuntu@<public IP>
On the running EMI: as root edit /etc/apt/sources.list and ensure these lines are present:
# for tsudat install
deb http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
If you are not running 10.04, change all occurrences of lucid to the appropriate name.
Then do this:
$ sudo apt-get update
On the running EMI:
$ sudo apt-get install python-scipy python-numpy python-matplotlib python-matplotlib-data python-amqplib \
python-dev python-netcdf python-profiler ttf-liberation python-boto zip nfs-common portmap \
euca2ools rsync ntpdate
On the running EMI, add the following lines to the end of /etc/fstab:
# for TsuDAT data
10.140.99.251:/short/w85 /data nfs defaults,intr 0 0
and create the mount point and mount the data:
$ sudo mkdir /data
$ sudo mount /data
Make sure the mount occurs.
On the running EMI, get and unzip the ANUGA source tarball into /anuga on the running instance. Then add these lines to _/.bashrc_:
# after ANUGA local install
export PYTHONPATH=/home/ubuntu
If required, remove any previous ANUGA install:
$ sudo rm -Rf /usr/lib/python2.6/dist-packages/anuga
Then (in a new terminal window), run the compile and test_all code:
$ cd ~/anuga
$ python compile_all.py
$ python test_all.py
You may get an error like no display name and no $DISPLAY environment variable. This is normal and may be ignored. Fix any other errors before continuing.
On the running EMI copy the certificates down and install:
$ cd
$ scp -r [email protected]:.nova .
$ . .nova/novarc
On the running EMI copy the bootstrap.py, tsudat_log.py, mount_nfs_shares.py and messaging_amqp.py files to /home/ubuntu (note that some change names on the copy):
$ scp [email protected]:/var/www/tsudat2/run_tsudat/ncios_bootstrap.py ~/bootstrap.py
$ scp [email protected]:/var/www/tsudat2/run_tsudat/tsudat_log.py ~/tsudat_log.py
$ scp [email protected]:/var/www/tsudat2/run_tsudat/mount_nfs_shares.py ~/mount_nfs_shares.py
$ scp [email protected]:/var/www/tsudat2/run_tsudat/messaging_amqp.py ~/messaging_amqp.py
the 192.43.239.232 is the IP of the server.
On the running EMI edit /etc/rc.local and insert the following lines just before the final exit 0 line:
# mount NFS shares
/usr/bin/python2.6 /home/ubuntu/mount_nfs_shares.py >/home/ubuntu/rc.local.out 2>&1
In the ubuntu user crontab, do:
@reboot . /home/ubuntu/.nova/novarc; /usr/bin/python2.6 /home/ubuntu/bootstrap.py >/home/ubuntu/bootstrap.log 2>&1
The point of the above change is to run our bootstrap code in the correct environment at instance start.
NOTE: If you are continually updating images, you just need to run the latest image, make changes, then bundle and copy the image and finally register the new image. You don't need to do anything above this point in that case. Of course, you can always check :)
On the running EMI, note the aki-xxxxxxxx value for the image you started:
$ . ~/.nova/novarc # just to be sure it has been done
$ euca-describe-images
...
IMAGE ami-0000004a TsuDAT/Ubuntu_10.04_Tsudat_2.0.43.manifest.xml available public x86_64 machine aki-00000019
...
On the running EMI, define the image values and the image filename:
$ export AKI_ID=aki-00000019 # from euca-describe-images
$ export BUCKET=TsuDAT
$ export PREFIX=Ubuntu_10.04_Tsudat_2.0.1
Then, on the running EMI do:
$ sudo rm -f /mnt/Ubuntu* # remove any previous bundling files
$ sudo cp /etc/fstab /mnt
$ sudo euca-bundle-vol -p $PREFIX -u $EC2_USER_ID -c $EC2_CERT -k $EC2_PRIVATE_KEY --ec2cert $EUCALYPTUS_CERT \
-d /mnt -s 2048 -e /mnt,/root,/var/lib/dhclient --kernel $AKI_ID --fstab /mnt/fstab
(The ''-s 2048'' gives an approximate 2GiB image. -e is directories to exclude. You may need to exclude /data as well)
Then on the running EMI, copy the new image to image storage:
$ euca-upload-bundle -b $BUCKET -m /mnt/$PREFIX.manifest.xml
NOTE: If you create images after testing on a running instance, make sure you delete all generated stuff, otherwise your image will be bloated. Look in your home directory, /mnt and /tmp. There should be about 37 bundle files (00 to 36, ie, about 370MB in the image). Appreciably more bundle files than 37 probably means you have to clean up the image before bundling.
On the running EMI (or another machine, but PREFIX and BUCKET are already defined on the running EMI):
$ euca-register $BUCKET/$PREFIX.manifest.xml
IMAGE ami-00000028
The image id ami-00000028 can be used to run the new image.
First, deregister the image:
$ euca-deregister ami-00000028
Then remove the files stored in the bucket. Using the BUCKET and PREFIX environment variables we defined above:
$ euca-delete-bundle -a $EC2_ACCESS_KEY -s $EC2_SECRET_KEY --url $S3_URL -b $BUCKET -p $PREFIX
For example, if we have:
$ euca-describe-images
...
IMAGE ami-00000028 TsuDAT/Ubuntu_10.04_Tsudat_2.0.10.manifest.xml available public x86_64 machine aki-00000019
...
then to delete that image we would do:
$ euca-deregister ami-00000028
$ euca-delete-bundle -a $EC2_ACCESS_KEY -s $EC2_SECRET_KEY --url $S3_URL -b TsuDAT -p Ubuntu_10.04_Tsudat_2.0.10