-
Bug
-
Resolution: Unresolved
-
Normal
-
None
-
None
-
None
-
False
-
-
False
-
?
-
None
-
-
-
Moderate
This was reported in the Compute DFG channel – the `nova-manage image_property set` command is not working properly with compute traits, for example:
# nova-manage image_property set 07e35fd5-0a83-4216-bcdd-64a1e51da767 --property trait:CUSTOM_WINDOWS_HOST='required'
Invalid image property name trait:CUSTOM_WINDOWS_HOST.
# nova-manage image_property set 07e35fd5-0a83-4216-bcdd-64a1e51da767 --property CUSTOM_WINDOWS_HOST=required
Invalid image property name CUSTOM_WINDOWS_HOST.
The problem was tracked down to some code intended for property name validation [1]:
# Validate the names of each property by checking against the o.vo # fields currently listed by ImageProps. We can't use from_dict to # do this as it silently ignores invalid property keys. for image_property_name in image_properties.keys(): if image_property_name not in objects.ImageMetaProps.fields: raise exception.InvalidImagePropertyName( image_property_name=image_property_name)
This fails for traits because in the ImageMetaProps object traits are stored in a list field [2] and will thus not be found as individual fields that match the names of traits:
# The required traits associated with the image. Traits are expected to # be defined as starting with `trait:` like below: # trait:HW_CPU_X86_AVX2=required # for trait in image_meta.traits_required: # will yield trait strings such as 'HW_CPU_X86_AVX2' 'traits_required': fields.ListOfStringsField(),
The ImageMetaProps object already handles adding traits from a dict representation of image properties to the internal "traits_required" list, so it appears that to fix it, the validation code needs to simply continue/ignore image property names that begin with "trait:".
[1] https://github.com/openstack/nova/blob/6f537e756bdcaa1d86a629940abf3775b3d56c80/nova/cmd/manage.py#L3335-L3341
[2] https://github.com/openstack/nova/blob/6f537e756bdcaa1d86a629940abf3775b3d56c80/nova/objects/image_meta.py#L614