Skip to content

Commit

Permalink
Remove rescue/unrescue NotImplementedError handle
Browse files Browse the repository at this point in the history
There are 2 kinds of RPC call from API layer to compute layer,
one is cast and another is call. For cast, the RPC message will
be posted and the API service will not wait for the message to
be processed. So it won't be able to catch the exception raised
in compute layer and catch and handle the exception is useless
and error leading. This patch removes code in API layer for
rescue and unrescue functions.

Change-Id: Iab8070c25a9dee505c0602efad85c41c21c2aa58
  • Loading branch information
jichenjc committed Jul 19, 2014
1 parent 769b3f1 commit b4a32a9
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 79 deletions.
7 changes: 0 additions & 7 deletions nova/api/openstack/compute/contrib/rescue.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ def _rescue(self, req, id, body):
except exception.InstanceNotRescuable as non_rescuable:
raise exc.HTTPBadRequest(
explanation=non_rescuable.format_message())
except NotImplementedError:
msg = _("The rescue operation is not implemented by this "
"cloud.")
raise exc.HTTPNotImplemented(explanation=msg)

return {'adminPass': password}

Expand All @@ -94,9 +90,6 @@ def _unrescue(self, req, id, body):
except exception.InstanceInvalidState as state_error:
common.raise_http_conflict_for_instance_invalid_state(state_error,
'unrescue')
except NotImplementedError:
msg = _("The unrescue operation is not implemented by this cloud.")
raise exc.HTTPNotImplemented(explanation=msg)

return webob.Response(status_int=202)

Expand Down
7 changes: 0 additions & 7 deletions nova/api/openstack/compute/plugins/v3/rescue.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from nova.api import validation
from nova import compute
from nova import exception
from nova.i18n import _
from nova import utils


Expand Down Expand Up @@ -76,9 +75,6 @@ def _rescue(self, req, id, body):
except exception.InstanceNotRescuable as non_rescuable:
raise exc.HTTPBadRequest(
explanation=non_rescuable.format_message())
except NotImplementedError:
msg = _("The rescue operation is not implemented by this cloud.")
raise exc.HTTPNotImplemented(explanation=msg)

if CONF.enable_instance_password:
return {'admin_password': password}
Expand All @@ -100,9 +96,6 @@ def _unrescue(self, req, id, body):
except exception.InstanceInvalidState as state_error:
common.raise_http_conflict_for_instance_invalid_state(state_error,
'unrescue')
except NotImplementedError:
msg = _("The unrescue operation is not implemented by this cloud.")
raise exc.HTTPNotImplemented(explanation=msg)

return webob.Response(status_int=202)

Expand Down
33 changes: 0 additions & 33 deletions nova/tests/api/openstack/compute/contrib/test_rescue.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.

import mock
from oslo.config import cfg
import webob

Expand Down Expand Up @@ -165,35 +164,3 @@ def fake_rescue(*args, **kwargs):

resp = req.get_response(self.app)
self.assertEqual(resp.status_int, 400)

@mock.patch('nova.compute.api.API.rescue')
def test_rescue_raises_not_implemented(self, rescue_mock):
body = dict(rescue=None)

def fake_rescue(*args, **kwargs):
raise NotImplementedError('not implemented')

rescue_mock.side_effect = fake_rescue
req = webob.Request.blank('/v2/fake/servers/test_inst/action')
req.method = "POST"
req.body = jsonutils.dumps(body)
req.headers["content-type"] = "application/json"

resp = req.get_response(self.app)
self.assertEqual(resp.status_int, 501)

@mock.patch('nova.compute.api.API.unrescue')
def test_unrescue_raises_not_implemented(self, unrescue_mock):
body = dict(unrescue=None)

def fake_unrescue(*args, **kwargs):
raise NotImplementedError('not implemented')

unrescue_mock.side_effect = fake_unrescue
req = webob.Request.blank('/v2/fake/servers/test_inst/action')
req.method = "POST"
req.body = jsonutils.dumps(body)
req.headers["content-type"] = "application/json"

resp = req.get_response(self.app)
self.assertEqual(resp.status_int, 501)
32 changes: 0 additions & 32 deletions nova/tests/api/openstack/compute/plugins/v3/test_rescue.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,35 +244,3 @@ def test_rescue_with_invalid_property(self):

resp = req.get_response(self.app)
self.assertEqual(400, resp.status_int)

@mock.patch('nova.compute.api.API.rescue')
def test_rescue_raises_not_implemented(self, rescue_mock):
body = dict(rescue=None)

def fake_rescue(*args, **kwargs):
raise NotImplementedError('fake message')

rescue_mock.side_effect = fake_rescue
req = webob.Request.blank('/v3/servers/test_inst/action')
req.method = "POST"
req.body = jsonutils.dumps(body)
req.headers["content-type"] = "application/json"

resp = req.get_response(self.app)
self.assertEqual(resp.status_int, 501)

@mock.patch('nova.compute.api.API.unrescue')
def test_unrescue_raises_not_implemented(self, unrescue_mock):
body = dict(unrescue=None)

def fake_unrescue(*args, **kwargs):
raise NotImplementedError('fake message')

unrescue_mock.side_effect = fake_unrescue
req = webob.Request.blank('/v3/servers/test_inst/action')
req.method = "POST"
req.body = jsonutils.dumps(body)
req.headers["content-type"] = "application/json"

resp = req.get_response(self.app)
self.assertEqual(resp.status_int, 501)

0 comments on commit b4a32a9

Please sign in to comment.