Example #1
0
    def test_setup_events_default_config(self):

        def mock_exists(path):
            return False

        def mock_get_config_file():
            return None

        with mock.patch('ceilometer.event.converter.get_config_file',
                        mock_get_config_file):

            oslo_cfg.CONF.set_override('drop_unmatched_notifications',
                                       False, group='event')

            with mock.patch('os.path.exists', mock_exists):
                c = converter.setup_events(self.fake_plugin_mgr)
            self.assertIsInstance(c, converter.NotificationEventsConverter)
            self.assertEqual(1, len(c.definitions))
            self.assertTrue(c.definitions[0].is_catchall)

            oslo_cfg.CONF.set_override('drop_unmatched_notifications',
                                       True, group='event')

            with mock.patch('os.path.exists', mock_exists):
                c = converter.setup_events(self.fake_plugin_mgr)
            self.assertIsInstance(c, converter.NotificationEventsConverter)
            self.assertEqual(0, len(c.definitions))
Example #2
0
    def test_setup_events_default_config(self):
        self.CONF.set_override("definitions_cfg_file", "/not/existing/file", group="event")
        self.CONF.set_override("drop_unmatched_notifications", False, group="event")

        c = converter.setup_events(self.CONF, self.fake_plugin_mgr)
        self.assertIsInstance(c, converter.NotificationEventsConverter)
        self.assertEqual(1, len(c.definitions))
        self.assertTrue(c.definitions[0].is_catchall)

        self.CONF.set_override("drop_unmatched_notifications", True, group="event")

        c = converter.setup_events(self.CONF, self.fake_plugin_mgr)
        self.assertIsInstance(c, converter.NotificationEventsConverter)
        self.assertEqual(0, len(c.definitions))
    def test_setup_events_default_config(self):
        self.CONF.set_override('drop_unmatched_notifications',
                               False, group='event')

        c = converter.setup_events(self.fake_plugin_mgr)
        self.assertIsInstance(c, converter.NotificationEventsConverter)
        self.assertEqual(1, len(c.definitions))
        self.assertTrue(c.definitions[0].is_catchall)

        self.CONF.set_override('drop_unmatched_notifications',
                               True, group='event')

        c = converter.setup_events(self.fake_plugin_mgr)
        self.assertIsInstance(c, converter.NotificationEventsConverter)
        self.assertEqual(0, len(c.definitions))
Example #4
0
 def __init__(self, manager):
     super(EventsNotificationEndpoint, self).__init__()
     LOG.debug("Loading event definitions")
     self.event_converter = event_converter.setup_events(
         manager.conf, extension.ExtensionManager(namespace="ceilometer.event.trait_plugin")
     )
     self.manager = manager
Example #5
0
 def __init__(self):
     super(EventsNotificationEndpoint, self).__init__()
     self.dispatcher_manager = dispatcher.load_dispatcher_manager()
     LOG.debug(_('Loading event definitions'))
     self.event_converter = event_converter.setup_events(
         extension.ExtensionManager(
             namespace='ceilometer.event.trait_plugin'))
Example #6
0
 def __init__(self, conf, publisher):
     super(EventEndpoint, self).__init__(conf, publisher)
     LOG.debug('Loading event definitions')
     self.event_converter = converter.setup_events(
         conf,
         extension.ExtensionManager(
             namespace='ceilometer.event.trait_plugin'))
Example #7
0
 def __init__(self):
     super(EventsNotificationEndpoint, self).__init__()
     self.dispatcher_manager = dispatcher.load_dispatcher_manager()
     LOG.debug(_('Loading event definitions'))
     self.event_converter = event_converter.setup_events(
         extension.ExtensionManager(
             namespace='ceilometer.event.trait_plugin'))
Example #8
0
    def test_setup_events_default_config(self):
        self.CONF.set_override('drop_unmatched_notifications',
                               False,
                               group='event')

        c = converter.setup_events(self.fake_plugin_mgr)
        self.assertIsInstance(c, converter.NotificationEventsConverter)
        self.assertEqual(1, len(c.definitions))
        self.assertTrue(c.definitions[0].is_catchall)

        self.CONF.set_override('drop_unmatched_notifications',
                               True,
                               group='event')

        c = converter.setup_events(self.fake_plugin_mgr)
        self.assertIsInstance(c, converter.NotificationEventsConverter)
        self.assertEqual(0, len(c.definitions))
Example #9
0
 def __init__(self, manager):
     super(EventsNotificationEndpoint, self).__init__()
     LOG.debug(_('Loading event definitions'))
     self.ctxt = context.get_admin_context()
     self.event_converter = event_converter.setup_events(
         extension.ExtensionManager(
             namespace='ceilometer.event.trait_plugin'))
     self.manager = manager
Example #10
0
 def __init__(self, manager):
     super(EventsNotificationEndpoint, self).__init__()
     LOG.debug('Loading event definitions')
     self.ctxt = context.get_admin_context()
     self.event_converter = event_converter.setup_events(
         extension.ExtensionManager(
             namespace='ceilometer.event.trait_plugin'))
     self.manager = manager
