summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-09-18 16:01:28 -0400
committerBrian Waldon <brian.waldon@rackspace.com>2011-09-18 16:01:28 -0400
commit340c0dd5250d6cdee08ccf86cf7a1e88cfbeea07 (patch)
tree8dff5412f178c1414615065031f3e8e63f46369c /nova/api
parent2835134095fb645caac5cd7720febfa871084c05 (diff)
downloadnova-340c0dd5250d6cdee08ccf86cf7a1e88cfbeea07.tar.gz
nova-340c0dd5250d6cdee08ccf86cf7a1e88cfbeea07.tar.xz
nova-340c0dd5250d6cdee08ccf86cf7a1e88cfbeea07.zip
catching AttributeError and adding tests
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/servers.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 0ef246852..9152d92bf 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -151,6 +151,7 @@ class Controller(object):
def create(self, req, body):
""" Creates a new server for a given user """
+
if 'server' in body:
body['server']['key_name'] = self._get_key_name(req, body)
@@ -656,7 +657,11 @@ class ControllerV11(Controller):
def _get_key_name(self, req, body):
if 'server' in body:
- return body['server'].get('key_name')
+ try:
+ return body['server'].get('key_name')
+ except AttributeError:
+ msg = _("Malformed server entity")
+ raise exc.HTTPBadRequest(explanation=msg)
def _image_ref_from_req_data(self, data):
try: