Esempio n. 1
0
 def get_alarm_changes(self,
                       alarm_id,
                       on_behalf_of,
                       user=None,
                       project=None,
                       type=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=type,
                                user_id=user,
                                project_id=project)
     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)[0]
             yield models.AlarmChange(**stored_entry)
Esempio n. 2
0
 def get_alarm_changes(
     self,
     alarm_id,
     on_behalf_of,
     user=None,
     project=None,
     type=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=type, user_id=user, project_id=project
     )
     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)[0]
             yield alarm_models.AlarmChange(**stored_entry)