Merge "Fix for glance image-create of *.qcow2 and *.img files"

This commit is contained in:
Jenkins 2012-08-17 14:58:14 +00:00 committed by Gerrit Code Review
commit f2e3bb4ba7

View File

@ -2174,6 +2174,8 @@ if is_service_enabled g-reg; then
RAMDISK="" RAMDISK=""
DISK_FORMAT="" DISK_FORMAT=""
CONTAINER_FORMAT="" CONTAINER_FORMAT=""
UNPACK=""
case "$IMAGE_FNAME" in case "$IMAGE_FNAME" in
*.tar.gz|*.tgz) *.tar.gz|*.tgz)
# Extract ami and aki files # Extract ami and aki files
@ -2205,6 +2207,7 @@ if is_service_enabled g-reg; then
IMAGE_NAME=$(basename "$IMAGE" ".img.gz") IMAGE_NAME=$(basename "$IMAGE" ".img.gz")
DISK_FORMAT=raw DISK_FORMAT=raw
CONTAINER_FORMAT=bare CONTAINER_FORMAT=bare
UNPACK=zcat
;; ;;
*.qcow2) *.qcow2)
IMAGE="$FILES/${IMAGE_FNAME}" IMAGE="$FILES/${IMAGE_FNAME}"
@ -2216,7 +2219,11 @@ if is_service_enabled g-reg; then
esac esac
if [ "$CONTAINER_FORMAT" = "bare" ]; then if [ "$CONTAINER_FORMAT" = "bare" ]; then
glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < <(zcat --force "${IMAGE}") if [ "$UNPACK" = "zcat" ]; then
glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < <(zcat --force "${IMAGE}")
else
glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < ${IMAGE}
fi
else else
# Use glance client to add the kernel the root filesystem. # Use glance client to add the kernel the root filesystem.
# We parse the results of the first upload to get the glance ID of the # We parse the results of the first upload to get the glance ID of the