Skip to content

Commit 314da5a

Browse files
author
Dean Troyer
committed
Handle additional directory structures in image upload
There appear to be multiple forms if AMI archive directory structures in common use. Add the one used by the tty-linux so we can get rid of the special case for it to support UPLOAD_LEGACY_TTY (new): image-name/aki-tty/image image-name/ami-tty/image image-name/ari-tty/image and (existing): image-name/*.img image-name/*.initrd image-name/*.vmlinuz Change-Id: Ia7d88d53760f571c6a488c3139049502b484d33e
1 parent 20121bd commit 314da5a

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

stack.sh

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,17 +1637,8 @@ if is_service_enabled g-reg; then
16371637
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'];"`
16381638

16391639
# 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"
16511642
fi
16521643

16531644
for image_url in ${IMAGE_URLS//,/ }; do
@@ -1669,14 +1660,15 @@ if is_service_enabled g-reg; then
16691660
rm -Rf "$xdir";
16701661
mkdir "$xdir"
16711662
tar -zxf $FILES/$IMAGE_FNAME -C "$xdir"
1672-
KERNEL=$(for f in "$xdir/"*-vmlinuz*; do
1663+
KERNEL=$(for f in "$xdir/"*-vmlinuz* "$xdir/"aki-*/image; do
16731664
[ -f "$f" ] && echo "$f" && break; done; true)
1674-
RAMDISK=$(for f in "$xdir/"*-initrd*; do
1665+
RAMDISK=$(for f in "$xdir/"*-initrd* "$xdir/"ari-*/image; do
16751666
[ -f "$f" ] && echo "$f" && break; done; true)
1676-
IMAGE=$(for f in "$xdir/"*.img; do
1667+
IMAGE=$(for f in "$xdir/"*.img "$xdir/"ami-*/image; do
16771668
[ -f "$f" ] && echo "$f" && break; done; true)
1678-
[ -n "$IMAGE_NAME" ]
1679-
IMAGE_NAME=$(basename "$IMAGE" ".img")
1669+
if [[ -z "$IMAGE_NAME" ]]; then
1670+
IMAGE_NAME=$(basename "$IMAGE" ".img")
1671+
fi
16801672
;;
16811673
*.img)
16821674
IMAGE="$FILES/$IMAGE_FNAME";

0 commit comments

Comments
 (0)