diff --git a/nova/tests/unit/virt/test_hardware.py b/nova/tests/unit/virt/test_hardware.py index 980b8703d2bf..23a3ff010d34 100644 --- a/nova/tests/unit/virt/test_hardware.py +++ b/nova/tests/unit/virt/test_hardware.py @@ -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, diff --git a/nova/virt/hardware.py b/nova/virt/hardware.py index 6e5681ea4e02..c8c1ea1d3f12 100644 --- a/nova/virt/hardware.py +++ b/nova/virt/hardware.py @@ -1982,15 +1982,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