Comment 6 for bug 1750027

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ironic (stable/queens)

Reviewed: https://review.openstack.org/546830
Committed: https://git.openstack.org/cgit/openstack/ironic/commit/?id=be94e64b912bfdb70c578918815a28ed8611662a
Submitter: Zuul
Branch: stable/queens

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.

    [1] https://hynek.me/articles/hasattr/

    Change-Id: Ib2166040508827db28d6f6e2d9a3e655c16f2993
    Closes-Bug: #1750027
    (cherry picked from commit c66679f14b0b5f34462a896c3bff5a9f483a9a83)