Exemple #1
0
 def get_alarm_changes(self,
                       alarm_id,
                       on_behalf_of,
                       user=None,
                       project=None,
                       alarm_type=None,
                       severity=None,
                       start_timestamp=None,
                       start_timestamp_op=None,
                       end_timestamp=None,
                       end_timestamp_op=None):
     q = hbase_utils.make_query(alarm_id=alarm_id,
                                on_behalf_of=on_behalf_of,
                                type=alarm_type,
                                user_id=user,
                                project_id=project,
                                severity=severity)
     start_row, end_row = hbase_utils.make_timestamp_query(
         hbase_utils.make_general_rowkey_scan,
         start=start_timestamp,
         start_op=start_timestamp_op,
         end=end_timestamp,
         end_op=end_timestamp_op,
         bounds_only=True,
         some_id=alarm_id)
     with self.conn_pool.connection() as conn:
         alarm_history_table = conn.table(self.ALARM_HISTORY_TABLE)
         gen = alarm_history_table.scan(filter=q,
                                        row_start=start_row,
                                        row_stop=end_row)
         for ignored, data in gen:
             stored_entry = hbase_utils.deserialize_entry(data)
             yield models.AlarmChange(**stored_entry)
Exemple #2
0
 def _row_to_alarm_change_model(row):
     return alarm_api_models.AlarmChange(event_id=row.event_id,
                                         alarm_id=row.alarm_id,
                                         type=row.type,
                                         detail=row.detail,
                                         user_id=row.user_id,
                                         project_id=row.project_id,
                                         on_behalf_of=row.on_behalf_of,
                                         timestamp=row.timestamp)
Exemple #3
0
    def _retrieve_alarm_changes(self, query_filter, orderby, limit):
        if limit is not None:
            alarms_history = self.db.alarm_history.find(query_filter,
                                                        limit=limit,
                                                        sort=orderby)
        else:
            alarms_history = self.db.alarm_history.find(query_filter,
                                                        sort=orderby)

        for alarm_history in alarms_history:
            ah = {}
            ah.update(alarm_history)
            del ah['_id']
            yield models.AlarmChange(**ah)