This patch adds support for loading a qcow2 image and using the 'bare'
container format for all single file images.
I tested this successfully by setting:
IMAGE_URLS="http://berrange.fedorapeople.org/images/2012-02-29/f16-x86_64-openstack-sda.qcow2"
Change-Id: Ia55ffd4957866a3d7b9fd7ba4c62e38663b35080
| ... | ... |
@@ -1681,27 +1681,41 @@ if is_service_enabled g-reg; then |
| 1681 | 1681 |
*.img) |
| 1682 | 1682 |
IMAGE="$FILES/$IMAGE_FNAME"; |
| 1683 | 1683 |
IMAGE_NAME=$(basename "$IMAGE" ".img") |
| 1684 |
+ DISK_FORMAT=raw |
|
| 1685 |
+ CONTAINER_FORMAT=bare |
|
| 1684 | 1686 |
;; |
| 1685 | 1687 |
*.img.gz) |
| 1686 | 1688 |
IMAGE="$FILES/${IMAGE_FNAME}"
|
| 1687 | 1689 |
IMAGE_NAME=$(basename "$IMAGE" ".img.gz") |
| 1690 |
+ DISK_FORMAT=raw |
|
| 1691 |
+ CONTAINER_FORMAT=bare |
|
| 1692 |
+ ;; |
|
| 1693 |
+ *.qcow2) |
|
| 1694 |
+ IMAGE="$FILES/${IMAGE_FNAME}"
|
|
| 1695 |
+ IMAGE_NAME=$(basename "$IMAGE" ".qcow2") |
|
| 1696 |
+ DISK_FORMAT=qcow2 |
|
| 1697 |
+ CONTAINER_FORMAT=bare |
|
| 1688 | 1698 |
;; |
| 1689 | 1699 |
*) echo "Do not know what to do with $IMAGE_FNAME"; false;; |
| 1690 | 1700 |
esac |
| 1691 | 1701 |
|
| 1692 |
- # Use glance client to add the kernel the root filesystem. |
|
| 1693 |
- # We parse the results of the first upload to get the glance ID of the |
|
| 1694 |
- # kernel for use when uploading the root filesystem. |
|
| 1695 |
- KERNEL_ID=""; RAMDISK_ID=""; |
|
| 1696 |
- if [ -n "$KERNEL" ]; then |
|
| 1697 |
- RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < "$KERNEL"` |
|
| 1698 |
- KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` |
|
| 1699 |
- fi |
|
| 1700 |
- if [ -n "$RAMDISK" ]; then |
|
| 1701 |
- RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-ramdisk" is_public=true container_format=ari disk_format=ari < "$RAMDISK"` |
|
| 1702 |
- RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` |
|
| 1702 |
+ if [ "$CONTAINER_FORMAT" = "bare" ]; then |
|
| 1703 |
+ glance add --silent-upload -A $TOKEN name="$IMAGE_NAME" is_public=true container_format=$CONTAINER_FORMAT disk_format=$DISK_FORMAT < <(zcat --force "${IMAGE}")
|
|
| 1704 |
+ else |
|
| 1705 |
+ # Use glance client to add the kernel the root filesystem. |
|
| 1706 |
+ # We parse the results of the first upload to get the glance ID of the |
|
| 1707 |
+ # kernel for use when uploading the root filesystem. |
|
| 1708 |
+ KERNEL_ID=""; RAMDISK_ID=""; |
|
| 1709 |
+ if [ -n "$KERNEL" ]; then |
|
| 1710 |
+ RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < "$KERNEL"` |
|
| 1711 |
+ KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` |
|
| 1712 |
+ fi |
|
| 1713 |
+ if [ -n "$RAMDISK" ]; then |
|
| 1714 |
+ RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-ramdisk" is_public=true container_format=ari disk_format=ari < "$RAMDISK"` |
|
| 1715 |
+ RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` |
|
| 1716 |
+ fi |
|
| 1717 |
+ glance add -A $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}")
|
|
| 1703 | 1718 |
fi |
| 1704 |
- glance add -A $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}")
|
|
| 1705 | 1719 |
done |
| 1706 | 1720 |
fi |
| 1707 | 1721 |
|