Merge "Fix incorrect exception on os-migrateLive"
This commit is contained in:
commit
3d19edc023
@ -327,6 +327,9 @@ class AdminActionsController(wsgi.Controller):
|
||||
raise exc.HTTPBadRequest(explanation=ex.format_message())
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'os-migrateLive')
|
||||
except Exception:
|
||||
if host is None:
|
||||
msg = _("Live migration of instance %s to another host "
|
||||
|
@ -174,13 +174,21 @@ class AdminActionsTest(CommonMixin, test.NoDBTestCase):
|
||||
self.mox.StubOutWithMock(self.compute_api, 'get')
|
||||
|
||||
def test_actions_raise_conflict_on_invalid_state(self):
|
||||
actions = ['pause', 'unpause', 'suspend', 'resume', 'migrate']
|
||||
method_translations = {'migrate': 'resize'}
|
||||
actions = ['pause', 'unpause', 'suspend', 'resume', 'migrate',
|
||||
'os-migrateLive']
|
||||
method_translations = {'migrate': 'resize',
|
||||
'os-migrateLive': 'live_migrate'}
|
||||
body_map = {'os-migrateLive':
|
||||
{'host': 'hostname',
|
||||
'block_migration': False,
|
||||
'disk_over_commit': False}}
|
||||
args_map = {'os-migrateLive': ((False, False, 'hostname'), {})}
|
||||
|
||||
for action in actions:
|
||||
method = method_translations.get(action)
|
||||
self.mox.StubOutWithMock(self.compute_api, method or action)
|
||||
self._test_invalid_state(action, method=method)
|
||||
self._test_invalid_state(action, method=method, body_map=body_map,
|
||||
compute_api_args_map=args_map)
|
||||
# Re-mock this.
|
||||
self.mox.StubOutWithMock(self.compute_api, 'get')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user