Beispiel #1
0
def analyze_inventory(args):
    config.get_models(
        args, {"odl_inventory_nodes", "odl_inventory_nodes_operational"})

    if args.store == "config":
        nodes = config.gmodels.odl_inventory_nodes.get_clist_by_key()
        print("Inventory Config:")
    else:
        print("Inventory Operational:")
        nodes = config.gmodels.odl_inventory_nodes_operational.get_clist_by_key(
        )
    node = nodes.get("openflow:" + args.nodeid)
    if node is None:
        print("node: {} was not found".format("openflow:" + args.nodeid))
        return
    tables = node.get(Nodes.NODE_TABLE)
    # groups = node.get(Nodes.NODE_GROUP)
    flow_list = []
    print("Flows: ")
    for table in tables:
        for flow in table.get('flow', []):
            if not args.ifname or args.ifname in utils.nstr(
                    flow.get('flow-name')):
                flow_dict = {
                    'table': table['id'],
                    'id': flow['id'],
                    'name': flow.get('flow-name'),
                    'flow': flow
                }
                flow_list.append(flow_dict)
    flowlist = sorted(flow_list, key=lambda x: x['table'])
    for flow in flowlist:
        print("Table: {}".format(flow['table']))
        print("FlowId: {}, FlowName: {} ".format(flow['id'], 'FlowName:',
                                                 flow.get('name')))
Beispiel #2
0
def analyze_inventory(args):
    config.get_models(args, {
        "odl_inventory_nodes",
        "odl_inventory_nodes_operational"})

    if args.store == "config":
        nodes = config.gmodels.odl_inventory_nodes.get_clist_by_key()
        print("Inventory Config:")
    else:
        print("Inventory Operational:")
        nodes = config.gmodels.odl_inventory_nodes_operational.get_clist_by_key()
    node = nodes.get("openflow:" + args.nodeid)
    if node is None:
        print("node: {} was not found".format("openflow:" + args.nodeid))
        return
    tables = node.get(Nodes.NODE_TABLE)
    # groups = node.get(Nodes.NODE_GROUP)
    flow_list = []
    print("Flows: ")
    for table in tables:
        for flow in table.get('flow', []):
            if not args.ifname or args.ifname in utils.nstr(flow.get('flow-name')):
                flow_dict = {'table': table['id'], 'id': flow['id'], 'name': flow.get('flow-name'), 'flow': flow}
                flow_list.append(flow_dict)
    flowlist = sorted(flow_list, key=lambda x: x['table'])
    for flow in flowlist:
        print("Table: {}".format(flow['table']))
        print("FlowId: {}, FlowName: {} ".format(flow['id'], 'FlowName:', flow.get('name')))