diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-03-26 20:43:43 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-03-26 20:46:15 +0000 |
| commit | 575ad8f77dc7095c8a0ba9dd8deb41bf2fddae1f (patch) | |
| tree | fae498a183c224e99e93aca00299b4449321c23c | |
| parent | 3433fd65d5f70d83ffa4db013f96c55970ea293e (diff) | |
| download | nova-575ad8f77dc7095c8a0ba9dd8deb41bf2fddae1f.tar.gz nova-575ad8f77dc7095c8a0ba9dd8deb41bf2fddae1f.tar.xz nova-575ad8f77dc7095c8a0ba9dd8deb41bf2fddae1f.zip | |
Fix unrescue in invalid state
Fixes bug 965667
Unrescue did not check for InstanceInvalidState exception and return the
appropriate error.
Change-Id: I3ca2c1dae09bd149086bfe67e2233c8359d5c8f8
| -rw-r--r-- | nova/api/openstack/compute/contrib/rescue.py | 6 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_rescue.py | 15 |
2 files changed, 20 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/contrib/rescue.py b/nova/api/openstack/compute/contrib/rescue.py index b46b12a18..7bf815a37 100644 --- a/nova/api/openstack/compute/contrib/rescue.py +++ b/nova/api/openstack/compute/contrib/rescue.py @@ -72,7 +72,11 @@ class RescueController(wsgi.Controller): context = req.environ["nova.context"] authorize(context) instance = self._get_instance(context, id) - self.compute_api.unrescue(context, instance) + try: + self.compute_api.unrescue(context, instance) + except exception.InstanceInvalidState as state_error: + common.raise_http_conflict_for_instance_invalid_state(state_error, + 'unrescue') return webob.Response(status_int=202) diff --git a/nova/tests/api/openstack/compute/contrib/test_rescue.py b/nova/tests/api/openstack/compute/contrib/test_rescue.py index c2c8aa28c..00efc2f27 100644 --- a/nova/tests/api/openstack/compute/contrib/test_rescue.py +++ b/nova/tests/api/openstack/compute/contrib/test_rescue.py @@ -93,3 +93,18 @@ class RescueTest(test.TestCase): resp = req.get_response(fakes.wsgi_app()) self.assertEqual(resp.status_int, 202) + + def test_unrescue_of_active_instance(self): + body = dict(unrescue=None) + + def fake_unrescue(*args, **kwargs): + raise exception.InstanceInvalidState('fake message') + + self.stubs.Set(compute.api.API, "unrescue", fake_unrescue) + req = webob.Request.blank('/v2/fake/servers/test_inst/action') + req.method = "POST" + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + + resp = req.get_response(fakes.wsgi_app()) + self.assertEqual(resp.status_int, 409) |
