From f70cb70acb8050c49dd4cf5f3e4f7c70ba2d978d Mon Sep 17 00:00:00 2001 From: Bharat Kunwar Date: Mon, 20 Apr 2020 09:53:25 +0000 Subject: [PATCH] Support upload of qcow2.xz image format Some images come in *.xz format [1] and this needs to be uncompressed before being uploaded. [1] https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/31.20200323.3.2/x86_64/fedora-coreos-31.20200323.3.2-openstack.x86_64.qcow2.xz Change-Id: I11f8484ba939c4b2c0a98aa08ef7db730baf71e8 --- functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/functions b/functions index 8ea634e753..0d27515c20 100644 --- a/functions +++ b/functions @@ -341,6 +341,12 @@ function upload_image { disk_format=qcow2 container_format=bare ;; + *.qcow2.xz) + image_name=$(basename "$image" ".qcow2.xz") + disk_format=qcow2 + container_format=bare + unpack=unxz + ;; *.raw) image_name=$(basename "$image" ".raw") disk_format=raw @@ -376,6 +382,16 @@ function upload_image { 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}") + elif [ "$unpack" = "unxz" ]; then + # NOTE(brtknr): unxz the file first and cleanup afterwards to + # prevent timeout while Glance tries to upload image (e.g. to Swift). + local tmp_dir + local image_path + tmp_dir=$(mktemp -d) + image_path="$tmp_dir/$image_name" + unxz -cv "${image}" > "$image_path" + 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 --file "$image_path" + rm -rf $tmp_dir 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