Fix case sensitive comparison

As of now, if flavor has 'hw:virtio_packed_ring' extra-spec set
to True and image has 'hw_virtio_packed_ring' set to 'true', if
fails the comparison and throws exception.

This change makes the comparison case-insensitive by adding
another condition for image_value to change it from str
to bool if its not None.

Closes-Bug: #2085124
Change-Id: Ie1af94b216f10cad592f38037875744927c4f18a
This commit is contained in:
Rajesh Tailor
2024-10-23 18:58:14 +05:30
parent ae87118f98
commit 8c2df0035d
2 changed files with 7 additions and 2 deletions

View File

@ -5836,6 +5836,7 @@ class VIFVirtioEnabledTest(test.NoDBTestCase):
('yes', True, True),
# fail: mismatched image and flavor configuration
('no', True, exception.FlavorImageConflict),
('yes', 'true', True),
)
def test_get_vif_virtio_constraint(
self, flavor_policy, image_policy, expected,

View File

@ -1986,15 +1986,19 @@ def get_packed_virtqueue_constraint(
flavor_key = ':'.join(['hw', key_value])
image_key = '_'.join(['hw', key_value])
flavor_value_str = flavor.get('extra_specs', {}).get(flavor_key, None)
image_value = image_meta.get('properties', {}).get(image_key, None)
image_value_str = image_meta.get('properties', {}).get(image_key, None)
else:
flavor_value_str, image_value = _get_flavor_image_meta(
flavor_value_str, image_value_str = _get_flavor_image_meta(
key_value, flavor, image_meta)
flavor_value = None
if flavor_value_str is not None:
flavor_value = strutils.bool_from_string(flavor_value_str)
image_value = None
if image_value_str is not None:
image_value = strutils.bool_from_string(image_value_str)
if (
image_value is not None and
flavor_value is not None and