Browse code

allow multiple images

Anthony Young authored on 2011/10/15 01:31:09
Showing 2 changed files
... ...
@@ -668,29 +668,33 @@ screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f /
668 668
 # TTY also uses cloud-init, supporting login via keypair and sending scripts as
669 669
 # userdata.  See https://help.ubuntu.com/community/CloudInit for more on cloud-init
670 670
 #
671
-# Override IMAGE_URL if you would to launch a different image.  Some other options:
671
+# Override IMAGE_URLS if you would to launch a different image(s).  
672
+# Specify IMAGE_URLS as a comma-separated list of uec urls.  Some other options include:
672 673
 #   natty: http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz
674
+#   oneiric: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz
673 675
 
674 676
 if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
675 677
     # Create a directory for the downloadedthe images tarballs.
676 678
     mkdir -p $FILES/images
677 679
 
678
-    # Downloads the image (uec ami+aki style), then extracts it.
679
-    IMAGE_FNAME=`echo "$IMAGE_URL" | python -c "import sys; print sys.stdin.read().split('/')[-1]"`
680
-    IMAGE_NAME=`echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]"`
681
-    if [ ! -f $FILES/$IMAGE_FNAME ]; then
682
-        wget -c $IMAGE_URL -O $FILES/$IMAGE_FNAME
683
-    fi
680
+    for image_url in ${IMAGE_URLS//,/ }; do
681
+        # Downloads the image (uec ami+aki style), then extracts it.
682
+        IMAGE_FNAME=`echo "$image_url" | python -c "import sys; print sys.stdin.read().split('/')[-1]"`
683
+        IMAGE_NAME=`echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]"`
684
+        if [ ! -f $FILES/$IMAGE_FNAME ]; then
685
+            wget -c $image_url -O $FILES/$IMAGE_FNAME
686
+        fi
684 687
 
685
-    # Extract ami and aki files
686
-    tar -zxf $FILES/$IMAGE_FNAME -C $FILES/images
688
+        # Extract ami and aki files
689
+        tar -zxf $FILES/$IMAGE_FNAME -C $FILES/images
687 690
 
688
-    # Use glance client to add the kernel the root filesystem.
689
-    # We parse the results of the first upload to get the glance ID of the
690
-    # kernel for use when uploading the root filesystem.
691
-    RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/$IMAGE_NAME-vmlinuz*`
692
-    KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
693
-    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
691
+        # Use glance client to add the kernel the root filesystem.
692
+        # We parse the results of the first upload to get the glance ID of the
693
+        # kernel for use when uploading the root filesystem.
694
+        RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/$IMAGE_NAME-vmlinuz*`
695
+        KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
696
+        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
697
+    done
694 698
 fi
695 699
 
696 700
 # Fin
... ...
@@ -27,8 +27,8 @@ NOVACLIENT_BRANCH=master
27 27
 OPENSTACKX_REPO=https://github.com/cloudbuilders/openstackx.git
28 28
 OPENSTACKX_BRANCH=diablo
29 29
 
30
-# Specify a uec image to download and install into glance.
31
-IMAGE_URL=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz
30
+# Specify a comma-separated list of uec images to download and install into glance.
31
+IMAGE_URLS=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz
32 32
 
33 33
 # allow local overrides of env variables
34 34
 if [ -f ./localrc ]; then