コード例 #1
0
ファイル: p4dbg.py プロジェクト: MMfSDT/basic-p4-topology
def main():
    deprecated_args = ["json"]
    for a in deprecated_args:
        if getattr(args, a) is not None:
            print "Command line option '--{}' is deprecated".format(a),
            print "and will be ignored"

    client = utils.thrift_connect_standard(args.thrift_ip, args.thrift_port)
    info = client.bm_mgmt_get_info()
    socket_addr = info.debugger_socket
    if socket_addr is None:
        print "The debugger is not enabled on the switch"
        sys.exit(1)
    if args.socket is not None:
        socket_addr = args.socket
    else:
        print "'--socket' not provided, using", socket_addr,
        print "(obtained from switch)"

    c = DebuggerAPI(socket_addr, standard_client=client)
    try:
        c.attach()
        c.cmdloop()
    except KeyboardInterrupt:
        if c.attached:
            c.say_bye()
    except Exception as e:
        print "Unknow error, detaching and exiting"
        print e
        if c.attached:
            c.say_bye()
コード例 #2
0
def main():
    deprecated_args = ["socket", "json"]
    for a in deprecated_args:
        if getattr(args, a) is not None:
            print "Command line option --{} is deprecated".format(a),
            print "and will be ignored"

    client = utils.thrift_connect_standard(args.thrift_ip, args.thrift_port)
    info = client.bm_mgmt_get_info()
    socket_addr = info.debugger_socket
    if socket_addr is None:
        print "The debugger is not enabled on the switch"
        sys.exit(1)

    c = DebuggerAPI(socket_addr, standard_client=client)
    try:
        c.attach()
        c.cmdloop()
    except KeyboardInterrupt:
        if c.attached:
            c.say_bye()
    except Exception as e:
        print "Unknow error, detaching and exiting"
        print e
        if c.attached:
            c.say_bye()
コード例 #3
0
ファイル: p4dbg.py プロジェクト: asilha/aclapolli-bmv2
def main():
    deprecated_args = []
    for a in deprecated_args:
        if getattr(args, a) is not None:
            print("Command line option '--{}' is deprecated".format(a),
                  end=' ')
            print("and will be ignored")

    client = None
    socket_addr = None

    if args.socket is not None:
        socket_addr = args.socket

    if not args.json or not args.socket:
        try:
            import bmpy_utils as utils
        except:
            print(
                "When '--json' or '--socket' is not provided, the debugger needs bmpy_utils"
            )
            print(
                "bmpy_utils is not available when building bmv2 without Thrift support"
            )
            sys.exit(1)
        client = utils.thrift_connect_standard(args.thrift_ip,
                                               args.thrift_port)
        info = client.bm_mgmt_get_info()
        if info.debugger_socket is None:
            print("The debugger is not enabled on the switch")
            sys.exit(1)
        if args.socket is None:
            socket_addr = info.debugger_socket
            print("'--socket' not provided, using", socket_addr, end=' ')
            print("(obtained from switch)")

    json_cfg = None
    if args.json is not None:
        with open(args.json, 'r') as f:
            json_cfg = f.read()

    c = DebuggerAPI(socket_addr, standard_client=client, json_cfg=json_cfg)
    try:
        c.attach()
        c.cmdloop()
    except KeyboardInterrupt:
        if c.attached:
            c.say_bye()
    except Exception as e:
        print("Unknow error, detaching and exiting")
        print(e)
        if c.attached:
            c.say_bye()
        raise
コード例 #4
0
def main():
    deprecated_args = ["socket", "json"]
    for a in deprecated_args:
        if getattr(args, a) is not None:
            print "Command line option --{} is deprecated".format(a),
            print "and will be ignored"

    client = utils.thrift_connect_standard(args.thrift_ip, args.thrift_port)
    info = client.bm_mgmt_get_info()
    socket_addr = info.elogger_socket
    if socket_addr is None:
        print "The event logger is not enabled on the switch,",
        print "run with --nanolog <ip addr>"
        sys.exit(1)

    recv_msgs(socket_addr, client)
コード例 #5
0
def main():
    deprecated_args = []
    for a in deprecated_args:
        if getattr(args, a) is not None:
            print("Command line option '--{}' is deprecated".format(a),
                  end=' ')
            print("and will be ignored")

    client = None
    socket_addr = None
    json_cfg = None

    if args.socket is not None:
        socket_addr = args.socket

    if not args.json or not args.socket:
        try:
            import bmpy_utils as utils
        except:
            print(
                "When '--json' or '--socket' is not provided, the client needs bmpy_utils"
            )
            print(
                "bmpy_utils is not available when building bmv2 without Thrift support"
            )
            sys.exit(1)
        client = utils.thrift_connect_standard(args.thrift_ip,
                                               args.thrift_port)
        info = client.bm_mgmt_get_info()
        if info.elogger_socket is None:
            print("The event logger is not enabled on the switch,", end=' ')
            print("run with '--nanolog <addr>'")
            sys.exit(1)
        if args.socket is None:
            socket_addr = info.elogger_socket
            print("'--socket' not provided, using", socket_addr, end=' ')
            print("(obtained from switch)")

        if args.json is None:
            json_cfg = utils.get_json_config(standard_client=client)

    if args.json is not None:
        with open(args.json, 'r') as f:
            json_cfg = f.read()
    name_map.load_names(json_cfg)

    recv_msgs(socket_addr, client)
コード例 #6
0
def main():
    deprecated_args = ["json"]
    for a in deprecated_args:
        if getattr(args, a) is not None:
            print "Command line option '--{}' is deprecated".format(a),
            print "and will be ignored"

    client = utils.thrift_connect_standard(args.thrift_ip, args.thrift_port)
    info = client.bm_mgmt_get_info()
    socket_addr = info.elogger_socket
    if socket_addr is None:
        print "The event logger is not enabled on the switch,",
        print "run with '--nanolog <ip addr>'"
        sys.exit(1)
    if args.socket is not None:
        socket_addr = args.socket
    else:
        print "'--socket' not provided, using", socket_addr,
        print "(obtained from switch)"

    recv_msgs(socket_addr, client)
コード例 #7
0
def main():
    client = utils.thrift_connect_standard(args.thrift_ip, args.thrift_port)
    swinfo = client.bm_mgmt_get_info()
    socket = swinfo.notifications_socket

    sub = nnpy.Socket(nnpy.AF_SP, nnpy.SUB)
    sub.setsockopt(nnpy.SUB, nnpy.SUB_SUBSCRIBE, 'LEA')
    sub.connect(socket)

    while True:
        msg = sub.recv()

        print "LOOP DETECTED: digest received, see details:"

        h = HDRMsg(client, msg)
        d = h.data()
        print h

        for i in range(0, h.num_samples):
            m = UnrollerMsg(d)
            d = m.data()
            print "\t", m

        h.confirm()