Move notifications options into oslo_messaging_notifications

In order to make the notifications configuration clearer, let's put
its options into "oslo_messaging_notifications" group just like what
oslo_messaging did.

Closes-Bug: #1536034
Depends-On: I4c9f4de73e7732cb90cb742c94daddf8d2d5e398
Change-Id: I0ba6348ecbc1852e24c9eb7b5f0fa9f3e5922463
This commit is contained in:
Javeme 2016-01-20 16:33:27 +08:00
parent 3a1cd0f6b5
commit 24be6c081d
9 changed files with 33 additions and 17 deletions

View File

@ -81,7 +81,7 @@ function configure_sahara {
# Set configuration to send notifications
if is_service_enabled ceilometer; then
iniset $SAHARA_CONF_FILE DEFAULT enable_notifications "true"
iniset $SAHARA_CONF_FILE oslo_messaging_notifications enable "true"
iniset $SAHARA_CONF_FILE oslo_messaging_notifications driver "messaging"
fi

View File

@ -135,12 +135,14 @@ Notifications configuration
---------------------------
Sahara can be configured to send notifications to the OpenStack
Telemetry module. To enable this functionality the following parameters
should be set in the ``[DEFAULT]`` section of the configuration file:
Telemetry module. To enable this functionality the following parameter
``enable`` should be set in the ``[oslo_messaging_notifications]`` section
of the configuration file:
.. sourcecode:: cfg
enable_notifications = true
[oslo_messaging_notifications]
enable = true
..
And the following parameter ``driver`` should be set in the

View File

@ -0,0 +1,3 @@
---
upgrade:
- Move notifications options into oslo_messaging_notifications

View File

@ -152,7 +152,6 @@ def list_opts():
db_opts,
plugins_base.opts,
topology_helper.opts,
sender.notifier_opts,
keystone.opts,
remote.ssh_opts,
sahara_main.opts,
@ -187,7 +186,8 @@ def list_opts():
(swift_helper.public_endpoint_cert_group.name,
itertools.chain(swift_helper.opts)),
(castellan.castellan_group.name,
itertools.chain(castellan.castellan_opts))
itertools.chain(castellan.castellan_opts)),
(sender.notifier_opts_group, sender.notifier_opts)
]

View File

@ -85,7 +85,8 @@ def setup_common(possible_topdir, service_name):
cinder.validate_config()
castellan.validate_config()
if service_name != 'all-in-one' or cfg.CONF.enable_notifications:
if (service_name != 'all-in-one' or
CONF.oslo_messaging_notifications.enable):
messaging.setup()
plugins_base.setup_plugins()

View File

@ -51,7 +51,8 @@ class NotificationTest(base.SaharaTestCase):
@mock.patch('oslo_messaging.notify.notifier.Notifier.info')
def test_update_cluster(self, mock_notify):
self.override_config("enable_notifications", True)
self.override_config("enable", True,
group='oslo_messaging_notifications')
messaging.setup()
self._make_sample()

View File

@ -30,7 +30,8 @@ class TestMessagingSetup(base.SaharaTestCase):
def setUp(self):
super(TestMessagingSetup, self).setUp()
self.override_config('enable_notifications', True)
self.override_config('enable', True,
group='oslo_messaging_notifications')
def _install(self):
messaging.setup()

View File

@ -24,22 +24,30 @@ SERVICE = 'sahara'
EVENT_TEMPLATE = "sahara.cluster.%s"
notifier_opts = [
cfg.StrOpt('notification_level',
cfg.StrOpt('level',
default='INFO',
deprecated_name='notification_level',
deprecated_group='DEFAULT',
help='Notification level for outgoing notifications'),
cfg.StrOpt('notification_publisher_id',
cfg.StrOpt('publisher_id',
deprecated_name='notification_publisher_id',
deprecated_group='DEFAULT',
help='Notification publisher_id for outgoing notifications'),
cfg.BoolOpt('enable_notifications',
cfg.BoolOpt('enable',
deprecated_name='enable_notifications',
deprecated_group='DEFAULT',
default=False,
help='Enables sending notifications to Ceilometer')
]
notifier_opts_group = 'oslo_messaging_notifications'
CONF = cfg.CONF
CONF.register_opts(notifier_opts)
CONF.register_opts(notifier_opts, group=notifier_opts_group)
def _get_publisher():
publisher_id = CONF.notification_publisher_id
publisher_id = CONF.oslo_messaging_notifications.publisher_id
if publisher_id is None:
publisher_id = SERVICE
return publisher_id
@ -70,14 +78,14 @@ def _body(
def notify(context, cluster_id, cluster_name, cluster_status, ev_type):
"""Sends notification about creating/updating/deleting cluster."""
if not cfg.CONF.enable_notifications:
if not cfg.CONF.oslo_messaging_notifications.enable:
return
LOG.debug("Notification about cluster is going to be sent. Notification "
"type={type}, cluster status = {status}"
.format(type=ev_type, status=cluster_status))
level = CONF.notification_level
level = CONF.oslo_messaging_notifications.level
_notify(context, EVENT_TEMPLATE % ev_type, level,
_body(cluster_id, cluster_name, cluster_status, context.tenant_id,

View File

@ -101,7 +101,7 @@ def setup():
TRANSPORT = messaging.get_transport(cfg.CONF, aliases=_ALIASES)
if not cfg.CONF.enable_notifications:
if not cfg.CONF.oslo_messaging_notifications.enable:
LOG.info(_LI("Notifications disabled"))
return
LOG.info(_LI("Notifications enabled"))