Merge "migrate server doesn't raise correct exception"

This commit is contained in:
Jenkins
2013-10-24 21:04:41 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 2 deletions

View File

@@ -132,6 +132,8 @@ class AdminActionsController(wsgi.Controller):
except exception.InstanceInvalidState as state_error:
common.raise_http_conflict_for_instance_invalid_state(state_error,
'migrate')
except exception.InstanceNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())
except Exception as e:
LOG.exception(_("Error in migrate %s"), e)
raise exc.HTTPBadRequest()
@@ -301,6 +303,8 @@ class AdminActionsController(wsgi.Controller):
exception.UnableToMigrateToSelf,
exception.DestinationHypervisorTooOld) as ex:
raise exc.HTTPBadRequest(explanation=ex.format_message())
except exception.InstanceNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())
except Exception:
if host is None:
msg = _("Live migration of instance %s to another host "

View File

@@ -169,8 +169,12 @@ class AdminActionsTest(CommonMixin, test.NoDBTestCase):
def test_actions_with_non_existed_instance(self):
actions = ['pause', 'unpause', 'suspend', 'resume',
'resetNetwork', 'injectNetworkInfo', 'lock',
'unlock', 'os-resetState']
body_map = {'os-resetState': {'state': 'active'}}
'unlock', 'os-resetState', 'migrate']
body_map = {'os-resetState': {'state': 'active'},
'os-migrateLive':
{'host': 'hostname',
'block_migration': False,
'disk_over_commit': False}}
for action in actions:
self._test_non_existing_instance(action,
body_map=body_map)