Comment 2 for bug 1620254

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/365684
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=3756bc510526531e3442da6d825cc90f44faa355
Submitter: Jenkins
Branch: master

commit 3756bc510526531e3442da6d825cc90f44faa355
Author: Kevin Benton <email address hidden>
Date: Mon Sep 5 08:26:01 2016 -0600

    Convert OVO fields to primitives for to_dict()

    to_dict() is used for conversions of OVO objects into
    regular dictionaries to be used as plugin return values
    to the API layer, etc. It provides the equivalent of
    make_<resource>_dict that we use now (without the extension
    processing). The values in these dictionaries should be
    ready for representation in the API.

    The issue was that the OVO to_dict() implementation was
    placing complex types right into the dictionary which
    would mean that the API would serialize them just by
    calling str() on them (as part of json encoding). This
    ignored the 'to_primitive' method defined on the OVO
    type that defines how a field should be converted.
    Therefore, when it came to timestamps to_dict() was
    placing native datetime objects into the dictionary
    which would convert to microsecond resolution, violating
    the expected format of the OVO DateTime type.

    This patch fixes the issue by calling 'to_primitive'
    on each non-synthetic field in the to_dict() method
    to ensure we match the expected format of the type before
    we send it out the API.

    Closes-Bug: #1620254
    Change-Id: Ic0be54b1d4b23119e1458d4532e2f70bff0ff9f6