diff --git a/nova/notifications/base.py b/nova/notifications/base.py index 690b331eda62..7fb340c5ba2a 100644 --- a/nova/notifications/base.py +++ b/nova/notifications/base.py @@ -252,19 +252,15 @@ def send_instance_update_notification(context, instance, old_vm_state=None, _send_versioned_instance_update(context, instance, payload, host, service) -def _map_service_to_binary(service): - if service == 'api': - binary = 'nova-api' - elif service == 'compute': - binary = 'nova-compute' - else: - binary = service - return binary - - @rpc.if_notifications_enabled def _send_versioned_instance_update(context, instance, payload, host, service): + def _map_legacy_service_to_binary(legacy_service): + if not legacy_service.startswith('nova-'): + return 'nova-' + service + else: + return service + state_update = instance_notification.InstanceStateUpdatePayload( old_state=payload.get('old_state'), state=payload.get('state'), @@ -295,7 +291,7 @@ def _send_versioned_instance_update(context, instance, payload, host, service): action=fields.NotificationAction.UPDATE), publisher=notification_base.NotificationPublisher( host=host or CONF.host, - binary=_map_service_to_binary(service)), + binary=_map_legacy_service_to_binary(service)), payload=versioned_payload) notification.emit(context) diff --git a/nova/tests/functional/notification_sample_tests/test_instance.py b/nova/tests/functional/notification_sample_tests/test_instance.py index 665719ff47ef..949533aafa0b 100644 --- a/nova/tests/functional/notification_sample_tests/test_instance.py +++ b/nova/tests/functional/notification_sample_tests/test_instance.py @@ -173,7 +173,7 @@ class TestInstanceNotificationSample( # rest is from the nova-compute. To keep the test simpler # assert this fact and then modify the publisher_id of the # first and eighth notification to match the template - self.assertEqual('conductor:fake-mini', + self.assertEqual('nova-conductor:fake-mini', instance_updates[0]['publisher_id']) self.assertEqual('nova-api:fake-mini', instance_updates[7]['publisher_id']) diff --git a/nova/tests/unit/test_notifications.py b/nova/tests/unit/test_notifications.py index 13377e8db950..6de2aae78568 100644 --- a/nova/tests/unit/test_notifications.py +++ b/nova/tests/unit/test_notifications.py @@ -426,7 +426,7 @@ class NotificationsTestCase(test.TestCase): self.assertEqual('testservice.testhost', notif.publisher_id) notif = fake_notifier.VERSIONED_NOTIFICATIONS[0] - self.assertEqual('testservice:testhost', notif['publisher_id']) + self.assertEqual('nova-testservice:testhost', notif['publisher_id']) def test_update_with_host_name(self): notifications.send_update_with_states(self.context, self.instance,