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:
task.execute()
except (exception.NoValidHost,
exception.ComputeHostNotFound,
exception.ComputeServiceUnavailable,
exception.InvalidHypervisorType,
exception.InvalidCPUInfo,

View File

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

View File

@ -93,7 +93,7 @@ class NovaException(Exception):
# log the issue and the kwargs
LOG.exception(_LE('Exception in string format operation'))
for name, value in six.iteritems(kwargs):
LOG.error("%s: %s" % (name, value)) # noqa
LOG.error("%s: %s" % (name, value)) # noqa
if CONF.fatal_exception_format_errors:
six.reraise(*exc_info)

View File

@ -138,10 +138,11 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
self.mox.StubOutWithMock(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.assertRaises(exception.ComputeServiceUnavailable,
self.assertRaises(exception.ComputeHostNotFound,
self.task._check_host_is_up, "host")
def test_check_requested_destination(self):
@ -187,10 +188,11 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
self.mox.StubOutWithMock(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.assertRaises(exception.ComputeServiceUnavailable,
self.assertRaises(exception.ComputeHostNotFound,
self.task._check_requested_destination)
def test_check_requested_destination_fails_with_not_enough_memory(self):