From f2b5f8856f98f72fbdaac536387c2c3672dd5e64 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 13 Oct 2011 16:44:42 -0700 Subject: [PATCH 1/5] starting work to extract image configuration so it isn't hard coded --- stack.sh | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/stack.sh b/stack.sh index 0b34790..3330342 100755 --- a/stack.sh +++ b/stack.sh @@ -637,36 +637,19 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then # Downloads the image (ami/aki/ari style), then extracts it. Upon extraction # we upload to glance with the glance cli tool. TTY is a stripped down # version of ubuntu. - if [ ! -f $FILES/tty.tgz ]; then - wget -c http://images.ansolabs.com/tty.tgz -O $FILES/tty.tgz + IMAGE_URL=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz + IMAGE_FNAME=`echo "$IMAGE_URL" | python -c "import sys; print sys.stdin.read().split('/')[-1]"` + IMAGE_NAME=`echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]"` + if [ ! -f $FILES/$IMAGE_FNAME ]; then + wget -c $IMAGE_URL -O $FILES/$IMAGE_FNAME fi # extract ami-tty/image, aki-tty/image & ari-tty/image - tar -zxf $FILES/tty.tgz -C $FILES/images + tar -zxf $FILES/$IMAGE_FNAME -C $FILES/images - # Use glance client to add the kernel, ramdisk and finally the root - # filesystem. We parse the results of the uploads to get glance IDs of the - # ramdisk and kernel and use them for the root filesystem. - RVAL=`glance add -A $SERVICE_TOKEN name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image` + RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/$IMAGE_NAME-vmlinuz*` KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` - RVAL=`glance add -A $SERVICE_TOKEN name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image` - RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` - glance add -A $SERVICE_TOKEN name="tty" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID ramdisk_id=$RAMDISK_ID < $FILES/images/ami-tty/image - - # Ubuntu 11.04 aka Natty - # ---------------------- - - # Downloaded from ubuntu enterprise cloud images. This - # image doesn't use the ramdisk functionality - if [ ! -f $FILES/natty.tgz ]; then - wget -c http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz -O $FILES/natty.tgz - fi - - tar -zxf $FILES/natty.tgz -C $FILES/images - - RVAL=`glance add -A $SERVICE_TOKEN name="uec-natty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/natty-server-cloudimg-amd64-vmlinuz-virtual` - KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` - glance add -A $SERVICE_TOKEN name="uec-natty" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID < $FILES/images/natty-server-cloudimg-amd64.img + glance add -A $SERVICE_TOKEN name="$IMAGE_NAME" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID < $FILES/images/$IMAGE_NAME.img fi From 0ab1d46e05c310a9977aebd3156b5269dffb91fc Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 13 Oct 2011 23:03:23 -0700 Subject: [PATCH 2/5] Allow user to download and install arbitrary images --- stack.sh | 29 +++++++++++++---------------- stackrc | 3 +++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/stack.sh b/stack.sh index 870811b..29f1377 100755 --- a/stack.sh +++ b/stack.sh @@ -660,38 +660,35 @@ screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f / # Install Images # ============== -# Upload a couple images to glance. **TTY** is a simple small image that use the -# lets you login to it with username/password of user/password. TTY is useful -# for basic functionality. We all include an Ubuntu cloud build of **Natty**. -# Natty uses cloud-init, supporting login via keypair and sending scripts as -# userdata. +# Upload an image to glance. # -# Read more about cloud-init at https://help.ubuntu.com/community/CloudInit +# The default image is a small ***TTY*** testing image, which lets you login +# the username/password of root/password. +# +# TTY also uses cloud-init, supporting login via keypair and sending scripts as +# userdata. See https://help.ubuntu.com/community/CloudInit for more on cloud-init +# +# Override IMAGE_URL if you would to launch a different image. Some other options: +# natty: http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then - # create a directory for the downloadedthe images tarballs. + # Create a directory for the downloadedthe images tarballs. mkdir -p $FILES/images - # Debug Image (TTY) - # ----------------- - - # Downloads the image (ami/aki/ari style), then extracts it. Upon extraction - # we upload to glance with the glance cli tool. TTY is a stripped down - # version of ubuntu. - IMAGE_URL=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz + # Downloads the image (uec ami+aki style), then extracts it. IMAGE_FNAME=`echo "$IMAGE_URL" | python -c "import sys; print sys.stdin.read().split('/')[-1]"` IMAGE_NAME=`echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]"` if [ ! -f $FILES/$IMAGE_FNAME ]; then wget -c $IMAGE_URL -O $FILES/$IMAGE_FNAME fi - # extract ami-tty/image, aki-tty/image & ari-tty/image + # Extract ami and aki files tar -zxf $FILES/$IMAGE_FNAME -C $FILES/images + # Upload to glance with the glance cli tool. RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/$IMAGE_NAME-vmlinuz*` KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` glance add -A $SERVICE_TOKEN name="$IMAGE_NAME" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID < $FILES/images/$IMAGE_NAME.img - fi # Fin diff --git a/stackrc b/stackrc index 15d73ce..9a94721 100644 --- a/stackrc +++ b/stackrc @@ -27,6 +27,9 @@ NOVACLIENT_BRANCH=master OPENSTACKX_REPO=https://github.com/cloudbuilders/openstackx.git OPENSTACKX_BRANCH=diablo +# Specify a uec image to download and install into glance. +IMAGE_URL=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz + # allow local overrides of env variables if [ -f ./localrc ]; then source ./localrc From 93947e59be5566391a3fa0a0b32906ce8c4ceffa Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 13 Oct 2011 23:07:56 -0700 Subject: [PATCH 3/5] improve docs --- stack.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 29f1377..ea4db93 100755 --- a/stack.sh +++ b/stack.sh @@ -685,7 +685,9 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then # Extract ami and aki files tar -zxf $FILES/$IMAGE_FNAME -C $FILES/images - # Upload to glance with the glance cli tool. + # Use glance client to add the kernel the root filesystem. + # We parse the results of the first upload to get the glance ID of the + # kernel for use when uploading the root filesystem. RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/$IMAGE_NAME-vmlinuz*` KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` glance add -A $SERVICE_TOKEN name="$IMAGE_NAME" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID < $FILES/images/$IMAGE_NAME.img From 120f4860cda1a946ebdba1acc03fc09caf2790de Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 14 Oct 2011 09:31:09 -0700 Subject: [PATCH 4/5] allow multiple images --- stack.sh | 34 +++++++++++++++++++--------------- stackrc | 4 ++-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/stack.sh b/stack.sh index ea4db93..b580a4a 100755 --- a/stack.sh +++ b/stack.sh @@ -668,29 +668,33 @@ screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f / # TTY also uses cloud-init, supporting login via keypair and sending scripts as # userdata. See https://help.ubuntu.com/community/CloudInit for more on cloud-init # -# Override IMAGE_URL if you would to launch a different image. Some other options: +# Override IMAGE_URLS if you would to launch a different image(s). +# Specify IMAGE_URLS as a comma-separated list of uec urls. Some other options include: # natty: http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz +# oneiric: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then # Create a directory for the downloadedthe images tarballs. mkdir -p $FILES/images - # Downloads the image (uec ami+aki style), then extracts it. - IMAGE_FNAME=`echo "$IMAGE_URL" | python -c "import sys; print sys.stdin.read().split('/')[-1]"` - IMAGE_NAME=`echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]"` - if [ ! -f $FILES/$IMAGE_FNAME ]; then - wget -c $IMAGE_URL -O $FILES/$IMAGE_FNAME - fi + for image_url in ${IMAGE_URLS//,/ }; do + # Downloads the image (uec ami+aki style), then extracts it. + IMAGE_FNAME=`echo "$image_url" | python -c "import sys; print sys.stdin.read().split('/')[-1]"` + IMAGE_NAME=`echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]"` + if [ ! -f $FILES/$IMAGE_FNAME ]; then + wget -c $image_url -O $FILES/$IMAGE_FNAME + fi - # Extract ami and aki files - tar -zxf $FILES/$IMAGE_FNAME -C $FILES/images + # Extract ami and aki files + tar -zxf $FILES/$IMAGE_FNAME -C $FILES/images - # Use glance client to add the kernel the root filesystem. - # We parse the results of the first upload to get the glance ID of the - # kernel for use when uploading the root filesystem. - RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/$IMAGE_NAME-vmlinuz*` - KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` - glance add -A $SERVICE_TOKEN name="$IMAGE_NAME" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID < $FILES/images/$IMAGE_NAME.img + # Use glance client to add the kernel the root filesystem. + # We parse the results of the first upload to get the glance ID of the + # kernel for use when uploading the root filesystem. + RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/$IMAGE_NAME-vmlinuz*` + KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` + glance add -A $SERVICE_TOKEN name="$IMAGE_NAME" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID < $FILES/images/$IMAGE_NAME.img + done fi # Fin diff --git a/stackrc b/stackrc index 9a94721..e1b65c3 100644 --- a/stackrc +++ b/stackrc @@ -27,8 +27,8 @@ NOVACLIENT_BRANCH=master OPENSTACKX_REPO=https://github.com/cloudbuilders/openstackx.git OPENSTACKX_BRANCH=diablo -# Specify a uec image to download and install into glance. -IMAGE_URL=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz +# Specify a comma-separated list of uec images to download and install into glance. +IMAGE_URLS=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz # allow local overrides of env variables if [ -f ./localrc ]; then From 7a8989e9711ec0d3f3401f46a20bdc55c75fd8e9 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 14 Oct 2011 10:20:30 -0700 Subject: [PATCH 5/5] fix doc --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index b580a4a..a7eacbf 100755 --- a/stack.sh +++ b/stack.sh @@ -674,7 +674,7 @@ screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f / # oneiric: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then - # Create a directory for the downloadedthe images tarballs. + # Create a directory for the downloaded image tarballs. mkdir -p $FILES/images for image_url in ${IMAGE_URLS//,/ }; do