Browse code

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

Dan Smith authored on 2020/07/16 06:41:38
Showing 1 changed files
... ...
@@ -77,6 +77,19 @@ function get_extra_file {
77 77
     fi
78 78
 }
79 79
 
80
+# Generate image property arguments for OSC
81
+#
82
+# Arguments: properties, one per, like propname=value
83
+#
84
+# Result is --property propname1=value1 --property propname2=value2
85
+function _image_properties_to_arg {
86
+    local result=""
87
+    for property in $*; do
88
+        result+=" --property $property"
89
+    done
90
+    echo $result
91
+}
92
+
80 93
 # Upload an image to glance using the configured mechanism
81 94
 #
82 95
 # Arguments:
... ...
@@ -98,9 +111,7 @@ function _upload_image {
98 98
     local properties
99 99
     local useimport
100 100
 
101
-    for prop in $*; do
102
-        properties+=" --property $prop"
103
-    done
101
+    properties=$(_image_properties_to_arg $*)
104 102
 
105 103
     if [[ "$GLANCE_USE_IMPORT_WORKFLOW" == "True" ]]; then
106 104
         if [[ "$GLANCE_STANDALONE" == "True" ]]; then
... ...
@@ -422,10 +433,10 @@ function upload_image {
422 422
         # kernel for use when uploading the root filesystem.
423 423
         local kernel_id="" ramdisk_id="";
424 424
         if [ -n "$kernel" ]; then
425
-            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)
425
+            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)
426 426
         fi
427 427
         if [ -n "$ramdisk" ]; then
428
-            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)
428
+            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)
429 429
         fi
430 430
         _upload_image "${image_name%.img}" ami ami "$image" ${kernel_id:+ kernel_id=$kernel_id} ${ramdisk_id:+ ramdisk_id=$ramdisk_id} $img_property
431 431
     fi