From 3feceb0e4a2e9527be0d5e51ff317851417654d4 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Sun, 17 Apr 2016 11:11:58 -0400 Subject: [PATCH] Support decompressing bz2 image CoreOS cloud image is compressed with bz2 extension [1]. In such case, we need to decompress the image before uploading it to glance. [1] https://coreos.com/os/docs/latest/booting-on-openstack.html Change-Id: I705d0813d180aefaa2507c00d1ae40af07d12fcf --- functions | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/functions b/functions index 0942f17009..ea737deee8 100644 --- a/functions +++ b/functions @@ -295,6 +295,12 @@ function upload_image { container_format=bare unpack=zcat ;; + *.img.bz2) + image_name=$(basename "$image" ".img.bz2") + disk_format=qcow2 + container_format=bare + unpack=bunzip2 + ;; *.qcow2) image_name=$(basename "$image" ".qcow2") disk_format=qcow2 @@ -328,6 +334,8 @@ function upload_image { if [ "$container_format" = "bare" ]; then if [ "$unpack" = "zcat" ]; then openstack --os-cloud=devstack-admin --os-region-name="$REGION_NAME" image create "$image_name" $img_property --public --container-format=$container_format --disk-format $disk_format < <(zcat --force "${image}") + elif [ "$unpack" = "bunzip2" ]; then + openstack --os-cloud=devstack-admin --os-region-name="$REGION_NAME" image create "$image_name" $img_property --public --container-format=$container_format --disk-format $disk_format < <(bunzip2 -cdk "${image}") else openstack --os-cloud=devstack-admin --os-region-name="$REGION_NAME" image create "$image_name" $img_property --public --container-format=$container_format --disk-format $disk_format < "${image}" fi