Beispiel #1
0
    def publish_events(self, events):
        if not self.event_driver:
            LOG.error(_LE("Can't publish events to a non-existing dispatcher" "'%s'"), self.dispatcher_name)
            return

        if not isinstance(events, list):
            events = [events]
        # not published externally; skip signing
        self.get_event_dispatcher().record_events([utils.message_from_event(event, secret=None) for event in events])
Beispiel #2
0
    def test_http_dispatcher_bad(self):
        self.CONF.dispatcher_http.event_target = ""
        dispatcher = http.HttpDispatcher(self.CONF)

        event = event_models.Event(uuid.uuid4(), "test", datetime.datetime(2012, 7, 2, 13, 53, 40), [], {})
        event = utils.message_from_event(event, self.CONF.publisher.telemetry_secret)
        with mock.patch("ceilometer.dispatcher.http.LOG", mock.MagicMock()) as LOG:
            dispatcher.record_events(event)
            self.assertTrue(LOG.exception.called)
Beispiel #3
0
 def test_event_conn(self):
     event = event_models.Event(uuid.uuid4(), 'test',
                                datetime.datetime(2012, 7, 2, 13, 53, 40),
                                [], {})
     event = utils.message_from_event(event,
                                      self.CONF.publisher.telemetry_secret)
     with mock.patch.object(self.dispatcher.event_conn,
                            'record_events') as record_events:
         self.dispatcher.record_events(event)
     self.assertEqual(1, len(record_events.call_args_list[0][0][0]))
Beispiel #4
0
 def test_event_conn(self):
     event = event_models.Event(uuid.uuid4(), 'test',
                                datetime.datetime(2012, 7, 2, 13, 53, 40),
                                [], {})
     event = utils.message_from_event(event,
                                      self.CONF.publisher.telemetry_secret)
     with mock.patch.object(self.dispatcher.event_conn,
                            'record_events') as record_events:
         self.dispatcher.record_events(event)
     self.assertEqual(1, len(record_events.call_args_list[0][0][0]))
Beispiel #5
0
    def test_http_dispatcher_share_target(self):
        self.CONF.dispatcher_http.target = "fake"
        dispatcher = http.HttpDispatcher(self.CONF)

        event = event_models.Event(uuid.uuid4(), "test", datetime.datetime(2012, 7, 2, 13, 53, 40), [], {})
        event = utils.message_from_event(event, self.CONF.publisher.telemetry_secret)
        with mock.patch.object(requests, "post") as post:
            dispatcher.record_events(event)

        self.assertEqual("fake", post.call_args[0][0])
Beispiel #6
0
    def publish_events(self, events):
        """Send an event message for publishing

        :param events: events from pipeline after transformation
        """
        ev_list = [utils.message_from_event(
            event, cfg.CONF.publisher.telemetry_secret) for event in events]

        topic = cfg.CONF.publisher_notifier.event_topic
        self.local_queue.append((topic, ev_list))
        self.flush()
Beispiel #7
0
    def publish_events(self, events):
        """Send an event message for publishing

        :param events: events from pipeline after transformation
        """
        ev_list = [utils.message_from_event(
            event, self.conf.publisher.telemetry_secret) for event in events]

        topic = self.conf.publisher_notifier.event_topic
        self.local_queue.append((topic, ev_list))
        self.flush()
Beispiel #8
0
    def publish_events(self, events):
        if not self.event_driver:
            LOG.error("Can't publish events to a non-existing dispatcher "
                      "'%s'", self.dispatcher_name)
            return

        if not isinstance(events, list):
            events = [events]
        # not published externally; skip signing
        self.get_event_dispatcher().record_events([
            utils.message_from_event(event, secret=None) for event in events])
    def setUp(self):
        super(TestEventDispatcherHttp, self).setUp()
        self.CONF = service.prepare_service([], [])

        # repr(uuid.uuid4()) is used in test event creation to avoid an
        # exception being thrown when the uuid is serialized to JSON
        event = event_models.Event(repr(uuid.uuid4()), 'test',
                                   datetime.datetime(2012, 7, 2, 13, 53, 40),
                                   [], {})
        event = utils.message_from_event(event,
                                         self.CONF.publisher.telemetry_secret)
        self.event = event
Beispiel #10
0
    def publish_events(self, events):
        if not self.event_driver:
            LOG.error(_LE("Can't publish events to a non-existing dispatcher"
                          "'%s'"), self.dispatcher_name)
            return

        if not isinstance(events, list):
            events = [events]
        self.get_event_dispatcher().record_events([
            utils.message_from_event(
                event, self.conf.publisher.telemetry_secret)
            for event in events])
Beispiel #11
0
    def publish_events(self, events):
        if not self.event_driver:
            LOG.error(_LE("Can't publish events to a non-existing dispatcher"
                          "'%s'"), self.dispatcher_name)
            return

        if not isinstance(events, list):
            events = [events]
        self.get_event_dispatcher().record_events([
            utils.message_from_event(
                event, cfg.CONF.publisher.telemetry_secret)
            for event in events])
