summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2013-05-20 20:01:08 +0000
committerRick Harris <rconradharris@gmail.com>2013-05-22 17:19:53 +0000
commit1fa3101fceab27c8ac70c091bac0d9e7bcc184b4 (patch)
tree40adfff3379a89299a304d8e80f3faeac12b91db /nova/api
parent350ff35508630506c8bb9a6a93bb283c819c14ff (diff)
downloadnova-1fa3101fceab27c8ac70c091bac0d9e7bcc184b4.tar.gz
nova-1fa3101fceab27c8ac70c091bac0d9e7bcc184b4.tar.xz
nova-1fa3101fceab27c8ac70c091bac0d9e7bcc184b4.zip
Move ImageTooLarge check to Compute API
The existing ImageTooLarge check is in the compute manager, meaning that a validation error puts the instance into an ERROR state without the ability to communicate the fault back to the user. This patch moves the check to the API where we can return the appropriate error to the user. Change-Id: I2183449351e3b70f98d0552ea247184a3641d85a
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/servers.py31
1 files changed, 13 insertions, 18 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index 44d8dce3b..512f8cb7a 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -902,32 +902,18 @@ class Controller(wsgi.Controller):
raise exc.HTTPRequestEntityTooLarge(
explanation=error.format_message(),
headers={'Retry-After': 0})
- except exception.InstanceTypeMemoryTooSmall as error:
- raise exc.HTTPBadRequest(explanation=error.format_message())
- except exception.InstanceTypeNotFound as error:
- raise exc.HTTPBadRequest(explanation=error.format_message())
- except exception.InstanceTypeDiskTooSmall as error:
- raise exc.HTTPBadRequest(explanation=error.format_message())
- except exception.InvalidMetadata as error:
- raise exc.HTTPBadRequest(explanation=error.format_message())
except exception.InvalidMetadataSize as error:
raise exc.HTTPRequestEntityTooLarge(
explanation=error.format_message())
- except exception.InvalidRequest as error:
- raise exc.HTTPBadRequest(explanation=error.format_message())
except exception.ImageNotFound as error:
msg = _("Can not find requested image")
raise exc.HTTPBadRequest(explanation=msg)
- except exception.ImageNotActive as error:
- raise exc.HTTPBadRequest(explanation=error.format_message())
except exception.FlavorNotFound as error:
msg = _("Invalid flavorRef provided.")
raise exc.HTTPBadRequest(explanation=msg)
except exception.KeypairNotFound as error:
msg = _("Invalid key_name provided.")
raise exc.HTTPBadRequest(explanation=msg)
- except exception.SecurityGroupNotFound as error:
- raise exc.HTTPBadRequest(explanation=error.format_message())
except rpc_common.RemoteError as err:
msg = "%(err_type)s: %(err_msg)s" % {'err_type': err.exc_type,
'err_msg': err.value}
@@ -935,7 +921,15 @@ class Controller(wsgi.Controller):
except UnicodeDecodeError as error:
msg = "UnicodeError: %s" % unicode(error)
raise exc.HTTPBadRequest(explanation=msg)
- # Let the caller deal with unhandled exceptions.
+ except (exception.ImageNotActive,
+ exception.ImageTooLarge,
+ exception.InstanceTypeDiskTooSmall,
+ exception.InstanceTypeMemoryTooSmall,
+ exception.InstanceTypeNotFound,
+ exception.InvalidMetadata,
+ exception.InvalidRequest,
+ exception.SecurityGroupNotFound) as error:
+ raise exc.HTTPBadRequest(explanation=error.format_message())
# If the caller wanted a reservation_id, return it
if ret_resv_id:
@@ -1288,10 +1282,11 @@ class Controller(wsgi.Controller):
except exception.ImageNotFound:
msg = _("Cannot find image for rebuild")
raise exc.HTTPBadRequest(explanation=msg)
- except (exception.InvalidMetadata,
- exception.InstanceTypeMemoryTooSmall,
+ except (exception.ImageNotActive,
+ exception.ImageTooLarge,
exception.InstanceTypeDiskTooSmall,
- exception.ImageNotActive) as error:
+ exception.InstanceTypeMemoryTooSmall,
+ exception.InvalidMetadata) as error:
raise exc.HTTPBadRequest(explanation=error.format_message())
instance = self._get_server(context, req, id)