summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorBrian Lamar <brian.lamar@rackspace.com>2011-08-02 11:17:42 +0000
committerTarmac <>2011-08-02 11:17:42 +0000
commitefdd1bb019ac431d7d7a1923ff8580de1bb34217 (patch)
tree44e2341e236c54eeeb05a6c033cdd2d2a81e83b6 /nova/api
parent483f8f9738b6e87642bfb0811b55ae6240f966cc (diff)
parent25a831fd449dbbb7f0c2cdac404d7600a6da9f27 (diff)
downloadnova-efdd1bb019ac431d7d7a1923ff8580de1bb34217.tar.gz
nova-efdd1bb019ac431d7d7a1923ff8580de1bb34217.tar.xz
nova-efdd1bb019ac431d7d7a1923ff8580de1bb34217.zip
Better error handling for resizing.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/servers.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 30169d450..8d2ccc2ad 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -405,6 +405,24 @@ class Controller(object):
error=item.error))
return dict(actions=actions)
+ def resize(self, req, instance_id, flavor_id):
+ """Begin the resize process with given instance/flavor."""
+ context = req.environ["nova.context"]
+
+ try:
+ self.compute_api.resize(context, instance_id, flavor_id)
+ except exception.FlavorNotFound:
+ msg = _("Unable to locate requested flavor.")
+ raise exc.HTTPBadRequest(explanation=msg)
+ except exception.CannotResizeToSameSize:
+ msg = _("Resize requires a change in size.")
+ raise exc.HTTPBadRequest(explanation=msg)
+ except exception.CannotResizeToSmallerSize:
+ msg = _("Resizing to a smaller size is not supported.")
+ raise exc.HTTPBadRequest(explanation=msg)
+
+ return webob.Response(status_int=202)
+
class ControllerV10(Controller):
@@ -444,16 +462,7 @@ class ControllerV10(Controller):
msg = _("Resize requests require 'flavorId' attribute.")
raise exc.HTTPBadRequest(explanation=msg)
- try:
- i_type = instance_types.get_instance_type_by_flavor_id(flavor_id)
- except exception.FlavorNotFound:
- msg = _("Unable to locate requested flavor.")
- raise exc.HTTPBadRequest(explanation=msg)
-
- context = req.environ["nova.context"]
- self.compute_api.resize(context, id, i_type["id"])
-
- return webob.Response(status_int=202)
+ return self.resize(req, id, flavor_id)
def _action_rebuild(self, info, request, instance_id):
context = request.environ['nova.context']
@@ -568,16 +577,7 @@ class ControllerV11(Controller):
msg = _("Resize requests require 'flavorRef' attribute.")
raise exc.HTTPBadRequest(explanation=msg)
- try:
- i_type = instance_types.get_instance_type_by_flavor_id(flavor_ref)
- except exception.FlavorNotFound:
- msg = _("Unable to locate requested flavor.")
- raise exc.HTTPBadRequest(explanation=msg)
-
- context = req.environ["nova.context"]
- self.compute_api.resize(context, id, i_type["id"])
-
- return webob.Response(status_int=202)
+ return self.resize(req, id, flavor_ref)
def _action_rebuild(self, info, request, instance_id):
context = request.environ['nova.context']