Image script cleanups

This commit is contained in:
Dean Troyer 2011-09-16 16:16:34 -05:00
parent 8cceaa20b1
commit 4dd420e333
3 changed files with 100 additions and 86 deletions

2
README
View file

@ -9,7 +9,6 @@ Tool to build (nfs export) openstack dev environments
* check openstack-puppet recipes to see if anything else is missing
* allow rabbit connection to be specified via environment variables with sensible defaults
* Add volume support
* extract image upload to a seperate script that supports generating images via debootstrap (ubuntu-vm-builder?)
* allow changing of git locations (specify different tag/branch or repos)
* change method of invoking stack.sh to ./stack.sh all _or_ ./stack.sh nova-compute,nova-network,nova-api,nova-volume
* Add quantum support
@ -19,6 +18,7 @@ Tool to build (nfs export) openstack dev environments
* sqlconn can be set via env
* move back to using sudo
* move nova to mysql
* create images via vmbuilder and upload images via glance
# Future

View file

@ -34,21 +34,12 @@ shift `expr $OPTIND - 1`
RELEASE=$1
FORMAT=$2
case $RELEASE in
natty) ;;
maverick) ;;
lucid) ;;
karmic) ;;
jaunty) ;;
*) echo "Unknown release: $RELEASE"
usage
esac
case $FORMAT in
kvm|qcow2) FORMAT=qcow2
TARGET=kvm
;;
vmserver|vmdk) FORMAT=vmdk
vmserver|vmdk)
FORMAT=vmdk
TARGET=vmserver
;;
vbox|vdi) FORMAT=qcow2
@ -57,12 +48,26 @@ case $FORMAT in
;;
vhd|vpc) FORMAT=qcow2
TARGET=kvm
FINAL_FORMAT=vpc
FINAL_FORMAT=vhd
;;
xen) FORMAT=raw
TARGET=xen
;;
*) echo "Unknown format: $FORMAT"
usage
esac
case $RELEASE in
natty) ;;
maverick) ;;
lucid) ;;
karmic) ;;
jaunty) ;;
*) echo "Unknown release: $RELEASE"
usage
;;
esac
# Install stuff if necessary
if [ -z `which vmbuilder` ]; then
sudo apt-get install ubuntu-vm-builder
@ -83,6 +88,10 @@ if [ -z "$FINAL_FORMAT" ]; then
mv ubuntu-$TARGET/tmp*.$FORMAT $RELEASE.$FORMAT
else
# Convert image
qemu-img convert -O $FINAL_FORMAT ubuntu-$TARGET/tmp*.$FORMAT $RELEASE.$FINAL_FORMAT
tgt=$FINAL_FORMAT
if [ "$tgt" = "vhd" ]; then
tgt=vpc
fi
qemu-img convert -O $tgt ubuntu-$TARGET/tmp*.$FORMAT $RELEASE.$FINAL_FORMAT
fi
rm -rf ubuntu-$TARGET

View file

@ -1,24 +1,18 @@
#!/bin/bash
# upload_image.sh - Upload Ubuntu images (create if necessary) in various formats
#
# upload_image.sh release format
#
# format target
# qcow2 kvm,qemu
# vmdk vmw6
# vbox vdi
# vhd vpc
HOST=${HOST:-demo.rcb.me}
PORT=${PORT:-9292}
# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc)
# Requires sudo to root
usage() {
echo "$0 - Upload Ubuntu images"
echo "$0 - Upload images to OpenStack"
echo ""
echo "$0 [-h host] [-p port] release format"
exit 1
}
HOST=${HOST:-localhost}
PORT=${PORT:-9292}
while getopts h:p: c; do
case $c in
h) HOST=$OPTARG
@ -32,44 +26,55 @@ shift `expr $OPTIND - 1`
RELEASE=$1
FORMAT=$2
case $RELEASE in
natty) ;;
maverick) ;;
lucid) ;;
karmic) ;;
jaunty) ;;
*) echo "Unknown release: $RELEASE"
usage
esac
case $FORMAT in
kvm|qcow2) FORMAT=qcow2
TARGET=kvm
;;
vmserver|vmdk) FORMAT=vmdk
vmserver|vmdk)
FORMAT=vmdk
TARGET=vmserver
;;
vbox|vdi) TARGET=kvm
FORMAT=vdi
;;
vhd|vpc) TARGET=kvm
FORMAT=vpc
FORMAT=vhd
;;
*) echo "Unknown format: $FORMAT"
usage
esac
case $RELEASE in
natty) ;;
maverick) ;;
lucid) ;;
karmic) ;;
jaunty) ;;
*) if [ ! -r $RELEASE.$FORMAT ]; then
echo "Unknown release: $RELEASE"
usage
fi
;;
esac
GLANCE=`which glance`
if [ -z "$GLANCE" ]; then
if [ -x "/opt/glance/bin/glance" ]; then
# Look for stack.sh's install
GLANCE="/opt/glance/bin/glance"
else
echo "Glance not found, must install client"
OWD=`pwd`
cd /opt
sudo apt-get install python-pip python-eventlet python-routes python-greenlet python-argparse python-sqlalchemy python-wsgiref python-pastedeploy python-xattr
sudo pip install kombu
git clone https://github.com/cloudbuilders/glance.git
sudo git clone https://github.com/cloudbuilders/glance.git
cd glance
sudo python setup.py develop
cd ..
cd $OWD
GLANCE=`which glance`
fi
fi
# Create image if it doesn't exist
if [ ! -r $RELEASE.$FORMAT ]; then