summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorZhou ShaoYu <hzzhoushaoyu@corp.netease.com>2013-02-05 14:42:53 +0800
committerZhou ShaoYu <hzzhoushaoyu@corp.netease.com>2013-02-05 15:48:10 +0800
commit702fdf2fc1acc32b5ccd9e0830e574c42770ab5d (patch)
tree28abec1117b15e2b206fd403ef40585358b63cfc /nova/api
parent81da7771aaa6eec79f6b3fd91ce315cd5c5b7e7a (diff)
downloadnova-702fdf2fc1acc32b5ccd9e0830e574c42770ab5d.tar.gz
nova-702fdf2fc1acc32b5ccd9e0830e574c42770ab5d.tar.xz
nova-702fdf2fc1acc32b5ccd9e0830e574c42770ab5d.zip
Fix check instance host for instance action
When instance has no host, actions such as get_console_output, start_stop_instance cause HTTP 500 response. Here change to HTTPConflict when action called before host set. Fix LP# 1116012 Change-Id: I6153a03f449d9fad8d0d8fb7295bdea4d2b2c2b1
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/console_output.py2
-rw-r--r--nova/api/openstack/compute/contrib/server_start_stop.py10
2 files changed, 10 insertions, 2 deletions
diff --git a/nova/api/openstack/compute/contrib/console_output.py b/nova/api/openstack/compute/contrib/console_output.py
index 953459d38..b734cbd13 100644
--- a/nova/api/openstack/compute/contrib/console_output.py
+++ b/nova/api/openstack/compute/contrib/console_output.py
@@ -65,6 +65,8 @@ class ConsoleOutputController(wsgi.Controller):
length)
except exception.NotFound:
raise webob.exc.HTTPNotFound(_('Unable to get console'))
+ except exception.InstanceNotReady as e:
+ raise webob.exc.HTTPConflict(explanation=unicode(e))
# XML output is not correctly escaped, so remove invalid characters
remove_re = re.compile('[\x00-\x08\x0B-\x0C\x0E-\x1F]')
diff --git a/nova/api/openstack/compute/contrib/server_start_stop.py b/nova/api/openstack/compute/contrib/server_start_stop.py
index 733972083..a13aabb05 100644
--- a/nova/api/openstack/compute/contrib/server_start_stop.py
+++ b/nova/api/openstack/compute/contrib/server_start_stop.py
@@ -44,7 +44,10 @@ class ServerStartStopActionController(wsgi.Controller):
context = req.environ['nova.context']
instance = self._get_instance(context, id)
LOG.debug(_('start instance'), instance=instance)
- self.compute_api.start(context, instance)
+ try:
+ self.compute_api.start(context, instance)
+ except exception.InstanceNotReady as e:
+ raise webob.exc.HTTPConflict(explanation=unicode(e))
return webob.Response(status_int=202)
@wsgi.action('os-stop')
@@ -53,7 +56,10 @@ class ServerStartStopActionController(wsgi.Controller):
context = req.environ['nova.context']
instance = self._get_instance(context, id)
LOG.debug(_('stop instance'), instance=instance)
- self.compute_api.stop(context, instance)
+ try:
+ self.compute_api.stop(context, instance)
+ except exception.InstanceNotReady as e:
+ raise webob.exc.HTTPConflict(explanation=unicode(e))
return webob.Response(status_int=202)