diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 014267e7f8..e7f83f2da7 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -320,6 +320,7 @@ class ComputeTaskManager(base.Base): try: task.execute() except (exception.NoValidHost, + exception.ComputeHostNotFound, exception.ComputeServiceUnavailable, exception.InvalidHypervisorType, exception.InvalidCPUInfo, diff --git a/nova/conductor/tasks/live_migrate.py b/nova/conductor/tasks/live_migrate.py index b31927816f..9ed5ccc946 100644 --- a/nova/conductor/tasks/live_migrate.py +++ b/nova/conductor/tasks/live_migrate.py @@ -77,16 +77,13 @@ class LiveMigrationTask(base.TaskBase): if self.instance.power_state not in (power_state.RUNNING, power_state.PAUSED): raise exception.InstanceInvalidState( - instance_uuid = self.instance.uuid, - attr = 'power_state', - state = self.instance.power_state, - method = 'live migrate') + instance_uuid=self.instance.uuid, + attr='power_state', + state=self.instance.power_state, + 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) diff --git a/nova/exception.py b/nova/exception.py index 62236a9089..f4ea67752d 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -145,7 +145,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) diff --git a/nova/tests/unit/conductor/tasks/test_live_migrate.py b/nova/tests/unit/conductor/tasks/test_live_migrate.py index c1f7cd24e5..b6d9f10120 100644 --- a/nova/tests/unit/conductor/tasks/test_live_migrate.py +++ b/nova/tests/unit/conductor/tasks/test_live_migrate.py @@ -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):