Merge "Make versioned notifications topics configurable"
This commit is contained in:
commit
e611116e58
@ -99,6 +99,21 @@ Possible values:
|
||||
* both: Both the legacy unversioned and the new versioned notifications are
|
||||
emitted. (Default)
|
||||
|
||||
The list of versioned notifications is visible in
|
||||
http://docs.openstack.org/developer/nova/notifications.html
|
||||
"""),
|
||||
cfg.ListOpt(
|
||||
'versioned_notifications_topics',
|
||||
default=['versioned_notifications'],
|
||||
help="""
|
||||
Specifies the topics for the versioned notifications issued by nova.
|
||||
|
||||
The default value is fine for most deployments and rarely needs to be changed.
|
||||
However, if you have a third-party service that consumes versioned
|
||||
notifications, it might be worth getting a topic for that service.
|
||||
Nova will send a message containing a versioned notification payload to each
|
||||
topic queue in this list.
|
||||
|
||||
The list of versioned notifications is visible in
|
||||
http://docs.openstack.org/developer/nova/notifications.html
|
||||
"""),
|
||||
|
14
nova/rpc.py
14
nova/rpc.py
@ -85,16 +85,18 @@ def init(conf):
|
||||
elif conf.notifications.notification_format == 'both':
|
||||
LEGACY_NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT,
|
||||
serializer=serializer)
|
||||
NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT,
|
||||
serializer=serializer,
|
||||
topics=['versioned_notifications'])
|
||||
NOTIFIER = messaging.Notifier(
|
||||
NOTIFICATION_TRANSPORT,
|
||||
serializer=serializer,
|
||||
topics=conf.notifications.versioned_notifications_topics)
|
||||
else:
|
||||
LEGACY_NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT,
|
||||
serializer=serializer,
|
||||
driver='noop')
|
||||
NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT,
|
||||
serializer=serializer,
|
||||
topics=['versioned_notifications'])
|
||||
NOTIFIER = messaging.Notifier(
|
||||
NOTIFICATION_TRANSPORT,
|
||||
serializer=serializer,
|
||||
topics=conf.notifications.versioned_notifications_topics)
|
||||
|
||||
|
||||
def cleanup():
|
||||
|
@ -29,6 +29,8 @@ class TestNotifier(test.NoDBTestCase):
|
||||
mock_noti_trans,
|
||||
mock_transport):
|
||||
conf = mock.Mock()
|
||||
conf.notifications.versioned_notifications_topics = [
|
||||
'versioned_notifications']
|
||||
|
||||
cases = {
|
||||
'unversioned': [
|
||||
|
@ -85,6 +85,20 @@ class TestRPC(testtools.TestCase):
|
||||
self._test_init(mock_notif, mock_noti_trans, mock_ser,
|
||||
mock_exmods, 'versioned', expected)
|
||||
|
||||
@mock.patch.object(rpc, 'get_allowed_exmods')
|
||||
@mock.patch.object(rpc, 'RequestContextSerializer')
|
||||
@mock.patch.object(messaging, 'get_notification_transport')
|
||||
@mock.patch.object(messaging, 'Notifier')
|
||||
def test_init_versioned_with_custom_topics(self, mock_notif,
|
||||
mock_noti_trans, mock_ser,
|
||||
mock_exmods):
|
||||
expected = [{'driver': 'noop'},
|
||||
{'topics': ['custom_topic1', 'custom_topic2']}]
|
||||
self._test_init(
|
||||
mock_notif, mock_noti_trans, mock_ser, mock_exmods, 'versioned',
|
||||
expected, versioned_notification_topics=['custom_topic1',
|
||||
'custom_topic2'])
|
||||
|
||||
def test_cleanup_transport_null(self):
|
||||
rpc.NOTIFICATION_TRANSPORT = mock.Mock()
|
||||
rpc.LEGACY_NOTIFIER = mock.Mock()
|
||||
@ -304,7 +318,8 @@ class TestRPC(testtools.TestCase):
|
||||
aliases=rpc.TRANSPORT_ALIASES)
|
||||
|
||||
def _test_init(self, mock_notif, mock_noti_trans, mock_ser,
|
||||
mock_exmods, notif_format, expected_driver_topic_kwargs):
|
||||
mock_exmods, notif_format, expected_driver_topic_kwargs,
|
||||
versioned_notification_topics=['versioned_notifications']):
|
||||
legacy_notifier = mock.Mock()
|
||||
notifier = mock.Mock()
|
||||
notif_transport = mock.Mock()
|
||||
@ -314,6 +329,8 @@ class TestRPC(testtools.TestCase):
|
||||
|
||||
conf.transport_url = None
|
||||
conf.notifications.notification_format = notif_format
|
||||
conf.notifications.versioned_notifications_topics = (
|
||||
versioned_notification_topics)
|
||||
mock_exmods.return_value = ['foo']
|
||||
mock_noti_trans.return_value = notif_transport
|
||||
mock_ser.return_value = serializer
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- The versioned_notifications_topic configuration option; This enables one to
|
||||
configure the topics used for versioned notifications.
|
Loading…
Reference in New Issue
Block a user