From 98b8001407ef06e1cdb8434571288dc56dba7bc0 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Wed, 18 Apr 2012 17:39:58 -0400 Subject: [PATCH] Make rebuilds with an emtpy name raise BadRequest. Fixes bug 973591 Change-Id: I87f189175c55a6922e7277857b85d526b9bfa6e1 --- nova/api/openstack/compute/servers.py | 5 ++++- .../api/openstack/compute/test_server_actions.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 2e7b184c482b..26c3b020a2cc 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -271,7 +271,10 @@ class ActionDeserializer(CommonDeserializer): def _action_rebuild(self, node): rebuild = {} if node.hasAttribute("name"): - rebuild['name'] = node.getAttribute("name") + name = node.getAttribute("name") + if not name: + raise AttributeError("Name cannot be blank") + rebuild['name'] = name if node.hasAttribute("auto_disk_config"): rebuild['auto_disk_config'] = node.getAttribute("auto_disk_config") diff --git a/nova/tests/api/openstack/compute/test_server_actions.py b/nova/tests/api/openstack/compute/test_server_actions.py index fd9b5eaef705..9e7d3ffc497a 100644 --- a/nova/tests/api/openstack/compute/test_server_actions.py +++ b/nova/tests/api/openstack/compute/test_server_actions.py @@ -877,3 +877,14 @@ class TestServerActionXMLDeserializer(test.TestCase): self.deserializer.deserialize, serial_request, 'action') + + def test_rebuild_blank_name(self): + serial_request = """ + """ + self.assertRaises(AttributeError, + self.deserializer.deserialize, + serial_request, + 'action')