Browse code

Merge "Handle additional directory structures in image upload"

Jenkins authored on 2012/03/30 08:15:19
Showing 1 changed files
... ...
@@ -1637,17 +1637,8 @@ if is_service_enabled g-reg; then
1637 1637
     TOKEN=`curl -s -d  "{\"auth\":{\"passwordCredentials\": {\"username\": \"$ADMIN_USER\", \"password\": \"$ADMIN_PASSWORD\"}, \"tenantName\": \"$ADMIN_TENANT\"}}" -H "Content-type: application/json" http://$HOST_IP:5000/v2.0/tokens | python -c "import sys; import json; tok = json.loads(sys.stdin.read()); print tok['access']['token']['id'];"`
1638 1638
 
1639 1639
     # Option to upload legacy ami-tty, which works with xenserver
1640
-    if [ $UPLOAD_LEGACY_TTY ]; then
1641
-        if [ ! -f $FILES/tty.tgz ]; then
1642
-            wget -c http://images.ansolabs.com/tty.tgz -O $FILES/tty.tgz
1643
-        fi
1644
-
1645
-        tar -zxf $FILES/tty.tgz -C $FILES/images
1646
-        RVAL=`glance add --silent-upload -A $TOKEN name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image`
1647
-        KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
1648
-        RVAL=`glance add --silent-upload -A $TOKEN name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image`
1649
-        RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
1650
-        glance add -A $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
1640
+    if [[ -n "$UPLOAD_LEGACY_TTY" ]]; then
1641
+        IMAGE_URLS="${IMAGE_URLS:+${IMAGE_URLS},}http://images.ansolabs.com/tty.tgz"
1651 1642
     fi
1652 1643
 
1653 1644
     for image_url in ${IMAGE_URLS//,/ }; do
... ...
@@ -1671,14 +1662,15 @@ if is_service_enabled g-reg; then
1671 1671
                 rm -Rf "$xdir";
1672 1672
                 mkdir "$xdir"
1673 1673
                 tar -zxf $FILES/$IMAGE_FNAME -C "$xdir"
1674
-                KERNEL=$(for f in "$xdir/"*-vmlinuz*; do
1674
+                KERNEL=$(for f in "$xdir/"*-vmlinuz* "$xdir/"aki-*/image; do
1675 1675
                          [ -f "$f" ] && echo "$f" && break; done; true)
1676
-                RAMDISK=$(for f in "$xdir/"*-initrd*; do
1676
+                RAMDISK=$(for f in "$xdir/"*-initrd* "$xdir/"ari-*/image; do
1677 1677
                          [ -f "$f" ] && echo "$f" && break; done; true)
1678
-                IMAGE=$(for f in "$xdir/"*.img; do
1678
+                IMAGE=$(for f in "$xdir/"*.img "$xdir/"ami-*/image; do
1679 1679
                          [ -f "$f" ] && echo "$f" && break; done; true)
1680
-                [ -n "$IMAGE_NAME" ]
1681
-                IMAGE_NAME=$(basename "$IMAGE" ".img")
1680
+                if [[ -z "$IMAGE_NAME" ]]; then
1681
+                    IMAGE_NAME=$(basename "$IMAGE" ".img")
1682
+                fi
1682 1683
                 ;;
1683 1684
             *.img)
1684 1685
                 IMAGE="$FILES/$IMAGE_FNAME";