summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorWilliam Wolf <throughnothing@gmail.com>2011-07-21 19:42:09 +0000
committerTarmac <>2011-07-21 19:42:09 +0000
commita1b4bf0d74deab62482d8244f8985f5dc1c0b56f (patch)
treec836bc1d53b6d90965d4b08d7ab7da8a6d2b4772 /nova/api
parentaf1b6c947a9bc8915e328546bda6ff454a1246e9 (diff)
parent8bf63ee3132e2f41eca5fa34ea8428e03b22986c (diff)
This fixes issues with invalid flavorRef's being passed in returning a 500 instead of a 400, and adds tests to verify that two separate cases work.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/create_instance_helper.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/nova/api/openstack/create_instance_helper.py b/nova/api/openstack/create_instance_helper.py
index 7784a3e81..7249f1261 100644
--- a/nova/api/openstack/create_instance_helper.py
+++ b/nova/api/openstack/create_instance_helper.py
@@ -101,7 +101,11 @@ class CreateInstanceHelper(object):
if personality:
injected_files = self._get_injected_files(personality)
- flavor_id = self.controller._flavor_id_from_req_data(body)
+ try:
+ flavor_id = self.controller._flavor_id_from_req_data(body)
+ except ValueError as error:
+ msg = _("Invalid flavorRef provided.")
+ raise exc.HTTPBadRequest(explanation=msg)
if not 'name' in body['server']:
msg = _("Server name is not defined")
@@ -153,7 +157,9 @@ class CreateInstanceHelper(object):
except exception.ImageNotFound as error:
msg = _("Can not find requested image")
raise exc.HTTPBadRequest(explanation=msg)
-
+ except exception.FlavorNotFound as error:
+ msg = _("Invalid flavorRef provided.")
+ raise exc.HTTPBadRequest(explanation=msg)
# Let the caller deal with unhandled exceptions.
def _handle_quota_error(self, error):