示例#1
0
def get_deployed_pgs_info(cluster_name, pgs_id_list, memlog):
    if len(pgs_id_list) == 0:
        return None

    # Get pgs info
    pgs_list = []
    for pgs_id in pgs_id_list:
        try:
            pgs_list.append(cm.pgs_info(cluster_name, pgs_id)['data'])
        except:
            warn(red("Failed to get pgs info from confmaster. %s" % sys.exc_info()[0]))
            return None

    # Run threads to get memlog and active-role
    pgs_readers = []
    pgs_list_by_ip = reduce(util.classify_by_ip, pgs_list, None)
    for ip, pl in pgs_list_by_ip.items():
        reader = DeployedPgsInfoReader(pl, memlog)
        reader.start()
        pgs_readers.append(reader)

    for r in pgs_readers:
        r.join()

    return pgs_list
示例#2
0
文件: util.py 项目: naver/nbase-arc
def get_deployed_pgs_info(cluster_name, pgs_id_list, memlog):
    if len(pgs_id_list) == 0:
        return None

    # Get pgs info
    pgs_list = []
    for pgs_id in pgs_id_list:
        try:
            pgs_list.append(cm.pgs_info(cluster_name, pgs_id)['data'])
        except:
            warn(red("Failed to get pgs info from confmaster. %s" % sys.exc_info()[0]))
            return None

    # Run threads to get memlog and active-role
    pgs_readers = []
    pgs_list_by_ip = reduce(classify_by_ip, pgs_list, None)
    for ip, pl in pgs_list_by_ip.items():
        reader = DeployedPgsInfoReader(pl, memlog)
        reader.start()
        pgs_readers.append(reader)

    for r in pgs_readers:
        r.join()

    return pgs_list
示例#3
0
def show_pgs(cluster_name, pgs_id):
    pgs = cm.pgs_info(cluster_name, pgs_id)
    if pgs == None:
        warn(red("PGS '%d' doesn't exist." % pgs_id))
        return

    pgs = pgs['data']
    pgs['active_role'] = util.get_role_of_smr(pgs['ip'],
                                              pgs['mgmt_port'],
                                              verbose=False)
    if pgs['active_role'] == 'M':
        pgs['quorum'] = remote.get_quorum(pgs)
    else:
        pgs['quorum'] = ''

    pg = cm.pg_info(cluster_name, pgs['pg_ID'])
    if pg == None:
        warn(red("PG '%d' doesn't exist." % pgs['pg_ID']))
        return

    if pgs['active_role'] == 'M':
        bold = True
    else:
        bold = False

    prefix_pg = PG_FORMAT[:-1] % pg

    # Print
    print yellow(PG_PARTITION[:-1] + PGS_PARTITION)
    print yellow(PG_COLUMN[:-1] + PGS_COLUMN)
    print yellow(PG_PARTITION[:-1] + PGS_PARTITION)

    if pgs['active_role'] != pgs['smr_role']:
        print yellow(prefix_pg[:-1]), magenta(PGS_FORMAT % pgs)
    elif pgs['active_role'] == 'M' or pgs['active_role'] == 'S':
        print yellow(prefix_pg[:-1]), yellow(PGS_FORMAT % pgs, bold)
    else:
        print yellow(prefix_pg[:-1]), red(PGS_FORMAT % pgs)

    print yellow(PG_PARTITION[:-1] + PGS_PARTITION)
示例#4
0
def show_pgs(cluster_name, pgs_id):
    pgs = cm.pgs_info(cluster_name, pgs_id)
    if pgs == None:
        warn(red("PGS '%d' doesn't exist." % pgs_id))
        return

    pgs = pgs['data']
    pgs['active_role'] = util.get_role_of_smr(pgs['ip'], pgs['mgmt_port'], verbose=False)
    if pgs['active_role'] == 'M':
        pgs['quorum'] = remote.get_quorum(pgs)
    else:
        pgs['quorum'] = ''

    pg = cm.pg_info(cluster_name, pgs['pg_ID'])
    if pg == None:
        warn(red("PG '%d' doesn't exist." % pgs['pg_ID']))
        return

    if pgs['active_role'] == 'M': 
        bold = True
    else: 
        bold = False

    prefix_pg = PG_FORMAT[:-1] % pg

    # Print
    print yellow(PG_PARTITION[:-1] + PGS_PARTITION)
    print yellow(PG_COLUMN[:-1] + PGS_COLUMN)
    print yellow(PG_PARTITION[:-1] + PGS_PARTITION)

    if pgs['active_role'] != pgs['smr_role']:
        print yellow(prefix_pg[:-1]), magenta(PGS_FORMAT % pgs)
    elif pgs['active_role'] == 'M' or pgs['active_role'] == 'S':
        print yellow(prefix_pg[:-1]), yellow(PGS_FORMAT % pgs, bold)
    else:
        print yellow(prefix_pg[:-1]), red(PGS_FORMAT % pgs)
            
    print yellow(PG_PARTITION[:-1] + PGS_PARTITION)