Public bug reported: Originally reported downstream [1]:
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 [2]: # 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 [3] 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://issues.redhat.com/browse/OSPRH-13327 [2] https://github.com/openstack/nova/blob/6f537e756bdcaa1d86a629940abf3775b3d56c80/nova/cmd/manage.py#L3335-L3341 [3] https://github.com/openstack/nova/blob/6f537e756bdcaa1d86a629940abf3775b3d56c80/nova/objects/image_meta.py#L614 ** Affects: nova Importance: Undecided Status: New ** Tags: nova-manage -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/2096341 Title: 'nova-manage image_property set' does not work with traits Status in OpenStack Compute (nova): New Bug description: Originally reported downstream [1]: 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 [2]: # 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 [3] 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://issues.redhat.com/browse/OSPRH-13327 [2] https://github.com/openstack/nova/blob/6f537e756bdcaa1d86a629940abf3775b3d56c80/nova/cmd/manage.py#L3335-L3341 [3] https://github.com/openstack/nova/blob/6f537e756bdcaa1d86a629940abf3775b3d56c80/nova/objects/image_meta.py#L614 To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/2096341/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : yahoo-eng-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp