Fix to upload as the appropriate image format

Cinder updates to check the format of images for security issue [1].
The format of cirros image is qcow2 but upload as raw at devstack init
process of Tacker.

This patch fixes to upload images to glance as the appropriate format.

[1] https://bugs.launchpad.net/cinder/+bug/1996188

Closes-Bug: #2008064
Change-Id: Ib7a36af99bc77f3bd1c95411760ff8cbd2456a3e
This commit is contained in:
Ayumu Ueha 2023-02-22 15:40:16 +00:00
parent 844de7fb20
commit 94d2433df7

View File

@ -361,9 +361,9 @@ function tacker_horizon_uninstall {
function openstack_image_create {
image=$1
disk_format=raw
container_format=bare
image_name=$2
disk_format=$3
openstack --os-cloud=devstack-admin image create $image_name --public --container-format=$container_format --disk-format $disk_format --file ${image}
openstack image show $image_name -f value -c id
}
@ -379,6 +379,8 @@ function tacker_check_and_download_images {
local gz_pattern="\.gz$"
local length=${#image_url[@]}
local index=0
install_package jq
while [ $index -lt $length ]
do
image_fname=`basename "${image_url[$index]}"`
@ -407,7 +409,8 @@ function tacker_check_and_download_images {
fi
fi
{
openstack_image_create $FILES/$image_fname $glance_name
disk_format=`qemu-img info --output=json $FILES/$image_fname | jq -r '.format'`
openstack_image_create $FILES/$image_fname $glance_name $disk_format
}||{
echo "ERROR: tacker image create for $image_fname failed"
image_fname=$image_fname"*"