Merge "Return 400 when compute host is not found"
This commit is contained in:
commit
450be218da
@ -108,7 +108,6 @@ class MigrateServerController(wsgi.Controller):
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
except (exception.NoValidHost,
|
||||
exception.ComputeServiceUnavailable,
|
||||
exception.ComputeHostNotFound,
|
||||
exception.InvalidHypervisorType,
|
||||
exception.InvalidCPUInfo,
|
||||
exception.UnableToMigrateToSelf,
|
||||
@ -127,6 +126,8 @@ class MigrateServerController(wsgi.Controller):
|
||||
raise exc.HTTPBadRequest(explanation=ex.format_message())
|
||||
except exception.InstanceIsLocked as e:
|
||||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
except exception.ComputeHostNotFound as e:
|
||||
raise exc.HTTPBadRequest(explanation=e.format_message())
|
||||
except exception.InstanceInvalidState as state_error:
|
||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||
'os-migrateLive', id)
|
||||
|
@ -427,8 +427,27 @@ class MigrateServerTestsV234(MigrateServerTestsV230):
|
||||
def test_migrate_live_migration_with_old_nova_not_supported(self):
|
||||
pass
|
||||
|
||||
def test_migrate_live_compute_host_not_found(self):
|
||||
exc = exception.ComputeHostNotFound(
|
||||
reason="Compute host %(host)s could not be found.",
|
||||
host='hostname')
|
||||
self.mox.StubOutWithMock(self.compute_api, 'live_migrate')
|
||||
instance = self._stub_instance_get()
|
||||
self.compute_api.live_migrate(self.context, instance, None,
|
||||
self.disk_over_commit, 'hostname',
|
||||
self.force, self.async).AndRaise(exc)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
body = {'os-migrateLive':
|
||||
{'host': 'hostname', 'block_migration': 'auto'}}
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._migrate_live,
|
||||
self.req, instance.uuid, body=body)
|
||||
|
||||
def test_migrate_live_unexpected_error(self):
|
||||
exc = exception.NoValidHost(reason="No valid host found")
|
||||
exc = exception.InvalidHypervisorType(
|
||||
reason="The supplied hypervisor type of is invalid.")
|
||||
self.mox.StubOutWithMock(self.compute_api, 'live_migrate')
|
||||
instance = self._stub_instance_get()
|
||||
self.compute_api.live_migrate(self.context, instance, None,
|
||||
|
Loading…
Reference in New Issue
Block a user