def record_alarm_change(self, alarm_change):
     """Record alarm change event."""
     alarm_change_dict = hbase_utils.serialize_entry(alarm_change)
     ts = alarm_change.get('timestamp') or datetime.datetime.now()
     rts = hbase_utils.timestamp(ts)
     with self.conn_pool.connection() as conn:
         alarm_history_table = conn.table(self.ALARM_HISTORY_TABLE)
         alarm_history_table.put(
             hbase_utils.prepare_key(alarm_change.get('alarm_id'), rts),
             alarm_change_dict)
示例#2
0
文件: impl_hbase.py 项目: sileht/aodh
 def record_alarm_change(self, alarm_change):
     """Record alarm change event."""
     alarm_change_dict = hbase_utils.serialize_entry(alarm_change)
     ts = alarm_change.get('timestamp') or datetime.datetime.now()
     rts = hbase_utils.timestamp(ts)
     with self.conn_pool.connection() as conn:
         alarm_history_table = conn.table(self.ALARM_HISTORY_TABLE)
         alarm_history_table.put(
             hbase_utils.prepare_key(alarm_change.get('alarm_id'), rts),
             alarm_change_dict)
示例#3
0
def migrate_alarm_history_table(conn, table):
    """Migrate table 'alarm_h' in HBase.

    Change row format from ""%s_%s" % alarm_id, rts,
    to new separator format "%s:%s" % alarm_id, rts
    """
    alarm_h_table = conn.table(table)
    alarm_h_filter = "RowFilter(=, 'regexstring:\\w*_\\d{19}')"
    gen = alarm_h_table.scan(filter=alarm_h_filter)
    for row, data in gen:
        row_parts = row.rsplit('_', 1)
        alarm_h_table.put(hbase_utils.prepare_key(*row_parts), data)
        alarm_h_table.delete(row)
示例#4
0
def migrate_alarm_history_table(conn, table):
    """Migrate table 'alarm_h' in HBase.

    Change row format from ""%s_%s" % alarm_id, rts,
    to new separator format "%s:%s" % alarm_id, rts
    """
    alarm_h_table = conn.table(table)
    alarm_h_filter = "RowFilter(=, 'regexstring:\\w*_\\d{19}')"
    gen = alarm_h_table.scan(filter=alarm_h_filter)
    for row, data in gen:
        row_parts = row.rsplit('_', 1)
        alarm_h_table.put(hbase_utils.prepare_key(*row_parts), data)
        alarm_h_table.delete(row)