Fix ami/aki image create use of $img_property

This abstracts out the conversion of key=value,... property lists to a function
and makes both _upload_image() and the two ami/aki image create calls use it. The
move to bare key=value properties introduced a regression for ami/aki where
the --property flag stopped being passed to osc in that case.

Change-Id: Idf7fdfe3f5800f79f6c48f9d9606a7b53436a730
This commit is contained in:
Dan Smith
2020-07-15 14:41:38 -07:00
committed by Ghanshyam Mann
parent 12a88cfb76
commit 2614c1bba1

View File

@@ -77,6 +77,19 @@ function get_extra_file {
fi
}
# Generate image property arguments for OSC
#
# Arguments: properties, one per, like propname=value
#
# Result is --property propname1=value1 --property propname2=value2
function _image_properties_to_arg {
local result=""
for property in $*; do
result+=" --property $property"
done
echo $result
}
# Upload an image to glance using the configured mechanism
#
# Arguments:
@@ -98,9 +111,7 @@ function _upload_image {
local properties
local useimport
for prop in $*; do
properties+=" --property $prop"
done
properties=$(_image_properties_to_arg $*)
if [[ "$GLANCE_USE_IMPORT_WORKFLOW" == "True" ]]; then
if [[ "$GLANCE_STANDALONE" == "True" ]]; then
@@ -422,10 +433,10 @@ function upload_image {
# kernel for use when uploading the root filesystem.
local kernel_id="" ramdisk_id="";
if [ -n "$kernel" ]; then
kernel_id=$(openstack --os-cloud=devstack-admin --os-region-name="$REGION_NAME" image create "$image_name-kernel" $img_property --public --container-format aki --disk-format aki < "$kernel" | grep ' id ' | get_field 2)
kernel_id=$(openstack --os-cloud=devstack-admin --os-region-name="$REGION_NAME" image create "$image_name-kernel" $(_image_properties_to_arg $img_property) --public --container-format aki --disk-format aki < "$kernel" | grep ' id ' | get_field 2)
fi
if [ -n "$ramdisk" ]; then
ramdisk_id=$(openstack --os-cloud=devstack-admin --os-region-name="$REGION_NAME" image create "$image_name-ramdisk" $img_property --public --container-format ari --disk-format ari < "$ramdisk" | grep ' id ' | get_field 2)
ramdisk_id=$(openstack --os-cloud=devstack-admin --os-region-name="$REGION_NAME" image create "$image_name-ramdisk" $(_image_properties_to_arg $img_property) --public --container-format ari --disk-format ari < "$ramdisk" | grep ' id ' | get_field 2)
fi
_upload_image "${image_name%.img}" ami ami "$image" ${kernel_id:+ kernel_id=$kernel_id} ${ramdisk_id:+ ramdisk_id=$ramdisk_id} $img_property
fi