HostDeserializer doesn't support multiple line xml

Bug #1082132 reported by Mauro S M Rodrigues
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Mauro S M Rodrigues

Bug Description

If you do a request to Hosts extension to put a host into maintenance mode or update its status, as it's in the unit tests, with this string:
("<?xml version='1.0' encoding='UTF-8'?>\n"
'<updates><status>enabled</status><foo>bar</foo></updates>')

it works fine, but if you change the string to:
"""<?xml version='1.0' encoding='UTF-8'?>
     <updates>
         <status>enabled</status>
         <maintenance_mode>disable</maintenance_mode>
     </updates>"""

it doesn't work, if you change the test string to this one it also doesn't work. The trace is:

run_tests.sh nova.tests.api.openstack.compute.contrib.test_hosts:HostSerializerTest

======================================================================
ERROR: nova.tests.api.openstack.compute.contrib.test_hosts.HostSerializerTest.test_update_deserializer
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/opt/stack/nova/nova/tests/api/openstack/compute/contrib/test_hosts.py", line 345, in test_update_deserializer
    result = self.deserializer.deserialize(intext)
  File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 187, in deserialize
    return self.dispatch(datastring, action=action)
  File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 177, in dispatch
    return action_method(*args, **kwargs)
  File "/opt/stack/nova/nova/api/openstack/compute/contrib/hosts.py", line 83, in default
    updates[child.tagName] = self.extract_text(child)
AttributeError: Text instance has no attribute 'tagName'

I'm about to submit a fix to this where a I change the HostDeserializer to HostUpdateDeserializer since it's only used on the update operation (ie maintenance mode and status).

[API V2 AUDIT] Also I think that put the tags updates doesn't make so much sense since the json version doesn't have it, so I'm also marking this with api v2 audit tag: nova-v2-non-best-practice

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

Fix proposed to branch: master
Review: https://review.openstack.org/16774

Changed in nova:
status: New → In Progress
Mark McLoughlin (markmc)
Changed in nova:
importance: Undecided → Low
importance: Low → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/16774
Committed: http://github.com/openstack/nova/commit/f58f2b48a1c5ebb01ef998720e5dbd1d88ed6e5d
Submitter: Jenkins
Branch: master

commit f58f2b48a1c5ebb01ef998720e5dbd1d88ed6e5d
Author: Mauro S. M. Rodrigues <email address hidden>
Date: Thu Nov 22 13:30:25 2012 -0500

    Fix HostDeserializer to enable multiple line xml

    Fixes bug: 1082132

    The current HostDeserializer wasn't able to deal with multiple line xml inputs.
    Since the HostDeserializer is used only on the update operation this patch
    renames it to HostUpdateDeserializer, and parses only the valid options (status
    and maintenance_mode).

    Change-Id: I9ec3b296a07e0fc903da1c005cf7bd5dcb08fd1b

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → grizzly-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-2 → 2013.1
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.