コード例 #1
0
def _get_current_bridge_snapshot(bridge_name,
                                 service_manager,
                                 include_stats=True) -> List[str]:
    table_assignments = service_manager.get_all_table_assignments()
    # Currently, the unit test setup library does not set up the ryu api app.
    # For now, snapshots are created from the flow dump output using ovs and
    # parsed using regex. Once the ryu api works for unit tests, we can
    # directly parse the api response and avoid the regex.
    flows = BridgeTools.get_annotated_flows_for_bridge(
        bridge_name, table_assignments, include_stats=include_stats)
    return [_parse_flow(flow) for flow in flows]
コード例 #2
0
def _display_flows(client, apps=None):
    pipelined_config = load_service_config('pipelined')
    bridge_name = pipelined_config['bridge_name']
    response = client.GetAllTableAssignments(Void())
    table_assignments = {
        table_assignment.app_name:
            Tables(main_table=table_assignment.main_table, type=None,
                   scratch_tables=table_assignment.scratch_tables)
        for table_assignment in response.table_assignments}
    try:
        flows = BridgeTools.get_annotated_flows_for_bridge(
            bridge_name, table_assignments, apps)
    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)