Esempio n. 1
0
    def get_one(self, message_id):
        """Return a single event with the given message id.

        :param message_id: Message ID of the Event to be returned
        """
        rbac.enforce("events:show", pecan.request)
        filters = _build_rbac_query_filters()
        t_filter = filters['t_filter']
        admin_proj = filters['admin_proj']
        event_filter = storage.EventFilter(traits_filter=t_filter,
                                           admin_proj=admin_proj,
                                           message_id=message_id)
        events = [event for event
                  in pecan.request.conn.get_events(event_filter)]
        if not events:
            raise base.EntityNotFound(_("Event"), message_id)

        if len(events) > 1:
            LOG.error(("More than one event with "
                       "id %s returned from storage driver"), message_id)

        event = events[0]

        return Event(message_id=event.message_id,
                     event_type=event.event_type,
                     generated=event.generated,
                     traits=event.traits,
                     raw=event.raw)
Esempio n. 2
0
    def get_one(self, message_id):
        """Return a single event with the given message id.

        :param message_id: Message ID of the Event to be returned
        """
        rbac.enforce("events:show", pecan.request)
        filters = _build_rbac_query_filters()
        t_filter = filters['t_filter']
        admin_proj = filters['admin_proj']
        event_filter = storage.EventFilter(traits_filter=t_filter,
                                           admin_proj=admin_proj,
                                           message_id=message_id)
        events = [event for event
                  in pecan.request.conn.get_events(event_filter)]
        if not events:
            raise base.EntityNotFound(_("Event"), message_id)

        if len(events) > 1:
            LOG.error(("More than one event with "
                       "id %s returned from storage driver"), message_id)

        event = events[0]

        return Event(message_id=event.message_id,
                     event_type=event.event_type,
                     generated=event.generated,
                     traits=event.traits,
                     raw=event.raw)
Esempio n. 3
0
    def get_all(self, q=None, limit=None, sort=None, marker=None):
        """Return all events matching the query filters.

        :param q: Filter arguments for which Events to return
        :param limit: Maximum number of samples to be returned.
        :param sort: A pair of sort key and sort direction combined with ":"
        :param marker: The pagination query marker, message id of the last
                       item viewed
        """
        rbac.enforce("events:index", pecan.request)
        q = q or []
        event_filter = _event_query_to_event_filter(q)
        pagination = v2_utils.set_pagination_options(
            sort, limit, marker, event_models.Event)
        return [Event(message_id=event.message_id,
                      event_type=event.event_type,
                      generated=event.generated,
                      traits=event.traits,
                      raw=event.raw)
                for event in
                pecan.request.conn.get_events(event_filter, pagination)]
Esempio n. 4
0
    def get_all(self, q=None, limit=None, sort=None, marker=None):
        """Return all events matching the query filters.

        :param q: Filter arguments for which Events to return
        :param limit: Maximum number of samples to be returned.
        :param sort: A pair of sort key and sort direction combined with ":"
        :param marker: The pagination query marker, message id of the last
                       item viewed
        """
        rbac.enforce("events:index", pecan.request)
        q = q or []
        event_filter = _event_query_to_event_filter(q)
        pagination = v2_utils.set_pagination_options(
            sort, limit, marker, event_models.Event)
        return [Event(message_id=event.message_id,
                      event_type=event.event_type,
                      generated=event.generated,
                      traits=event.traits,
                      raw=event.raw)
                for event in
                pecan.request.conn.get_events(event_filter, pagination)]