Merge "Remove enable_notifications option"

This commit is contained in:
Jenkins 2016-11-10 20:36:15 +00:00 committed by Gerrit Code Review
commit a18c8a897a
7 changed files with 14 additions and 52 deletions

View File

@ -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

View File

@ -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.

View File

@ -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',

View File

@ -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()

View File

@ -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)

View File

@ -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()

View File

@ -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()