Skip to content

Commit 3feceb0

Browse files
author
Hongbin Lu
committed
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
1 parent 251b870 commit 3feceb0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

functions

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ function upload_image {
295295
container_format=bare
296296
unpack=zcat
297297
;;
298+
*.img.bz2)
299+
image_name=$(basename "$image" ".img.bz2")
300+
disk_format=qcow2
301+
container_format=bare
302+
unpack=bunzip2
303+
;;
298304
*.qcow2)
299305
image_name=$(basename "$image" ".qcow2")
300306
disk_format=qcow2
@@ -328,6 +334,8 @@ function upload_image {
328334
if [ "$container_format" = "bare" ]; then
329335
if [ "$unpack" = "zcat" ]; then
330336
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}")
337+
elif [ "$unpack" = "bunzip2" ]; then
338+
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}")
331339
else
332340
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}"
333341
fi

0 commit comments

Comments
 (0)