|
...
|
...
|
@@ -660,55 +660,41 @@ screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f /
|
|
660
|
660
|
# Install Images
|
|
661
|
661
|
# ==============
|
|
662
|
662
|
|
|
663
|
|
-# Upload a couple images to glance. **TTY** is a simple small image that use the
|
|
664
|
|
-# lets you login to it with username/password of user/password. TTY is useful
|
|
665
|
|
-# for basic functionality. We all include an Ubuntu cloud build of **Natty**.
|
|
666
|
|
-# Natty uses cloud-init, supporting login via keypair and sending scripts as
|
|
667
|
|
-# userdata.
|
|
|
663
|
+# Upload an image to glance.
|
|
668
|
664
|
#
|
|
669
|
|
-# Read more about cloud-init at https://help.ubuntu.com/community/CloudInit
|
|
|
665
|
+# The default image is a small ***TTY*** testing image, which lets you login
|
|
|
666
|
+# the username/password of root/password.
|
|
|
667
|
+#
|
|
|
668
|
+# TTY also uses cloud-init, supporting login via keypair and sending scripts as
|
|
|
669
|
+# userdata. See https://help.ubuntu.com/community/CloudInit for more on cloud-init
|
|
|
670
|
+#
|
|
|
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:
|
|
|
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
|
|
670
|
675
|
|
|
671
|
676
|
if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
|
|
672
|
|
- # create a directory for the downloadedthe images tarballs.
|
|
|
677
|
+ # Create a directory for the downloaded image tarballs.
|
|
673
|
678
|
mkdir -p $FILES/images
|
|
674
|
679
|
|
|
675
|
|
- # Debug Image (TTY)
|
|
676
|
|
- # -----------------
|
|
677
|
|
-
|
|
678
|
|
- # Downloads the image (ami/aki/ari style), then extracts it. Upon extraction
|
|
679
|
|
- # we upload to glance with the glance cli tool. TTY is a stripped down
|
|
680
|
|
- # version of ubuntu.
|
|
681
|
|
- if [ ! -f $FILES/tty.tgz ]; then
|
|
682
|
|
- wget -c http://images.ansolabs.com/tty.tgz -O $FILES/tty.tgz
|
|
683
|
|
- fi
|
|
684
|
|
-
|
|
685
|
|
- # extract ami-tty/image, aki-tty/image & ari-tty/image
|
|
686
|
|
- tar -zxf $FILES/tty.tgz -C $FILES/images
|
|
687
|
|
-
|
|
688
|
|
- # Use glance client to add the kernel, ramdisk and finally the root
|
|
689
|
|
- # filesystem. We parse the results of the uploads to get glance IDs of the
|
|
690
|
|
- # ramdisk and kernel and use them for the root filesystem.
|
|
691
|
|
- RVAL=`glance add -A $SERVICE_TOKEN name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image`
|
|
692
|
|
- KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
|
|
693
|
|
- RVAL=`glance add -A $SERVICE_TOKEN name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image`
|
|
694
|
|
- RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
|
|
695
|
|
- 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
|
|
696
|
|
-
|
|
697
|
|
- # Ubuntu 11.04 aka Natty
|
|
698
|
|
- # ----------------------
|
|
699
|
|
-
|
|
700
|
|
- # Downloaded from ubuntu enterprise cloud images. This
|
|
701
|
|
- # image doesn't use the ramdisk functionality
|
|
702
|
|
- if [ ! -f $FILES/natty.tgz ]; then
|
|
703
|
|
- wget -c http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz -O $FILES/natty.tgz
|
|
704
|
|
- fi
|
|
705
|
|
-
|
|
706
|
|
- tar -zxf $FILES/natty.tgz -C $FILES/images
|
|
|
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
|
|
707
|
687
|
|
|
708
|
|
- 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`
|
|
709
|
|
- KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
|
|
710
|
|
- 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
|
|
|
688
|
+ # Extract ami and aki files
|
|
|
689
|
+ tar -zxf $FILES/$IMAGE_FNAME -C $FILES/images
|
|
711
|
690
|
|
|
|
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
|
|
712
|
698
|
fi
|
|
713
|
699
|
|
|
714
|
700
|
# Fin
|