Beispiel #12
0
    def setUp(self):
        super(TestEventDispatcherHttp, self).setUp()
        self.CONF = self.useFixture(fixture_config.Config()).conf

        # repr(uuid.uuid4()) is used in test event creation to avoid an
        # exception being thrown when the uuid is serialized to JSON
        event = event_models.Event(repr(uuid.uuid4()), 'test',
                                   datetime.datetime(2012, 7, 2, 13, 53, 40),
                                   [], {})
        event = utils.message_from_event(event,
                                         self.CONF.publisher.telemetry_secret)
        self.event = event
Beispiel #13
0
    def publish_events(self, context, events):
        """Send an event message for publishing

        :param context: Execution context from the service or RPC call
        :param events: events from pipeline after transformation
        """
        ev_list = [utils.message_from_event(
            event, cfg.CONF.publisher.telemetry_secret) for event in events]

        topic = cfg.CONF.publisher_notifier.event_topic
        self.local_queue.append((context, topic, ev_list))
        self.flush()
Beispiel #14
0
    def test_http_dispatcher_bad(self):
        self.CONF.dispatcher_http.event_target = ''
        dispatcher = http.HttpDispatcher(self.CONF)

        event = event_models.Event(uuid.uuid4(), 'test',
                                   datetime.datetime(2012, 7, 2, 13, 53, 40),
                                   [], {})
        event = utils.message_from_event(event,
                                         self.CONF.publisher.telemetry_secret)
        with mock.patch('ceilometer.dispatcher.http.LOG',
                        mock.MagicMock()) as LOG:
            dispatcher.record_events(event)
            self.assertTrue(LOG.exception.called)
Beispiel #15
0
    def test_http_dispatcher_share_target(self):
        self.CONF.dispatcher_http.target = 'fake'
        dispatcher = http.HttpDispatcher(self.CONF)

        event = event_models.Event(uuid.uuid4(), 'test',
                                   datetime.datetime(2012, 7, 2, 13, 53, 40),
                                   [], {})
        event = utils.message_from_event(event,
                                         self.CONF.publisher.telemetry_secret)
        with mock.patch.object(requests, 'post') as post:
            dispatcher.record_events(event)

        self.assertEqual('fake', post.call_args[0][0])
Beispiel #16
0
    def test_http_dispatcher(self):
        self.CONF.dispatcher_http.event_target = 'fake'
        dispatcher = http.HttpDispatcher(self.CONF)

        event = event_models.Event(uuid.uuid4(), 'test',
                                   datetime.datetime(2012, 7, 2, 13, 53, 40),
                                   [], {})
        event = utils.message_from_event(event,
                                         self.CONF.publisher.telemetry_secret)

        with mock.patch.object(requests, 'post') as post:
            dispatcher.record_events(event)

        self.assertEqual(1, post.call_count)
Beispiel #17
0
    def publish_events(self, context, events):
        """Send an event message for kafka broker.

        :param context: Execution context from the service or RPC call
        :param events: events from pipeline after transformation
        """
        events_list = [utils.message_from_event(
            event, cfg.CONF.publisher.telemetry_secret) for event in events]

        self.local_queue.append(events_list)

        try:
            self._check_kafka_connection()
        except Exception as e:
            raise e

        self.flush()
Beispiel #18
0
    def publish_events(self, context, events):
        """Send an event message for kafka broker.

        :param context: Execution context from the service or RPC call
        :param events: events from pipeline after transformation
        """
        events_list = [utils.message_from_event(
            event, cfg.CONF.publisher.telemetry_secret) for event in events]

        self.local_queue.append(events_list)

        try:
            self._check_kafka_connection()
        except Exception as e:
            raise e

        self.flush()
Beispiel #19
0
 def process_notification(self, notification):
     try:
         event = self.event_converter.to_event(notification)
         if event is not None:
             if self.requeue:
                 for notifier in self.transporter:
                     notifier.sample(
                         self.ctxt.to_dict(),
                         event_type='pipeline.event',
                         payload=[utils.message_from_event(
                             event, cfg.CONF.publisher.telemetry_secret)])
             else:
                 with self.transporter.publisher(self.ctxt) as p:
                     p(event)
     except Exception:
         if not cfg.CONF.notification.ack_on_event_error:
             return oslo.messaging.NotificationResult.REQUEUE
         raise
     return oslo.messaging.NotificationResult.HANDLED
Beispiel #20
0
 def serializer(data):
     return publisher_utils.message_from_event(
         data, cfg.CONF.publisher.telemetry_secret)
Beispiel #21
0
 def serializer(self, data):
     return publisher_utils.message_from_event(
         data, self.conf.publisher.telemetry_secret)
Beispiel #22
0
 def serializer(data):
     return publisher_utils.message_from_event(
         data, cfg.CONF.publisher.telemetry_secret)
Beispiel #23
0
 def serializer(self, data):
     return publisher_utils.message_from_event(
         data, self.conf.publisher.telemetry_secret)