Merge "raise exception ComputeHostNotFound if host is not found"

This commit is contained in:
Jenkins 2016-07-26 13:17:36 +00:00 committed by Gerrit Code Review
commit 1913050fd1
4 changed files with 9 additions and 9 deletions

View File

@ -333,6 +333,7 @@ class ComputeTaskManager(base.Base):
try: try:
task.execute() task.execute()
except (exception.NoValidHost, except (exception.NoValidHost,
exception.ComputeHostNotFound,
exception.ComputeServiceUnavailable, exception.ComputeServiceUnavailable,
exception.InvalidHypervisorType, exception.InvalidHypervisorType,
exception.InvalidCPUInfo, exception.InvalidCPUInfo,

View File

@ -83,10 +83,7 @@ class LiveMigrationTask(base.TaskBase):
method='live migrate') method='live migrate')
def _check_host_is_up(self, host): def _check_host_is_up(self, host):
try:
service = objects.Service.get_by_compute_host(self.context, host) service = objects.Service.get_by_compute_host(self.context, host)
except exception.NotFound:
raise exception.ComputeServiceUnavailable(host=host)
if not self.servicegroup_api.service_is_up(service): if not self.servicegroup_api.service_is_up(service):
raise exception.ComputeServiceUnavailable(host=host) raise exception.ComputeServiceUnavailable(host=host)

View File

@ -138,10 +138,11 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
self.mox.StubOutWithMock(objects.Service, 'get_by_compute_host') self.mox.StubOutWithMock(objects.Service, 'get_by_compute_host')
objects.Service.get_by_compute_host( objects.Service.get_by_compute_host(
self.context, "host").AndRaise(exception.NotFound) self.context, "host").AndRaise(
exception.ComputeHostNotFound(host='host'))
self.mox.ReplayAll() self.mox.ReplayAll()
self.assertRaises(exception.ComputeServiceUnavailable, self.assertRaises(exception.ComputeHostNotFound,
self.task._check_host_is_up, "host") self.task._check_host_is_up, "host")
def test_check_requested_destination(self): def test_check_requested_destination(self):
@ -187,10 +188,11 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
self.mox.StubOutWithMock(objects.Service, 'get_by_compute_host') self.mox.StubOutWithMock(objects.Service, 'get_by_compute_host')
objects.Service.get_by_compute_host( objects.Service.get_by_compute_host(
self.context, self.destination).AndRaise(exception.NotFound) self.context, self.destination).AndRaise(
exception.ComputeHostNotFound(host='host'))
self.mox.ReplayAll() self.mox.ReplayAll()
self.assertRaises(exception.ComputeServiceUnavailable, self.assertRaises(exception.ComputeHostNotFound,
self.task._check_requested_destination) self.task._check_requested_destination)
def test_check_requested_destination_fails_with_not_enough_memory(self): def test_check_requested_destination_fails_with_not_enough_memory(self):