コード例 #1
0
ファイル: peer_eventsapi.py プロジェクト: yut148/glusterfs
def action_handle(action, json_output=False):
    out = execute_in_peers("node-" + action)
    column_name = action.upper()
    if action == "status":
        column_name = EVENTSD.upper()

    if not json_output:
        table = PrettyTable(["NODE", "NODE STATUS", column_name + " STATUS"])
        table.align["NODE STATUS"] = "r"
        table.align[column_name + " STATUS"] = "r"

    json_out = []
    if json_output:
        rows_to_json(json_out, column_name.lower() + "_status", out)
    else:
        rows_to_table(table, out)

    return json_out if json_output else table
コード例 #2
0
def action_handle(action):
    out = execute_in_peers("node-" + action)
    column_name = action.upper()
    if action == "status":
        column_name = EVENTSD.upper()

    table = PrettyTable(["NODE", "NODE STATUS", column_name + " STATUS"])
    table.align["NODE STATUS"] = "r"
    table.align[column_name + " STATUS"] = "r"

    for p in out:
        status_col_val = "OK" if p.ok else "NOT OK: {0}".format(p.error)
        if action == "status":
            status_col_val = "DOWN"
            if p.ok:
                status_col_val = p.output

        table.add_row(
            [p.hostname, "UP" if p.node_up else "DOWN", status_col_val])

    print(table)
コード例 #3
0
ファイル: peer_eventsapi.py プロジェクト: fmpnate/glusterfs
def action_handle(action):
    out = execute_in_peers("node-" + action)
    column_name = action.upper()
    if action == "status":
        column_name = EVENTSD.upper()

    table = PrettyTable(["NODE", "NODE STATUS", column_name + " STATUS"])
    table.align["NODE STATUS"] = "r"
    table.align[column_name + " STATUS"] = "r"

    for p in out:
        status_col_val = "OK" if p.ok else "NOT OK: {0}".format(
            p.error)
        if action == "status":
            status_col_val = "DOWN"
            if p.ok:
                status_col_val = p.output

        table.add_row([p.hostname,
                       "UP" if p.node_up else "DOWN",
                       status_col_val])

    print (table)