Merge "Explicit errors on confirm/revertResize failures"
This commit is contained in:
@@ -664,6 +664,9 @@ class Controller(object):
|
|||||||
def _action_confirm_resize(self, input_dict, req, id):
|
def _action_confirm_resize(self, input_dict, req, id):
|
||||||
try:
|
try:
|
||||||
self.compute_api.confirm_resize(req.environ['nova.context'], id)
|
self.compute_api.confirm_resize(req.environ['nova.context'], id)
|
||||||
|
except exception.MigrationNotFound:
|
||||||
|
msg = _("Instance has not been resized.")
|
||||||
|
raise exc.HTTPBadRequest(explanation=msg)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
LOG.exception(_("Error in confirm-resize %s"), e)
|
LOG.exception(_("Error in confirm-resize %s"), e)
|
||||||
raise exc.HTTPBadRequest()
|
raise exc.HTTPBadRequest()
|
||||||
@@ -672,6 +675,9 @@ class Controller(object):
|
|||||||
def _action_revert_resize(self, input_dict, req, id):
|
def _action_revert_resize(self, input_dict, req, id):
|
||||||
try:
|
try:
|
||||||
self.compute_api.revert_resize(req.environ['nova.context'], id)
|
self.compute_api.revert_resize(req.environ['nova.context'], id)
|
||||||
|
except exception.MigrationNotFound:
|
||||||
|
msg = _("Instance has not been resized.")
|
||||||
|
raise exc.HTTPBadRequest(explanation=msg)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
LOG.exception(_("Error in revert-resize %s"), e)
|
LOG.exception(_("Error in revert-resize %s"), e)
|
||||||
raise exc.HTTPBadRequest()
|
raise exc.HTTPBadRequest()
|
||||||
|
@@ -272,6 +272,20 @@ class ServerActionsTest(test.TestCase):
|
|||||||
res = req.get_response(fakes.wsgi_app())
|
res = req.get_response(fakes.wsgi_app())
|
||||||
self.assertEqual(res.status_int, 400)
|
self.assertEqual(res.status_int, 400)
|
||||||
|
|
||||||
|
def test_confirm_resize_migration_not_found(self):
|
||||||
|
req = self.webreq('/1/action', 'POST', dict(confirmResize=None))
|
||||||
|
|
||||||
|
def confirm_resize_mock(*args):
|
||||||
|
raise exception.MigrationNotFoundByStatus(instance_id=1,
|
||||||
|
status='finished')
|
||||||
|
|
||||||
|
self.stubs.Set(nova.compute.api.API,
|
||||||
|
'confirm_resize',
|
||||||
|
confirm_resize_mock)
|
||||||
|
|
||||||
|
res = req.get_response(fakes.wsgi_app())
|
||||||
|
self.assertEqual(res.status_int, 400)
|
||||||
|
|
||||||
def test_revert_resize_server(self):
|
def test_revert_resize_server(self):
|
||||||
req = self.webreq('/1/action', 'POST', dict(revertResize=None))
|
req = self.webreq('/1/action', 'POST', dict(revertResize=None))
|
||||||
|
|
||||||
@@ -299,6 +313,20 @@ class ServerActionsTest(test.TestCase):
|
|||||||
res = req.get_response(fakes.wsgi_app())
|
res = req.get_response(fakes.wsgi_app())
|
||||||
self.assertEqual(res.status_int, 400)
|
self.assertEqual(res.status_int, 400)
|
||||||
|
|
||||||
|
def test_revert_resize_migration_not_found(self):
|
||||||
|
req = self.webreq('/1/action', 'POST', dict(revertResize=None))
|
||||||
|
|
||||||
|
def revert_resize_mock(*args):
|
||||||
|
raise exception.MigrationNotFoundByStatus(instance_id=1,
|
||||||
|
status='finished')
|
||||||
|
|
||||||
|
self.stubs.Set(nova.compute.api.API,
|
||||||
|
'revert_resize',
|
||||||
|
revert_resize_mock)
|
||||||
|
|
||||||
|
res = req.get_response(fakes.wsgi_app())
|
||||||
|
self.assertEqual(res.status_int, 400)
|
||||||
|
|
||||||
def test_create_backup(self):
|
def test_create_backup(self):
|
||||||
"""The happy path for creating backups"""
|
"""The happy path for creating backups"""
|
||||||
self.flags(allow_admin_api=True)
|
self.flags(allow_admin_api=True)
|
||||||
|
Reference in New Issue
Block a user