Merge "pluggable notification agent"

This commit is contained in:
Zuul 2017-11-21 01:33:36 +00:00 committed by Gerrit Code Review
commit bd583fe13b
4 changed files with 45 additions and 4 deletions

@ -24,9 +24,10 @@ from futurist import periodics
from oslo_config import cfg
from oslo_log import log
import oslo_messaging
from stevedore import extension
from stevedore import named
from tooz import coordination
from ceilometer.i18n import _
from ceilometer import messaging
from ceilometer import utils
@ -75,7 +76,11 @@ OPTS = [
deprecated_group='DEFAULT',
deprecated_name='notification_workers',
help='Number of workers for notification service, '
'default value is 1.')
'default value is 1.'),
cfg.MultiStrOpt('pipelines',
default=['meter', 'event'],
help="Select which pipeline managers to enable to "
" generate data"),
]
@ -139,6 +144,9 @@ class NotificationService(cotyledon.Service):
for exchange in
set(self.conf.notification.notification_control_exchanges)]
def _log_missing_pipeline(self, names):
LOG.error(_('Could not load the following pipelines: %s'), names)
def run(self):
# Delay startup so workers are jittered
time.sleep(self.startup_delay)
@ -146,8 +154,10 @@ class NotificationService(cotyledon.Service):
super(NotificationService, self).run()
self.coord_lock = threading.Lock()
self.managers = [ext.obj for ext in extension.ExtensionManager(
namespace='ceilometer.notification.pipeline', invoke_on_load=True,
self.managers = [ext.obj for ext in named.NamedExtensionManager(
namespace='ceilometer.notification.pipeline',
names=self.conf.notification.pipelines, invoke_on_load=True,
on_missing_entrypoints_callback=self._log_missing_pipeline,
invoke_args=(self.conf,
self.conf.notification.workload_partitioning))]

@ -121,6 +121,23 @@ class TestNotification(BaseNotificationTest):
self.assertEqual(1, len(mock_listener.call_args_list[0][0][1]))
self.assertEqual(1, len(self.srv.listeners))
def test_select_pipelines(self):
self.CONF.set_override('pipelines', ['event'], group='notification')
self.srv.run()
self.addCleanup(self.srv.terminate)
self.assertEqual(1, len(self.srv.managers))
self.assertEqual(1, len(self.srv.listeners[0].dispatcher.endpoints))
@mock.patch('ceilometer.notification.LOG')
def test_select_pipelines_missing(self, logger):
self.CONF.set_override('pipelines', ['meter', 'event', 'bad'],
group='notification')
self.srv.run()
self.addCleanup(self.srv.terminate)
self.assertEqual(2, len(self.srv.managers))
logger.error.assert_called_with(
'Could not load the following pipelines: %s', set(['bad']))
class BaseRealNotification(BaseNotificationTest):
def setup_pipeline(self, counter_names):

@ -39,6 +39,10 @@ The notification agent is responsible for consuming notifications. This
component is responsible for consuming from the message bus and transforming
notifications into events and measurement samples.
By default, the notification agent is configured to build both events and
samples. To enable selective data models, set the required pipelines using
`pipelines` option under the `[notification]` section.
Additionally, the notification agent is responsible for all data processing
such as transformations and publishing. After processing, the data is sent
to any supported publisher target such as gnocchi or panko. These services

@ -0,0 +1,10 @@
---
features:
- |
The notification-agent can now be configured to either build meters or
events. By default, the notification agent will continue to load both
pipelines and build both data models. To selectively enable a pipeline,
configure the `pipelines` option under the `[notification]` section.
Addition pipelines can be created following the format used by existing
pipelines.