コード例 #1
0
def display_raw_flows(_unused, args):
    pipelined_config = load_service_config('pipelined')
    bridge_name = pipelined_config['bridge_name']
    try:
        flows = BridgeTools.get_flows_for_bridge(bridge_name, args.table_num)
    except subprocess.CalledProcessError as e:
        if e.returncode == errno.EPERM:
            print("Need to run as root to dump flows")
        return

    for flow in flows:
        print(flow)
コード例 #2
0
def display_flows(_unused, args):
    pipelined_config = load_service_config('pipelined')
    bridge_name = pipelined_config['bridge_name']
    flows = []
    try:
        flows = BridgeTools.get_flows_for_bridge(bridge_name, args.table_num)
    except subprocess.CalledProcessError as e:
        if e.returncode == errno.EPERM:
            print("Need to run as root to dump flows")
        return

    # Parse the flows and print it decoding note
    for flow in flows[1:]:
        flow = flow.replace('00', '').replace('.', '')
        # If there is a note, decode it.
        note_regex = r'note:([\d\.a-fA-F]*)'
        flow = re.sub(
            note_regex, lambda match: 'note:' + str(
                binascii.unhexlify(match.group().replace('note:', ''))), flow)
        print(flow)
コード例 #3
0
def display_flows(_unused, args):
    pipelined_config = load_service_config('pipelined')
    bridge_name = pipelined_config['bridge_name']
    flows = []
    try:
        flows = BridgeTools.get_flows_for_bridge(bridge_name, args.table_num)
    except subprocess.CalledProcessError as e:
        if (e.returncode == errno.EPERM):
            print("Need to run as root to dump flows")
        return

    # Parse the flows and print it decoding note
    for flow in flows[1:]:
        flow = flow.replace('00', '').replace('.', '')
        # If there is a note, decode it otherwise just print the flow
        if 'note:' in flow:
            prefix = flow.split('note:')
            print(prefix[0] + "note:" + str(binascii.unhexlify(prefix[1])))
        else:
            print(flow)