Use "topics" instead of "topic" in Notifier initialization

The "topic" parameter of the __init__method of Notifier has been
deprecated and will be removed. see change[1].

[1] Id89957411aa219cff92fafec2f448c81cb57b3ca

Change-Id: If41b0aa4f9afc90d049063bf509723c3a8295db7
This commit is contained in:
liusheng 2016-06-13 16:20:13 +08:00
parent 726f24334d
commit f99cedf11f
4 changed files with 6 additions and 6 deletions

View File

@ -116,7 +116,7 @@ class NotificationService(service_base.PipelineBasedService):
transport,
driver=cfg.CONF.publisher_notifier.telemetry_driver,
publisher_id=pipe.name,
topic='%s-%s-%s' % (self.NOTIFICATION_IPC, pipe.name, x)))
topics=['%s-%s-%s' % (self.NOTIFICATION_IPC, pipe.name, x)]))
return notifiers
def _get_pipe_manager(self, transport, pipeline_manager):

View File

@ -192,12 +192,12 @@ class NotifierPublisher(MessagingPublisher):
def __init__(self, parsed_url, default_topic):
super(NotifierPublisher, self).__init__(parsed_url)
options = urlparse.parse_qs(parsed_url.query)
topic = options.get('topic', [default_topic])[-1]
topic = options.get('topic', [default_topic])
self.notifier = oslo_messaging.Notifier(
messaging.get_transport(),
driver=cfg.CONF.publisher_notifier.telemetry_driver,
publisher_id='telemetry.publisher.%s' % cfg.CONF.host,
topic=topic,
topics=topic,
retry=self.retry
)

View File

@ -107,13 +107,13 @@ class NotifierOnlyPublisherTest(BasePublisherTestCase):
def test_publish_topic_override(self, notifier):
msg_publisher.SampleNotifierPublisher(
netutils.urlsplit('notifier://?topic=custom_topic'))
notifier.assert_called_with(mock.ANY, topic='custom_topic',
notifier.assert_called_with(mock.ANY, topics=['custom_topic'],
driver=mock.ANY, retry=mock.ANY,
publisher_id=mock.ANY)
msg_publisher.EventNotifierPublisher(
netutils.urlsplit('notifier://?topic=custom_event_topic'))
notifier.assert_called_with(mock.ANY, topic='custom_event_topic',
notifier.assert_called_with(mock.ANY, topics=['custom_event_topic'],
driver=mock.ANY, retry=mock.ANY,
publisher_id=mock.ANY)

View File

@ -48,7 +48,7 @@ def get_notifier(config_file):
messaging.get_transport(),
driver='messagingv2',
publisher_id='telemetry.publisher.test',
topic='metering',
topics=['metering'],
)