Inconsistent deserialization of integers

Bug #818321 reported by dan wendlandt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
dan wendlandt
quantum (Ubuntu)
Fix Released
Undecided
Unassigned
Nominated for Precise by Yolanda Robla

Bug Description

The PortCount attribute of a network is returned as an integer in /quantum/api/views/networks.py

The json deserializer properly converts this into a python integer, but the XML deserialization returns it as a string.

The unit test checks for an integer and fails.

I confirmed that if I change networks.py and the unit test to use a string, the test passes for both JSON and XML.

Seems like two fixes are possible:

1) change the XML deserialization to be able to recognize when something is an integer and parse it into a python int.
2) say that the API does not support passing integer values and change the PortCount field to be a string (PortCount does not appear anywhere on the API spec page, http://wiki.openstack.org/QuantumAPISpec, that I can see, but I'm assuming it was intended to be an int.)

Related branches

dan wendlandt (danwent)
Changed in quantum:
importance: Critical → High
Revision history for this message
dan wendlandt (danwent) wrote :

FYI, below are the tests that are failing

======================================================================
FAIL: test_rename_network_xml (tests.unit.test_api.APITest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/danwent/quantum2/tests/unit/test_api.py", line 694, in test_rename_network_xml
    self._test_rename_network('xml')
  File "/home/danwent/quantum2/tests/unit/test_api.py", line 152, in _test_rename_network
    network_data['network'])
AssertionError: {'PortCount': 0, 'id': u'0d63c0ba-9c66-491a-b97d-3c4d2a762177', 'name': 'new_net [truncated]... != {u'PortCount': u'0', u'id': u'0d63c0ba-9c66-491a-b97d-3c4d2a762177', u'name': u' [truncated]...
- {'PortCount': 0,
+ {u'PortCount': u'0',
? + ++ +

- 'id': u'0d63c0ba-9c66-491a-b97d-3c4d2a762177',
+ u'id': u'0d63c0ba-9c66-491a-b97d-3c4d2a762177',
? +

- 'name': 'new_network_name'}
+ u'name': u'new_network_name'}
? + +

======================================================================
FAIL: test_show_network_xml (tests.unit.test_api.APITest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/danwent/quantum2/tests/unit/test_api.py", line 682, in test_show_network_xml
    self._test_show_network('xml')
  File "/home/danwent/quantum2/tests/unit/test_api.py", line 119, in _test_show_network
    network_data['network'])
AssertionError: {'PortCount': 0, 'id': u'86fbc2af-de74-4dc3-9428-38551af79e08', 'name': 'test_ne [truncated]... != {u'PortCount': u'0', u'id': u'86fbc2af-de74-4dc3-9428-38551af79e08', u'name': u' [truncated]...
- {'PortCount': 0,
+ {u'PortCount': u'0',
? + ++ +

- 'id': u'86fbc2af-de74-4dc3-9428-38551af79e08',
+ u'id': u'86fbc2af-de74-4dc3-9428-38551af79e08',
? +

- 'name': 'test_network'}
+ u'name': u'test_network'}
? + +

summary: - Inconsistent deserialization on integers
+ Inconsistent deserialization of integers
Revision history for this message
dan wendlandt (danwent) wrote :

Based on Salvatore's comments on the email thread, I'm going to just remove PortCount for now as it is not in the spec and the only source of this bug right now.

Changed in quantum:
status: New → In Progress
assignee: Salvatore Orlando (salvatore-orlando) → dan wendlandt (danwent)
Revision history for this message
dan wendlandt (danwent) wrote :

Created bug #818960 to track doing API work to fix the underlying problem.

Changed in quantum:
status: In Progress → Fix Committed
dan wendlandt (danwent)
Changed in quantum:
status: Fix Committed → Fix Released
Changed in quantum (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.