ironic/ironic/objects
Mark Goddard be94e64b91 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: Ib2166040508827db28d6f6e2d9a3e655c16f2993
Closes-Bug: #1750027
(cherry picked from commit c66679f14b)
2018-02-22 09:41:51 +00:00
..
__init__.py Add RPC object for traits 2018-01-23 22:58:59 +00:00
base.py Support nested objects and object lists in as_dict 2018-02-22 09:41:51 +00:00
chassis.py [trivial] Fix argument descriptions 2017-07-10 14:12:56 +00:00
conductor.py conductor saves version in db 2017-08-24 16:40:44 -04:00
fields.py Add RPC object for traits 2018-01-23 22:58:59 +00:00
indirection.py Remove cyclic import between rpcapi and objects.base 2016-09-13 15:55:44 +01:00
node.py Do not pass credentials to the ramdisk on cleaning 2018-02-07 12:22:26 +01:00
notification.py Fix a few docstring warnings 2017-01-31 15:18:23 -08:00
port.py Rolling upgrades support for port.physical_network 2017-07-20 19:13:56 +01:00
portgroup.py Add version column 2017-06-06 15:34:37 -04:00
trait.py Support nested objects and object lists in as_dict 2018-02-22 09:41:51 +00:00
volume_connector.py Add CRUD notification objects for volume connector and volume target 2017-06-28 11:13:00 +09:00
volume_target.py Add CRUD notification objects for volume connector and volume target 2017-06-28 11:13:00 +09:00