ironic/ironic/api
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
..
controllers Support nested objects and object lists in as_dict 2018-02-22 09:41:51 +00:00
middleware Stop guessing mime types based on URLs 2018-02-07 20:58:35 +00:00
__init__.py Centralize config options - [api] 2016-07-21 11:51:45 -07:00
app.py Stop guessing mime types based on URLs 2018-02-07 20:58:35 +00:00
app.wsgi Add uWSGI support 2017-12-28 18:08:49 +02:00
config.py Remove agent vendor passthru completely 2016-12-13 09:31:08 +02:00
expose.py Disable XML now that we have WSME/Pecan support 2015-04-06 09:31:09 -07:00
hooks.py Remove translation of log messages from ironic/api 2017-04-05 09:53:58 -07:00
wsgi.py Add uWSGI support 2017-12-28 18:08:49 +02:00