Merge "Make notification publisher_id consistent"
This commit is contained in:
commit
3dd6526137
|
@ -252,19 +252,15 @@ def send_instance_update_notification(context, instance, old_vm_state=None,
|
||||||
_send_versioned_instance_update(context, instance, payload, host, service)
|
_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
|
@rpc.if_notifications_enabled
|
||||||
def _send_versioned_instance_update(context, instance, payload, host, service):
|
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(
|
state_update = instance_notification.InstanceStateUpdatePayload(
|
||||||
old_state=payload.get('old_state'),
|
old_state=payload.get('old_state'),
|
||||||
state=payload.get('state'),
|
state=payload.get('state'),
|
||||||
|
@ -295,7 +291,7 @@ def _send_versioned_instance_update(context, instance, payload, host, service):
|
||||||
action=fields.NotificationAction.UPDATE),
|
action=fields.NotificationAction.UPDATE),
|
||||||
publisher=notification_base.NotificationPublisher(
|
publisher=notification_base.NotificationPublisher(
|
||||||
host=host or CONF.host,
|
host=host or CONF.host,
|
||||||
binary=_map_service_to_binary(service)),
|
binary=_map_legacy_service_to_binary(service)),
|
||||||
payload=versioned_payload)
|
payload=versioned_payload)
|
||||||
notification.emit(context)
|
notification.emit(context)
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ class TestInstanceNotificationSample(
|
||||||
# rest is from the nova-compute. To keep the test simpler
|
# rest is from the nova-compute. To keep the test simpler
|
||||||
# assert this fact and then modify the publisher_id of the
|
# assert this fact and then modify the publisher_id of the
|
||||||
# first and eighth notification to match the template
|
# first and eighth notification to match the template
|
||||||
self.assertEqual('conductor:fake-mini',
|
self.assertEqual('nova-conductor:fake-mini',
|
||||||
instance_updates[0]['publisher_id'])
|
instance_updates[0]['publisher_id'])
|
||||||
self.assertEqual('nova-api:fake-mini',
|
self.assertEqual('nova-api:fake-mini',
|
||||||
instance_updates[7]['publisher_id'])
|
instance_updates[7]['publisher_id'])
|
||||||
|
|
|
@ -426,7 +426,7 @@ class NotificationsTestCase(test.TestCase):
|
||||||
self.assertEqual('testservice.testhost', notif.publisher_id)
|
self.assertEqual('testservice.testhost', notif.publisher_id)
|
||||||
|
|
||||||
notif = fake_notifier.VERSIONED_NOTIFICATIONS[0]
|
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):
|
def test_update_with_host_name(self):
|
||||||
notifications.send_update_with_states(self.context, self.instance,
|
notifications.send_update_with_states(self.context, self.instance,
|
||||||
|
|
Loading…
Reference in New Issue