diff options
| author | Christopher Yeoh <cyeoh@au1.ibm.com> | 2013-03-10 15:43:19 +1030 |
|---|---|---|
| committer | Christopher Yeoh <cyeoh@au1.ibm.com> | 2013-03-13 00:32:49 +1030 |
| commit | 02c7cd97fa4b8a81f0795be757bd99a29a037795 (patch) | |
| tree | b6fcb6f5145ffc6befa7b232e93302e56e8c5997 | |
| parent | 92482459963e21cb692c0515450abc81d69e40ed (diff) | |
| download | nova-02c7cd97fa4b8a81f0795be757bd99a29a037795.tar.gz nova-02c7cd97fa4b8a81f0795be757bd99a29a037795.tar.xz nova-02c7cd97fa4b8a81f0795be757bd99a29a037795.zip | |
Fix more OS-DCF:diskConfig XML handling
Add handling in the deserialisation code to handle the
OS-DCF:diskConfig attribute in the rebuild and resize actions so
the diskConfig extension can handle it properly. Formerly only
the older auto_disk_config attribute was managed (and incorrectly so).
Fixes bug 1153133
Change-Id: I68479d258cf23083274dd21b1f9eabab2feeb093
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 13 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/test_servers.py | 63 |
2 files changed, 74 insertions, 2 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index c21599300..2ef154329 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -357,7 +357,12 @@ class ActionDeserializer(CommonDeserializer): rebuild['name'] = name if node.hasAttribute("auto_disk_config"): - rebuild['auto_disk_config'] = node.getAttribute("auto_disk_config") + rebuild['OS-DCF:diskConfig'] = node.getAttribute( + "auto_disk_config") + + if node.hasAttribute("OS-DCF:diskConfig"): + rebuild['OS-DCF:diskConfig'] = node.getAttribute( + "OS-DCF:diskConfig") metadata_node = self.find_first_child_named(node, "metadata") if metadata_node is not None: @@ -391,7 +396,11 @@ class ActionDeserializer(CommonDeserializer): raise AttributeError("No flavorRef was specified in request") if node.hasAttribute("auto_disk_config"): - resize['auto_disk_config'] = node.getAttribute("auto_disk_config") + resize['OS-DCF:diskConfig'] = node.getAttribute("auto_disk_config") + + if node.hasAttribute("OS-DCF:diskConfig"): + resize['OS-DCF:diskConfig'] = node.getAttribute( + "OS-DCF:diskConfig") return resize diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index da653c980..e706f5046 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -3844,6 +3844,69 @@ class TestServerCreateRequestXMLDeserializer(test.TestCase): self.assertEquals(request['body'], expected) +class TestServerActionRequestXMLDeserializer(test.TestCase): + + def setUp(self): + super(TestServerActionRequestXMLDeserializer, self).setUp() + self.deserializer = servers.ActionDeserializer() + + def test_rebuild_request(self): + serial_request = """ +<rebuild xmlns="http://docs.openstack.org/compute/api/v1.1" + xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" + OS-DCF:diskConfig="MANUAL" imageRef="1"/>""" + request = self.deserializer.deserialize(serial_request) + expected = { + "rebuild": { + "imageRef": "1", + "OS-DCF:diskConfig": "MANUAL", + }, + } + self.assertEquals(request['body'], expected) + + def test_rebuild_request_auto_disk_config_compat(self): + serial_request = """ +<rebuild xmlns="http://docs.openstack.org/compute/api/v1.1" + xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" + auto_disk_config="MANUAL" imageRef="1"/>""" + request = self.deserializer.deserialize(serial_request) + expected = { + "rebuild": { + "imageRef": "1", + "OS-DCF:diskConfig": "MANUAL", + }, + } + self.assertEquals(request['body'], expected) + + def test_resize_request(self): + serial_request = """ +<resize xmlns="http://docs.openstack.org/compute/api/v1.1" + xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" + OS-DCF:diskConfig="MANUAL" flavorRef="1"/>""" + request = self.deserializer.deserialize(serial_request) + expected = { + "resize": { + "flavorRef": "1", + "OS-DCF:diskConfig": "MANUAL", + }, + } + self.assertEquals(request['body'], expected) + + def test_resize_request_auto_disk_config_compat(self): + serial_request = """ +<resize xmlns="http://docs.openstack.org/compute/api/v1.1" + xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" + auto_disk_config="MANUAL" flavorRef="1"/>""" + request = self.deserializer.deserialize(serial_request) + expected = { + "resize": { + "flavorRef": "1", + "OS-DCF:diskConfig": "MANUAL", + }, + } + self.assertEquals(request['body'], expected) + + class TestAddressesXMLSerialization(test.TestCase): index_serializer = ips.AddressesTemplate() |
