Exemplo n.º 1
0
    def _setup_endpoint(self, publishers):
        ev_pipeline_mgr = self._setup_pipeline(publishers)
        self.endpoint = event_endpoint.EventsNotificationEndpoint(
            ev_pipeline_mgr)

        self.endpoint.event_converter = mock.MagicMock()
        self.endpoint.event_converter.to_event.return_value = mock.MagicMock(
            event_type='test.test')
Exemplo n.º 2
0
    def start(self):
        super(NotificationService, self).start()
        # FIXME(sileht): endpoint use notification_topics option
        # and it should not because this is oslo.messaging option
        # not a ceilometer, until we have a something to get
        # the notification_topics in an other way
        # we must create a transport to ensure the option have
        # beeen registered by oslo.messaging
        transport = messaging.get_transport()
        messaging.get_notifier(transport, '')

        self.pipeline_manager = pipeline.setup_pipeline()

        self.notification_manager = self._get_notifications_manager(
            self.pipeline_manager)
        if not list(self.notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = cfg.CONF.notification.ack_on_event_error

        endpoints = []
        if cfg.CONF.notification.store_events:
            endpoints = [event_endpoint.EventsNotificationEndpoint()]

        targets = []
        for ext in self.notification_manager:
            handler = ext.obj
            LOG.debug(
                _('Event types from %(name)s: %(type)s'
                  ' (ack_on_error=%(error)s)') % {
                      'name': ext.name,
                      'type': ', '.join(handler.event_types),
                      'error': ack_on_error
                  })
            # NOTE(gordc): this could be a set check but oslo.messaging issue
            # https://bugs.launchpad.net/oslo.messaging/+bug/1398511
            # This ensures we don't create multiple duplicate consumers.
            for new_tar in handler.get_targets(cfg.CONF):
                if new_tar not in targets:
                    targets.append(new_tar)
            endpoints.append(handler)

        urls = cfg.CONF.notification.messaging_urls or [None]
        self.listeners = []
        for url in urls:
            transport = messaging.get_transport(url)
            listener = messaging.get_notification_listener(
                transport, targets, endpoints)
            listener.start()
            self.listeners.append(listener)

        # Add a dummy thread to have wait() working
        self.tg.add_timer(604800, lambda: None)
Exemplo n.º 3
0
    def setUp(self):
        super(TestEventEndpoint, self).setUp()
        self.CONF = self.useFixture(fixture_config.Config()).conf
        self.CONF([])
        self.CONF.set_override("connection", "log://", group='database')
        self.CONF.set_override("store_events", True, group="notification")
        self.setup_messaging(self.CONF)

        self.mock_pm = mock.MagicMock()
        self.endpoint = event_endpoint.EventsNotificationEndpoint(self.mock_pm)
        self.endpoint.event_converter = mock.MagicMock()
        self.endpoint.event_converter.to_event.return_value = mock.MagicMock(
            event_type='test.test')
Exemplo n.º 4
0
    def setUp(self):
        super(TestEventEndpoint, self).setUp()
        self.CONF = self.useFixture(fixture_config.Config()).conf
        self.CONF([])
        self.CONF.set_override("connection", "log://", group='database')
        self.CONF.set_override("store_events", True, group="notification")
        self.setup_messaging(self.CONF)

        self.mock_dispatcher = mock.MagicMock()
        self.endpoint = event_endpoint.EventsNotificationEndpoint()
        (self.endpoint.dispatcher_manager) = (
            extension.ExtensionManager.make_test_instance([
                extension.Extension('test', None, None, self.mock_dispatcher)
            ]))
        self.endpoint.event_converter = mock.MagicMock()
        self.endpoint.event_converter.to_event.return_value = mock.MagicMock(
            event_type='test.test')
Exemplo n.º 5
0
    def _configure_main_queue_listeners(self, pipe_manager,
                                        event_pipe_manager):
        notification_manager = self._get_notifications_manager(pipe_manager)
        if not list(notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = cfg.CONF.notification.ack_on_event_error

        endpoints = []
        if cfg.CONF.notification.store_events:
            endpoints.append(
                event_endpoint.EventsNotificationEndpoint(event_pipe_manager))

        targets = []
        for ext in notification_manager:
            handler = ext.obj
            if (cfg.CONF.notification.disable_non_metric_meters
                    and isinstance(handler, base.NonMetricNotificationBase)):
                continue
            LOG.debug(
                'Event types from %(name)s: %(type)s'
                ' (ack_on_error=%(error)s)', {
                    'name': ext.name,
                    'type': ', '.join(handler.event_types),
                    'error': ack_on_error
                })
            # NOTE(gordc): this could be a set check but oslo_messaging issue
            # https://bugs.launchpad.net/oslo.messaging/+bug/1398511
            # This ensures we don't create multiple duplicate consumers.
            for new_tar in handler.get_targets(cfg.CONF):
                if new_tar not in targets:
                    targets.append(new_tar)
            endpoints.append(handler)

        urls = cfg.CONF.notification.messaging_urls or [None]
        for url in urls:
            transport = messaging.get_transport(url)
            listener = messaging.get_batch_notification_listener(
                transport,
                targets,
                endpoints,
                batch_size=cfg.CONF.notification.batch_size,
                batch_timeout=cfg.CONF.notification.batch_timeout)
            listener.start()
            self.listeners.append(listener)
Exemplo n.º 6
0
    def _configure_main_queue_listeners(self, pipe_manager,
                                        event_pipe_manager):
        notification_manager = self._get_notifications_manager(pipe_manager)
        if not list(notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = self.conf.notification.ack_on_event_error

        endpoints = []
        endpoints.append(
            event_endpoint.EventsNotificationEndpoint(event_pipe_manager))

        targets = []
        for ext in notification_manager:
            handler = ext.obj
            LOG.debug(
                'Event types from %(name)s: %(type)s'
                ' (ack_on_error=%(error)s)', {
                    'name': ext.name,
                    'type': ', '.join(handler.event_types),
                    'error': ack_on_error
                })
            # NOTE(gordc): this could be a set check but oslo_messaging issue
            # https://bugs.launchpad.net/oslo.messaging/+bug/1398511
            # This ensures we don't create multiple duplicate consumers.
            for new_tar in handler.get_targets(self.conf):
                if new_tar not in targets:
                    targets.append(new_tar)
            endpoints.append(handler)

        urls = self.conf.notification.messaging_urls or [None]
        for url in urls:
            transport = messaging.get_transport(self.conf, url)
            # NOTE(gordc): ignore batching as we want pull
            # to maintain sequencing as much as possible.
            listener = messaging.get_batch_notification_listener(
                transport, targets, endpoints)
            listener.start()
            self.listeners.append(listener)
Exemplo n.º 7
0
    def start(self):
        super(NotificationService, self).start()
        self.pipeline_manager = pipeline.setup_pipeline()

        self.notification_manager = self._get_notifications_manager(
            self.pipeline_manager)
        if not list(self.notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = cfg.CONF.notification.ack_on_event_error

        endpoints = []
        if cfg.CONF.notification.store_events:
            endpoints = [event_endpoint.EventsNotificationEndpoint()]

        targets = []
        for ext in self.notification_manager:
            handler = ext.obj
            LOG.debug(
                _('Event types from %(name)s: %(type)s'
                  ' (ack_on_error=%(error)s)') % {
                      'name': ext.name,
                      'type': ', '.join(handler.event_types),
                      'error': ack_on_error
                  })
            targets.extend(handler.get_targets(cfg.CONF))
            endpoints.append(handler)

        urls = cfg.CONF.notification.messaging_urls or [None]
        self.listeners = []
        for url in urls:
            listener = messaging.get_notification_listener(
                targets, endpoints, url)
            listener.start()
            self.listeners.append(listener)

        # Add a dummy thread to have wait() working
        self.tg.add_timer(604800, lambda: None)