Reviewed: https://review.openstack.org/392931 Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=d400c04095e1e09468b3bd009ae7004b400fddea Submitter: Jenkins Branch: master
commit d400c04095e1e09468b3bd009ae7004b400fddea Author: Kevin Benton <ke...@benton.pub> Date: Wed Nov 2 11:38:15 2016 -0700 Add 'to_primitive' for MACAddress and IPNetwork Both of these OVO common types did not have a to_primitive method, so their native netaddr objects were being passed to the json serializer. For the MACAdddress object, this resulted in an traceback because EUI types are not json encodable. For the IPNetwork, this resulted in a list of every IP address in the network. This fixes both by adding a 'to_primitive' method that calls str on the netaddr objects, which results in sane representations (string mac address and string CIDR). This adds a base test the common types test case to ensure all primitive representations are json serializable. Closes-Bug: #1638664 Change-Id: Ic0032e3fc12de643e6900702249e69d3946faa19 ** Changed in: neutron Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to neutron. https://bugs.launchpad.net/bugs/1638664 Title: OVO MACAddress field isn't serializable Status in neutron: Fix Released Bug description: The OVO MACAddress field can't be serialized to JSON because it is represented as a EUI object from netaddr without a to_primitive method. This is what happens if you try to json encode an EUI object. >>> json.dumps({'mac-address': netaddr.EUI('AA-BB-CC-DD-EE-FF')}) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/json/__init__.py", line 244, in dumps return _default_encoder.encode(obj) File "/usr/lib/python2.7/json/encoder.py", line 207, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode return _iterencode(o, 0) File "/usr/lib/python2.7/json/encoder.py", line 184, in default raise TypeError(repr(o) + " is not JSON serializable") TypeError: EUI('AA-BB-CC-DD-EE-FF') is not JSON serializable To manage notifications about this bug go to: https://bugs.launchpad.net/neutron/+bug/1638664/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : yahoo-eng-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp