commit be94e64b912bfdb70c578918815a28ed8611662a
Author: Mark Goddard <email address hidden>
Date: Mon Feb 19 13:29:45 2018 +0000
Support nested objects and object lists in as_dict
The value returned by ironic.objects.IronicObject.as_dict() should be a
plain object, in order for it to be serialised to JSON. Currently,
nested object fields and object list fields are not converted to dict
format. This caused problems during cleaning, when the node object's
as_dict representation is JSON encoded and sent to IPA.
This change adds support for calling as_dict() on nested objects and
list objects, to ensure these are also returned in dict form.
We also change the method used in as_dict() for checking whether an
object has an attribute. The hasattr() function used previously has
problems when used with properties in python 2 [1], in that any
exceptions raised in the property getter result in hasattr() returning
False. Instead we use obj_attr_is_set() to determine whether the object
has a particular attribute.
Reviewed: https:/ /review. openstack. org/546830 /git.openstack. org/cgit/ openstack/ ironic/ commit/ ?id=be94e64b912 bfdb70c57891881 5a28ed8611662a
Committed: https:/
Submitter: Zuul
Branch: stable/queens
commit be94e64b912bfdb 70c578918815a28 ed8611662a
Author: Mark Goddard <email address hidden>
Date: Mon Feb 19 13:29:45 2018 +0000
Support nested objects and object lists in as_dict
The value returned by ironic. objects. IronicObject. as_dict( ) should be a
plain object, in order for it to be serialised to JSON. Currently,
nested object fields and object list fields are not converted to dict
format. This caused problems during cleaning, when the node object's
as_dict representation is JSON encoded and sent to IPA.
This change adds support for calling as_dict() on nested objects and
list objects, to ensure these are also returned in dict form.
We also change the method used in as_dict() for checking whether an
object has an attribute. The hasattr() function used previously has
problems when used with properties in python 2 [1], in that any
exceptions raised in the property getter result in hasattr() returning
False. Instead we use obj_attr_is_set() to determine whether the object
has a particular attribute.
[1] https:/ /hynek. me/articles/ hasattr/
Change-Id: Ib2166040508827 db28d6f6e2d9a3e 655c16f2993 4462a896c3bff5a 9f483a9a83)
Closes-Bug: #1750027
(cherry picked from commit c66679f14b0b5f3