Example #11
0
 def __init__(self, transporter):
     super(EventsNotificationEndpoint, self).__init__()
     LOG.debug(_('Loading event definitions'))
     self.ctxt = context.get_admin_context()
     self.event_converter = event_converter.setup_events(
         extension.ExtensionManager(
             namespace='ceilometer.event.trait_plugin'))
     self.transporter = transporter
     # NOTE(gordc): if no publisher, this isn't a PipelineManager and
     # data should be requeued.
     self.requeue = not hasattr(transporter, 'publisher')
Example #12
0
 def __init__(self, transporter):
     super(EventsNotificationEndpoint, self).__init__()
     LOG.debug(_('Loading event definitions'))
     self.ctxt = context.get_admin_context()
     self.event_converter = event_converter.setup_events(
         extension.ExtensionManager(
             namespace='ceilometer.event.trait_plugin'))
     self.transporter = transporter
     # NOTE(gordc): if no publisher, this isn't a PipelineManager and
     # data should be requeued.
     self.requeue = not hasattr(transporter, 'publisher')
Example #13
0
    def test_setup_events_load_config_in_code_tree(self, mocked_log):
        self.CONF.set_override('definitions_cfg_file',
                               '/not/existing/file', group='event')
        self.CONF.set_override('drop_unmatched_notifications',
                               False, group='event')

        c = converter.setup_events(self.CONF, self.fake_plugin_mgr)
        self.assertIsInstance(c, converter.NotificationEventsConverter)
        log_called_args = mocked_log.debug.call_args_list
        self.assertEqual(
            'No Definitions configuration file found! Using default config.',
            log_called_args[0][0][0])
        self.assertTrue(log_called_args[1][0][0].startswith(
            'Loading definitions configuration file:'))
Example #14
0
    def test_setup_events_load_config_in_code_tree(self, mocked_log):
        self.CONF.set_override('definitions_cfg_file',
                               '/not/existing/file', group='event')
        self.CONF.set_override('drop_unmatched_notifications',
                               False, group='event')

        c = converter.setup_events(self.CONF, self.fake_plugin_mgr)
        self.assertIsInstance(c, converter.NotificationEventsConverter)
        log_called_args = mocked_log.debug.call_args_list
        self.assertEqual(
            'No Definitions configuration file found! Using default config.',
            log_called_args[0][0][0])
        self.assertTrue(log_called_args[1][0][0].startswith(
            'Loading definitions configuration file:'))
Example #15
0
    def initialize_service_hook(self, service):
        """Consumers must be declared before consume_thread start."""
        self.pipeline_manager = pipeline.setup_pipeline(
            transformer.TransformerExtensionManager("ceilometer.transformer")
        )

        LOG.debug(_("Loading event definitions"))
        self.event_converter = event_converter.setup_events(
            extension.ExtensionManager(namespace="ceilometer.event.trait_plugin")
        )

        self.notification_manager = extension.ExtensionManager(
            namespace=self.NOTIFICATION_NAMESPACE, invoke_on_load=True
        )

        if not list(self.notification_manager):
            LOG.warning(_("Failed to load any notification handlers for %s"), self.NOTIFICATION_NAMESPACE)
        self.notification_manager.map(self._setup_subscription)
Example #16
0
    def initialize_service_hook(self, service):
        '''Consumers must be declared before consume_thread start.'''
        self.pipeline_manager = pipeline.setup_pipeline()

        LOG.debug(_('Loading event definitions'))
        self.event_converter = event_converter.setup_events(
            extension.ExtensionManager(
                namespace='ceilometer.event.trait_plugin'))

        self.notification_manager = \
            extension.ExtensionManager(
                namespace=self.NOTIFICATION_NAMESPACE,
                invoke_on_load=True,
            )

        if not list(self.notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)
        self.notification_manager.map(self._setup_subscription)
Example #17
0
if output_file is None:
    out = sys.stdout
else:
    out = open(output_file, 'w')

if input_file is None:
    notifications = json.load(sys.stdin)
else:
    with open(input_file, 'r') as f:
        notifications = json.load(f)

out.write("Definitions file: %s\n" % config_file)
out.write("Notifications tested: %s\n" % len(notifications))

event_converter = converter.setup_events(
    extension.ExtensionManager(
        namespace='ceilometer.event.trait_plugin'))

for notification in notifications:
    event = event_converter.to_event(notification)
    if event is None:
        out.write("Dropped notification: %s\n" %
                  notification['message_id'])
        continue
    out.write("Event: %s at %s\n" % (event.event_name, event.generated))
    for trait in event.traits:
        dtype = TYPES[trait.dtype]
        out.write("    Trait: name: %s, type: %s, value: %s\n" % (
            trait.name, dtype, trait.value))
Example #18
0
 def __init__(self):
     LOG.debug(_('Loading event definitions'))
     self.event_converter = event_converter.setup_events(
         extension.ExtensionManager(
             namespace='ceilometer.event.trait_plugin'))