diff --git a/devstack/plugin.sh b/devstack/plugin.sh index c12ab189..875e3eae 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -81,7 +81,6 @@ function configure_sahara { # Set configuration to send notifications if is_service_enabled ceilometer; then - iniset $SAHARA_CONF_FILE oslo_messaging_notifications enable "true" iniset $SAHARA_CONF_FILE oslo_messaging_notifications driver "messaging" fi diff --git a/releasenotes/notes/remove_enable_notifications_opt-4c0d46e8e79eb06f.yaml b/releasenotes/notes/remove_enable_notifications_opt-4c0d46e8e79eb06f.yaml new file mode 100644 index 00000000..b7605c45 --- /dev/null +++ b/releasenotes/notes/remove_enable_notifications_opt-4c0d46e8e79eb06f.yaml @@ -0,0 +1,6 @@ +--- +deprecations: + - The 'enable' option of the 'oslo_messaging_notifications' section + has been removed. To enable notifications now please specify the + 'driver' option in the same section. + diff --git a/sahara/tests/unit/base.py b/sahara/tests/unit/base.py index 8099a8e3..84e83160 100644 --- a/sahara/tests/unit/base.py +++ b/sahara/tests/unit/base.py @@ -19,14 +19,15 @@ from oslotest import base from sahara import context from sahara.db import api as db_api from sahara import main +from sahara.utils import rpc class SaharaTestCase(base.BaseTestCase): def setUp(self): super(SaharaTestCase, self).setUp() - self.setup_context() + rpc.setup('all-in-one') def setup_context(self, username="test_user", tenant_id="tenant_1", auth_token="test_auth_token", tenant_name='test_tenant', diff --git a/sahara/tests/unit/utils/notification/test_sender.py b/sahara/tests/unit/utils/notification/test_sender.py index 9e049b41..5f68aea3 100644 --- a/sahara/tests/unit/utils/notification/test_sender.py +++ b/sahara/tests/unit/utils/notification/test_sender.py @@ -27,8 +27,6 @@ class NotificationTest(base.SaharaTestCase): def info(self, *args): self.call = args - self.override_config("enable", True, - group='oslo_messaging_notifications') notifier = FakeNotifier() mock_notify.return_value = notifier ctx = context.ctx() diff --git a/sahara/tests/unit/utils/test_rpc.py b/sahara/tests/unit/utils/test_rpc.py index 846e6453..4cb6c8ac 100644 --- a/sahara/tests/unit/utils/test_rpc.py +++ b/sahara/tests/unit/utils/test_rpc.py @@ -56,10 +56,8 @@ class TestMessagingSetup(base.SaharaTestCase): super(TestMessagingSetup, self).tearDown() def test_set_defaults(self): - self.override_config('enable', True, - group='oslo_messaging_notifications') - messaging.setup('distributed') + self.assertIsNotNone(messaging.MESSAGING_TRANSPORT) self.assertIsNotNone(messaging.NOTIFICATION_TRANSPORT) self.assertIsNotNone(messaging.NOTIFIER) @@ -77,8 +75,6 @@ class TestMessagingSetup(base.SaharaTestCase): self.assertEqual(1, self.notifier_init.call_count) def test_fallback(self): - self.override_config('enable', True, - group='oslo_messaging_notifications') self.get_notify_transport.side_effect = ValueError() messaging.setup('distributed') @@ -100,22 +96,7 @@ class TestMessagingSetup(base.SaharaTestCase): self.get_notify_transport.call_args_list) self.assertEqual(1, self.notifier_init.call_count) - def test_no_messaging(self): - messaging.setup('all-in-one') - - self.assertEqual(0, self.get_notify_transport.call_count) - self.assertEqual(0, self.get_transport.call_count) - def test_only_notifications(self): - self.override_config('enable', True, - group='oslo_messaging_notifications') - messaging.setup('all-in-one') self.assertEqual(0, self.get_transport.call_count) self.assertEqual(1, self.get_notify_transport.call_count) - - def test_only_service_messaging(self): - messaging.setup('distributed') - - self.assertEqual(1, self.get_transport.call_count) - self.assertEqual(0, self.get_notify_transport.call_count) diff --git a/sahara/utils/notification/sender.py b/sahara/utils/notification/sender.py index 61bdebd5..9fa5a949 100644 --- a/sahara/utils/notification/sender.py +++ b/sahara/utils/notification/sender.py @@ -33,13 +33,7 @@ notifier_opts = [ help='Notification level for outgoing notifications'), cfg.StrOpt('publisher_id', deprecated_name='notification_publisher_id', - deprecated_group='DEFAULT', - help='Notification publisher_id for outgoing notifications'), - cfg.BoolOpt('enable', - deprecated_name='enable_notifications', - deprecated_group='DEFAULT', - default=False, - help='Enables sending notifications to Ceilometer') + deprecated_group='DEFAULT') ] notifier_opts_group = 'oslo_messaging_notifications' @@ -56,9 +50,6 @@ def _get_publisher(): def _notify(event_type, body): - if not cfg.CONF.oslo_messaging_notifications.enable: - return - LOG.debug("Notification about cluster is going to be sent. Notification " "type={type}".format(type=event_type)) ctx = context.ctx() diff --git a/sahara/utils/rpc.py b/sahara/utils/rpc.py index 46cb7fda..7cbc14ab 100644 --- a/sahara/utils/rpc.py +++ b/sahara/utils/rpc.py @@ -21,7 +21,6 @@ from oslo_serialization import jsonutils from sahara import context from sahara.i18n import _LE -from sahara.i18n import _LI MESSAGING_TRANSPORT = None @@ -105,37 +104,24 @@ def setup_service_messaging(): def setup_notifications(): global NOTIFICATION_TRANSPORT, NOTIFIER, MESSAGING_TRANSPORT - if not cfg.CONF.oslo_messaging_notifications.enable: - LOG.info(_LI("Notifications disabled")) - return - try: - NOTIFICATION_TRANSPORT = messaging.get_notification_transport( - cfg.CONF, aliases=_ALIASES) + NOTIFICATION_TRANSPORT = \ + messaging.get_notification_transport(cfg.CONF, aliases=_ALIASES) except Exception: LOG.error(_LE("Unable to setup notification transport. Reusing " "service transport for that.")) - setup_service_messaging() - NOTIFICATION_TRANSPORT = MESSAGING_TRANSPORT serializer = ContextSerializer(JsonPayloadSerializer()) - NOTIFIER = messaging.Notifier( - NOTIFICATION_TRANSPORT, serializer=serializer) - LOG.info(_LI("Notifications enabled")) + NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT, + serializer=serializer) def setup(service_name): """Initialise the oslo_messaging layer.""" - global MESSAGING_TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER - if (service_name == 'all-in-one' and - not cfg.CONF.oslo_messaging_notifications.enable): - LOG.info(_LI("Notifications disabled")) - return messaging.set_transport_defaults('sahara') - setup_notifications() if service_name != 'all-in-one': setup_service_messaging()