From 1759d5825c8207492c8960711130d9eb85e5d631 Mon Sep 17 00:00:00 2001 From: Christopher Yeoh Date: Fri, 8 Mar 2013 14:55:54 +1100 Subject: Fix OS-DCF:diskconfig XML handling Removes string to bool conversion for the OS-DCF:diskconfig attribute during XML deserialising as the diskconfig extension expects a string (MANUAL or AUTO) not a bool. Fixes bug 1152439 Change-Id: Id9a5c2559a2891c2a21c437c9a5a534b9885c9bf --- nova/api/openstack/compute/servers.py | 4 ++-- nova/tests/api/openstack/compute/test_servers.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 3464cfdbd..9055d0ae1 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -215,11 +215,11 @@ class CommonDeserializer(wsgi.MetadataXMLDeserializer): # anyone that might be using it. auto_disk_config = server_node.getAttribute('auto_disk_config') if auto_disk_config: - server['OS-DCF:diskConfig'] = utils.bool_from_str(auto_disk_config) + server['OS-DCF:diskConfig'] = auto_disk_config auto_disk_config = server_node.getAttribute('OS-DCF:diskConfig') if auto_disk_config: - server['OS-DCF:diskConfig'] = utils.bool_from_str(auto_disk_config) + server['OS-DCF:diskConfig'] = auto_disk_config config_drive = server_node.getAttribute('config_drive') if config_drive: diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index 638ef79b0..75daf42f6 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -2190,11 +2190,11 @@ class ServersControllerCreateTest(test.TestCase): # NOTE(vish): the extension converts OS-DCF:disk_config into # auto_disk_config, so we are testing with # the_internal_value - params = {'auto_disk_config': True} + params = {'auto_disk_config': 'AUTO'} old_create = compute_api.API.create def create(*args, **kwargs): - self.assertEqual(kwargs['auto_disk_config'], True) + self.assertEqual(kwargs['auto_disk_config'], 'AUTO') return old_create(*args, **kwargs) self.stubs.Set(compute_api.API, 'create', create) @@ -3745,14 +3745,14 @@ class TestServerCreateRequestXMLDeserializer(test.TestCase): + OS-DCF:diskConfig="AUTO"> """ request = self.deserializer.deserialize(serial_request) expected = {"server": { "name": "new-server-test", "imageRef": "1", "flavorRef": "1", - "OS-DCF:diskConfig": True, + "OS-DCF:diskConfig": "AUTO", }} self.assertEquals(request['body'], expected) -- cgit