From 10caf4b48fa67b160e6024a801efbda292d44ebf Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Mon, 22 Oct 2012 17:53:30 -0400 Subject: Fix Broken XML Namespace Handling nodeName is set to ns2:metadata and not just metadata when namespaces are specified using first example in the defect. Explicitly check namespaces where necessary and use localName instead of nodeName. Ensure that scheduler_hints are picked up from the correct namespace fix lines too long from pep8 Fixes bug 887191 Change-Id: I5db2b575d24f6b1b358489e309af7e6ace2950fd --- nova/tests/api/openstack/compute/test_servers.py | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index 0a35fb36a..afa181ee3 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -3030,6 +3030,57 @@ class TestServerCreateRequestXMLDeserializer(test.TestCase): } self.assertEquals(request['body'], expected) + def test_request_with_alternate_namespace_prefix(self): + serial_request = """ + + world + + """ + request = self.deserializer.deserialize(serial_request) + expected = { + "server": { + "name": "new-server-test", + "imageRef": "1", + "flavorRef": "2", + 'metadata': {"hello": "world"}, + }, + } + self.assertEquals(request['body'], expected) + + def test_request_with_scheduler_hints_and_alternate_namespace_prefix(self): + serial_request = """ + + world + + xen + eb999657-dd6b-464e-8713-95c532ac3b18 + + + """ + request = self.deserializer.deserialize(serial_request) + expected = { + "server": { + 'OS-SCH-HNT:scheduler_hints': { + 'hypervisor': ['xen'], + 'near': ['eb999657-dd6b-464e-8713-95c532ac3b18'] + }, + "name": "new-server-test", + "imageRef": "1", + "flavorRef": "2", + "metadata": { + "hello": "world" + } + } + } + self.assertEquals(request['body'], expected) + def test_access_ipv4(self): serial_request = """