Merge "Ensure publisher_id is set correctly in notifications"

This commit is contained in:
Jenkins
2015-02-10 04:50:54 +00:00
committed by Gerrit Code Review
4 changed files with 8 additions and 4 deletions

View File

@@ -86,7 +86,6 @@ class ResourceTracker(object):
self.monitors = monitor_handler.choose_monitors(self)
self.ext_resources_handler = \
ext_resources.ResourceHandler(CONF.compute_resources)
self.notifier = rpc.get_notifier()
self.old_resources = {}
self.scheduler_client = scheduler_client.SchedulerClient()

View File

@@ -81,7 +81,8 @@ def notify_decorator(name, fn):
ctxt = common_context.get_context_from_function_and_args(
fn, args, kwarg)
notifier = rpc.get_notifier(publisher_id=(CONF.default_publisher_id
notifier = rpc.get_notifier('api',
publisher_id=(CONF.default_publisher_id
or CONF.host))
method = notifier.getattr(CONF.default_notification_level.lower(),
'info')
@@ -103,7 +104,8 @@ def send_api_fault(url, status, exception):
rpc.get_notifier('api').error(None, 'api.fault', payload)
def send_update(context, old_instance, new_instance, service=None, host=None):
def send_update(context, old_instance, new_instance, service="compute",
host=None):
"""Send compute.instance.update notification to report any changes occurred
in that instance
"""

View File

@@ -140,7 +140,7 @@ def get_server(target, endpoints, serializer=None):
serializer=serializer)
def get_notifier(service=None, host=None, publisher_id=None):
def get_notifier(service, host=None, publisher_id=None):
assert NOTIFIER is not None
if not publisher_id:
publisher_id = "%s.%s" % (service, host or CONF.host)

View File

@@ -180,6 +180,9 @@ class NotificationsTestCase(test.TestCase):
notifications.send_update(self.context, old, self.instance)
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
# service name should default to 'compute'
notif = fake_notifier.NOTIFICATIONS[0]
self.assertEqual('compute.testhost', notif.publisher_id)
def test_send_on_task_change(self):