This adds support for image urls that end in .img.gz or .img.
The assumption is that they're a full disk image or a compressed
disk image.
Some examples:
https://cloud-images.ubuntu.com/server/releases/11.10/release/ubuntu-11.10-server-cloudimg-i386-disk1.img
http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-rootfs.img.gz
http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
Change-Id: I79b67b461fb02f2403dad3e15f630fa9817eb0db
... | ... |
@@ -1215,20 +1215,55 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then |
1215 | 1215 |
for image_url in ${IMAGE_URLS//,/ }; do |
1216 | 1216 |
# Downloads the image (uec ami+aki style), then extracts it. |
1217 | 1217 |
IMAGE_FNAME=`basename "$image_url"` |
1218 |
- IMAGE_NAME=`basename "$IMAGE_FNAME" .tar.gz` |
|
1219 | 1218 |
if [ ! -f $FILES/$IMAGE_FNAME ]; then |
1220 | 1219 |
wget -c $image_url -O $FILES/$IMAGE_FNAME |
1221 | 1220 |
fi |
1222 | 1221 |
|
1223 |
- # Extract ami and aki files |
|
1224 |
- tar -zxf $FILES/$IMAGE_FNAME -C $FILES/images |
|
1222 |
+ KERNEL="" |
|
1223 |
+ RAMDISK="" |
|
1224 |
+ case "$IMAGE_FNAME" in |
|
1225 |
+ *.tar.gz|*.tgz) |
|
1226 |
+ # Extract ami and aki files |
|
1227 |
+ [ "${IMAGE_FNAME%.tar.gz}" != "$IMAGE_FNAME" ] && |
|
1228 |
+ IMAGE_NAME="${IMAGE_FNAME%.tar.gz}" || |
|
1229 |
+ IMAGE_NAME="${IMAGE_FNAME%.tgz}" |
|
1230 |
+ xdir="$FILES/images/$IMAGE_NAME" |
|
1231 |
+ rm -Rf "$xdir"; |
|
1232 |
+ mkdir "$xdir" |
|
1233 |
+ tar -zxf $FILES/$IMAGE_FNAME -C "$xdir" |
|
1234 |
+ KERNEL=$(for f in "$xdir/"*-vmlinuz*; do |
|
1235 |
+ [ -f "$f" ] && echo "$f" && break; done; true) |
|
1236 |
+ RAMDISK=$(for f in "$xdir/"*-initrd*; do |
|
1237 |
+ [ -f "$f" ] && echo "$f" && break; done; true) |
|
1238 |
+ IMAGE=$(for f in "$xdir/"*.img; do |
|
1239 |
+ [ -f "$f" ] && echo "$f" && break; done; true) |
|
1240 |
+ [ -n "$IMAGE_NAME" ] |
|
1241 |
+ IMAGE_NAME=$(basename "$IMAGE" ".img") |
|
1242 |
+ ;; |
|
1243 |
+ *.img) |
|
1244 |
+ IMAGE="$FILES/$IMAGE_FNAME"; |
|
1245 |
+ IMAGE_NAME=$(basename "$IMAGE" ".img") |
|
1246 |
+ ;; |
|
1247 |
+ *.img.gz) |
|
1248 |
+ IMAGE="$FILES/${IMAGE_FNAME}" |
|
1249 |
+ IMAGE_NAME=$(basename "$IMAGE" ".img.gz") |
|
1250 |
+ ;; |
|
1251 |
+ *) echo "Do not know what to do with $IMAGE_FNAME"; false;; |
|
1252 |
+ esac |
|
1225 | 1253 |
|
1226 | 1254 |
# Use glance client to add the kernel the root filesystem. |
1227 | 1255 |
# We parse the results of the first upload to get the glance ID of the |
1228 | 1256 |
# kernel for use when uploading the root filesystem. |
1229 |
- RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/$IMAGE_NAME-vmlinuz*` |
|
1230 |
- KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` |
|
1231 |
- 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 |
|
1257 |
+ KERNEL_ID=""; RAMDISK_ID=""; |
|
1258 |
+ if [ -n "$KERNEL" ]; then |
|
1259 |
+ RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < "$KERNEL"` |
|
1260 |
+ KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` |
|
1261 |
+ fi |
|
1262 |
+ if [ -n "$RAMDISK" ]; then |
|
1263 |
+ RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-ramdisk" is_public=true container_format=ari disk_format=ari < "$RAMDISK"` |
|
1264 |
+ RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` |
|
1265 |
+ fi |
|
1266 |
+ glance add -A $SERVICE_TOKEN name="${IMAGE_NAME%.img}" is_public=true container_format=ami disk_format=ami ${KERNEL_ID:+kernel_id=$KERNEL_ID} ${RAMDISK_ID:+ramdisk_id=$RAMDISK_ID} < <(zcat --force "${IMAGE}") |
|
1232 | 1267 |
done |
1233 | 1268 |
fi |
1234 | 1269 |
|
... | ... |
@@ -44,6 +44,18 @@ CITEST_REPO=https://github.com/openstack/tempest.git |
44 | 44 |
CITEST_BRANCH=master |
45 | 45 |
|
46 | 46 |
# Specify a comma-separated list of uec images to download and install into glance. |
47 |
+# supported urls here are: |
|
48 |
+# * "uec-style" images: |
|
49 |
+# If the file ends in .tar.gz, uncompress the tarball and and select the first |
|
50 |
+# .img file inside it as the image. If present, use "*-vmlinuz*" as the kernel |
|
51 |
+# and "*-initrd*" as the ramdisk |
|
52 |
+# example: http://cloud-images.ubuntu.com/releases/oneiric/release/ubuntu-11.10-server-cloudimg-amd64.tar.gz |
|
53 |
+# * disk image (*.img,*.img.gz) |
|
54 |
+# if file ends in .img, then it will be uploaded and registered as a to |
|
55 |
+# glance as a disk image. If it ends in .gz, it is uncompressed first. |
|
56 |
+# example: |
|
57 |
+# http://cloud-images.ubuntu.com/releases/oneiric/release/ubuntu-11.10-server-cloudimg-armel-disk1.img |
|
58 |
+# http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-rootfs.img.gz |
|
47 | 59 |
IMAGE_URLS=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz |
48 | 60 |
|
49 | 61 |
# allow local overrides of env variables |