def get_terminal_moid(e164='', ip=''): if e164: with get_redis_client() as client: return client.hget('terminal:%s:baseinfo' % e164, 'moid') if ip: with get_redis_client() as client: return client.hget('terminal:ip2moid', ip)
def ev_machine_room_sfu_info(machine_room_moid, used_sfu, remainder_sfu): key = 'machine_room:' + machine_room_moid + ':info' with get_redis_client() as client: client.hmset(key, { 'used_sfu': used_sfu, 'remainder_sfu': remainder_sfu })
def ev_machine_room_res_info(machine_room_moid, total_port, remainder_port, remainder_tra): key = 'machine_room:' + machine_room_moid + ':info' with get_redis_client() as client: client.hmset( key, { 'total_port': total_port, 'remainder_port': remainder_port, 'remainder_tra': remainder_tra })
def ev_rms_mp_info(service_type, moid, total_h264, used_h264, total_h265, used_h265): suffix = 'mg' if service_type == 0 else 'g_mg' key = 'domain:' + moid + ':' + suffix with get_redis_client() as client: client.hmset( key, { 'total_h264': total_h264, 'used_h264': used_h264, 'total_h265': total_h265, 'used_h265': used_h265 })
def get_types(): with get_redis_client() as client: return client.smembers('p_server:type'), client.smembers( 'l_server:type')
def flush_redis_db(): with get_redis_client() as client: client.flushall()
def get_collector_online_server(collectorid): with get_redis_client() as client: return client.hgetall('collector:%s:online' % collectorid)
def add_collector(collectorid, devid): with get_redis_client() as client: client.sadd('collector', collectorid) client.hset('collector:%s:info' % collectorid, 'p_server_moid', devid)
def get_collectors(): with get_redis_client() as client: return client.smembers('collector')
def ev_aps_add_mt_info(moid, operator_type): with get_redis_client() as client: client.hset('terminal:' + moid + ':baseinfo', 'operator_type', operator_type)
def get_warning_server_limit(moid, resource): with get_redis_client() as client: limit = client.hget('warning:limit:' + moid, resource) if limit is None: limit = common.SERVER_RESOURCE_LIMIT[resource] return limit
def get_collector_p_server_moid(collectorid): with get_redis_client() as client: key = 'collector:%s:info' % collectorid return client.hget(key, 'p_server_moid')
def ev_rms_vmr_info(moid, mapping): key = 'domain:' + moid + ':vmr' with get_redis_client() as client: client.hmset(key, mapping)
def ev_logical_server_info(moid, version): with get_redis_client() as client: client.hset('l_server:' + moid + ':info', 'version', version)
def nms_is_first_import(): with get_redis_client() as client: r = client.get('nms_first_import') return r != common.IMPORT_FLAG
def get_warning_global_limit(resource): with get_redis_client() as client: return client.hget('warning:limit:global', resource)
def set_nms_first_import(): with get_redis_client() as client: client.set('nms_first_import', common.IMPORT_FLAG)
def get_stop_warning(moid): with get_redis_client() as client: return client.sismember('warning:stop', moid)
def ev_srv_system_uptime(moid, uptime): with get_redis_client() as client: client.hset('p_server:' + moid + ':info', 'uptime', uptime)