diff --git a/doc/notification_samples/instance-soft_delete-end.json b/doc/notification_samples/instance-soft_delete-end.json index 632a18369d02..eb25097b686c 100644 --- a/doc/notification_samples/instance-soft_delete-end.json +++ b/doc/notification_samples/instance-soft_delete-end.json @@ -8,5 +8,5 @@ } }, "priority":"INFO", - "publisher_id":"nova-compute:compute" + "publisher_id":"nova-compute:fake-mini" } diff --git a/doc/notification_samples/instance-soft_delete-start.json b/doc/notification_samples/instance-soft_delete-start.json index 8557860aa81e..d60e3dfd0027 100644 --- a/doc/notification_samples/instance-soft_delete-start.json +++ b/doc/notification_samples/instance-soft_delete-start.json @@ -8,5 +8,5 @@ } }, "priority":"INFO", - "publisher_id":"nova-compute:compute" + "publisher_id":"nova-compute:fake-mini" } diff --git a/nova/compute/api.py b/nova/compute/api.py index 22b0837c0b81..2a50d2c6fbec 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1800,7 +1800,7 @@ class API(base.Base): # FIXME: When the instance context is targeted, # we can remove this with compute_utils.notify_about_instance_delete( - self.notifier, cctxt, instance, CONF.host): + self.notifier, cctxt, instance): instance.destroy() else: instance.destroy() @@ -1858,7 +1858,7 @@ class API(base.Base): try: # Now destroy the instance from the cell it lives in. with compute_utils.notify_about_instance_delete( - self.notifier, context, instance, CONF.host): + self.notifier, context, instance): instance.destroy() except exception.InstanceNotFound: pass @@ -1929,7 +1929,7 @@ class API(base.Base): if not instance.host and not may_have_ports_or_volumes: try: with compute_utils.notify_about_instance_delete( - self.notifier, context, instance, CONF.host, + self.notifier, context, instance, delete_type if delete_type != 'soft_delete' else 'delete'): @@ -2090,7 +2090,7 @@ class API(base.Base): LOG.warning("instance's host %s is down, deleting from " "database", instance.host, instance=instance) with compute_utils.notify_about_instance_delete( - self.notifier, context, instance, CONF.host, + self.notifier, context, instance, delete_type if delete_type != 'soft_delete' else 'delete'): elevated = context.elevated() diff --git a/nova/compute/manager.py b/nova/compute/manager.py index e8dda7766b56..5dbbd0933b49 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2823,7 +2823,7 @@ class ComputeManager(manager.Manager): def soft_delete_instance(self, context, instance): """Soft delete an instance on this host.""" with compute_utils.notify_about_instance_delete( - self.notifier, context, instance, self.host, 'soft_delete', + self.notifier, context, instance, 'soft_delete', source=fields.NotificationSource.COMPUTE): try: self.driver.soft_delete(instance) diff --git a/nova/compute/utils.py b/nova/compute/utils.py index 427a40b572c2..d1f8a559ba87 100644 --- a/nova/compute/utils.py +++ b/nova/compute/utils.py @@ -1180,7 +1180,7 @@ class UnlimitedSemaphore(object): @contextlib.contextmanager -def notify_about_instance_delete(notifier, context, instance, host, +def notify_about_instance_delete(notifier, context, instance, delete_type='delete', source=fields.NotificationSource.API): try: @@ -1192,7 +1192,7 @@ def notify_about_instance_delete(notifier, context, instance, host, notify_about_instance_action( context, instance, - host=host, + host=CONF.host, source=source, action=delete_type, phase=fields.NotificationPhase.START) @@ -1205,7 +1205,7 @@ def notify_about_instance_delete(notifier, context, instance, host, notify_about_instance_action( context, instance, - host=host, + host=CONF.host, source=source, action=delete_type, phase=fields.NotificationPhase.END) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 6dabd555d1de..49cfd83be902 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -1426,7 +1426,7 @@ class ComputeTaskManager(base.Base): # bdm, tags and instance record. with obj_target_cell(instance, cell) as cctxt: with compute_utils.notify_about_instance_delete( - self.notifier, cctxt, instance, CONF.host, + self.notifier, cctxt, instance, source=fields.NotificationSource.CONDUCTOR): try: instance.destroy() diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index 217534174e6a..6e5978ced5af 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -1732,7 +1732,7 @@ class _ComputeAPIUnitTestMixIn(object): _lookup_instance.assert_called_once_with( self.context, instance.uuid) notify_mock.assert_called_once_with( - self.compute_api.notifier, self.context, instance, 'fake-mini') + self.compute_api.notifier, self.context, instance) destroy_mock.assert_called_once_with() @mock.patch.object(context, 'target_cell') diff --git a/nova/tests/unit/compute/test_compute_utils.py b/nova/tests/unit/compute/test_compute_utils.py index 7542752081b7..722ccce0c440 100644 --- a/nova/tests/unit/compute/test_compute_utils.py +++ b/nova/tests/unit/compute/test_compute_utils.py @@ -1107,7 +1107,7 @@ class ComputeUtilsTestCase(test.NoDBTestCase): instance = fake_instance.fake_instance_obj( self.context, expected_attrs=('system_metadata',)) with compute_utils.notify_about_instance_delete( - mock.sentinel.notifier, self.context, instance, "fake-mini"): + mock.sentinel.notifier, self.context, instance): instance.destroy() expected_notify_calls = [ mock.call(mock.sentinel.notifier, self.context, instance,