Esempio n. 1
0
def show_groups(args):
    config.get_models(args, {"odl_inventory_nodes"})
    of_nodes = config.gmodels.odl_inventory_nodes.get_clist_by_key()
    groups = config.gmodels.odl_inventory_nodes.get_groups(of_nodes)
    for dpn in groups:
        for group_key in groups[dpn]:
            print("Dpn: {}, ID: {}, Group: {}".format(dpn, group_key, utils.format_json(args, groups[dpn][group_key])))
Esempio n. 2
0
def show_stale_flows(args, sort_by='table'):
    config.get_models(
        args,
        {
            "elan_elan_instances",
            "elan_elan_interfaces",
            "ietf_interfaces_interfaces",
            "ietf_interfaces_interfaces_state",
            "interface_service_bindings_service_bindings",
            "l3vpn_vpn_interfaces",
            # "mip_mac",
            "neutron_neutron",
            "odl_fib_fib_entries",
            "odl_interface_meta_if_index_interface_map",
            "odl_l3vpn_vpn_instance_to_vpn_id",
            "odl_inventory_nodes_config",
            "odl_inventory_nodes_operational"
        })
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping(
    )
    nports = config.gmodels.neutron_neutron.get_ports_by_key()

    for flow in utils.sort(get_stale_flows(['ifm', 'acl', 'elan', 'l3vpn']),
                           sort_by):
        host = compute_map.get(flow.get('dpnid'), flow.get('dpnid'))
        ip_list = get_ips_for_iface(nports, flow.get('ifname'))
        if ip_list:
            flow['iface-ips'] = ip_list
        result = "Table:{}, Host:{}, FlowId:{}{}".format(
            flow['table'], host, flow['id'], utils.show_optionals(flow))
        print(result)
Esempio n. 3
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')))
Esempio n. 4
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')))
Esempio n. 5
0
def show_stale_flows(args, sort_by='table'):
    config.get_models(args, {
        "elan_elan_instances",
        "elan_elan_interfaces",
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "interface_service_bindings_service_bindings",
        "l3vpn_vpn_interfaces",
        # "mip_mac",
        "neutron_neutron",
        "odl_fib_fib_entries",
        "odl_interface_meta_if_index_interface_map",
        "odl_l3vpn_vpn_instance_to_vpn_id",
        "odl_inventory_nodes",
        "odl_inventory_nodes_operational"})
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping()
    nports = config.gmodels.neutron_neutron.get_objects_by_key(obj=Neutron.PORTS)
    modules = [args.modules] if args.modules else tbls.get_all_modules()
    for flow in utils.sort(get_stale_flows(modules), sort_by):
        host = compute_map.get(flow.get('dpnid'), flow.get('dpnid'))
        ip_list = get_ips_for_iface(nports, flow.get('ifname'))
        if ip_list:
            flow['iface-ips'] = ip_list
        flow['host'] = host
        result = utils.show_all(flow)
        print(result)
        # path = get_data_path('flows', flow)
        # print("http://192.168.2.32:8383/restconf/config/{}".format(path))
        if not args.metaonly:
            print("Flow: ", utils.format_json(args, flow_parser.parse_flow(flow['flow'])))
Esempio n. 6
0
def dump_flows(args, modules=None, sort_by='table_id', filter_by=None):
    config.get_models(
        args, {
            "neutron_neutron", "odl_inventory_nodes_operational",
            "network_topology_network_topology_operational"
        })
    filter_by = filter_by if filter_by else []
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping(
    )
    node_map = config.gmodels.network_topology_network_topology_operational.get_dpn_host_mapping(
    )
    nports = config.gmodels.neutron_neutron.get_objects_by_key(
        obj=Neutron.PORTS)
    for flow in sort(get_all_flows(args, modules, filter_by), sort_by):
        dpnid = flow.pdata.get('dpnid')
        host = compute_map.get(dpnid)
        if not host:
            host = node_map.get(int(dpnid))
        ip_list = get_ips_for_iface(nports, flow.pdata.get('ifname'))
        if ip_list:
            flow.pdata['iface-ips'] = ip_list
        flow.pdata['host'] = host
        result = show_all(flow)
        print(result)
        if not args.metaonly:
            print("Flow: {}".format(
                utils.format_json(args,
                                  inv_flow_parser.parse_flow(flow.rdata))))
Esempio n. 7
0
def show_learned_mac_flows(args):
    config.get_models(args, {
        "elan_elan_instances",
        "elan_elan_interfaces",
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "interface_service_bindings_service_bindings",
        "l3vpn_vpn_interfaces",
        # "mip_mac",
        "neutron_neutron",
        "odl_fib_fib_entries",
        "odl_interface_meta_if_index_interface_map",
        "odl_l3vpn_vpn_instance_to_vpn_id",
        "odl_inventory_nodes",
        "odl_inventory_nodes_operational"})
    # nports = config.gmodels.neutron_neutron.get_ports_by_key(key='mac-address')
    nports = config.gmodels.neutron_neutron.get_objects_by_key(obj=Neutron.PORTS, key='mac-address')
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping()

    flows = utils.sort(get_all_flows(args, ['elan']), 'table')
    for flow_info in flows:
        flow = flow_info.get('flow')
        dpnid = flow_info.get('dpnid')
        host = compute_map.get(dpnid, dpnid)
        if ((flow_info.get('table') == 50 and flow.get('idle-timeout') == 300
             and not nports.get(flow_info.get('src-mac')))
            or (flow_info.get('table') == 51 and not nports.get(flow_info.get('dst-mac')))):  # NOQA

            result = 'Table:{}, Host:{}, FlowId:{}{}'.format(
                flow_info.get('table'), host, flow.get('id'),
                utils.show_optionals(flow_info))
            print(result)
            print("Flow: {}".format(utils.format_json(args, flow_parser.parse_flow(flow))))
Esempio n. 8
0
def analyze_interface(args):
    config.get_models(
        args,
        {"ietf_interfaces_interfaces", "ietf_interfaces_interfaces_state"})
    ifaces = config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
    ifstates = config.gmodels.ietf_interfaces_interfaces_state.get_clist_by_key(
    )

    if not args.ifname:
        print_keys(args, ifaces, ifstates)
        return

    ifname = args.ifname
    iface, ifstate, port, tunnel, tunState = by_ifname(args, ifname, ifstates,
                                                       ifaces)
    print("InterfaceConfig: \n{}".format(utils.format_json(args, iface)))
    print("InterfaceState: \n{}".format(utils.format_json(args, ifstate)))
    if port:
        print("NeutronPort: \n{}".format(utils.format_json(args, port)))
        # analyze_neutron_port(port, iface, ifstate)
        return
    if tunnel:
        print("Tunnel: \n{}".format(utils.format_json(args, tunnel)))
    if tunState:
        print("TunState: \n{}".format(utils.format_json(args, tunState)))
Esempio n. 9
0
def show_stale_flows(args, sort_by='table'):
    config.get_models(args, {
        "elan_elan_instances",
        "elan_elan_interfaces",
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "interface_service_bindings_service_bindings",
        "l3vpn_vpn_interfaces",
        # "mip_mac",
        "neutron_neutron",
        "odl_fib_fib_entries",
        "odl_interface_meta_if_index_interface_map",
        "odl_l3vpn_vpn_instance_to_vpn_id",
        "odl_inventory_nodes",
        "odl_inventory_nodes_operational"})
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping()
    nports = config.gmodels.neutron_neutron.get_objects_by_key(obj=Neutron.PORTS)
    modules = [args.modules] if args.modules else tbls.get_all_modules()
    for flow in utils.sort(get_stale_flows(modules), sort_by):
        host = compute_map.get(flow.get('dpnid'), flow.get('dpnid'))
        ip_list = get_ips_for_iface(nports, flow.get('ifname'))
        if ip_list:
            flow['iface-ips'] = ip_list
        result = "Table:{}, Host:{}, FlowId:{}{}".format(flow['table'], host, flow['id'], utils.show_optionals(flow))
        print(result)
        # path = get_data_path('flows', flow)
        # print("http://192.168.2.32:8383/restconf/config/{}".format(path))
        if not args.metaonly:
            print("Flow: ", utils.format_json(args, flow_parser.parse_flow(flow['flow'])))
Esempio n. 10
0
def show_learned_mac_flows(args):
    config.get_models(args, {
        "elan_elan_instances",
        "elan_elan_interfaces",
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "interface_service_bindings_service_bindings",
        "l3vpn_vpn_interfaces",
        # "mip_mac",
        "neutron_neutron",
        "odl_fib_fib_entries",
        "odl_interface_meta_if_index_interface_map",
        "odl_l3vpn_vpn_instance_to_vpn_id",
        "odl_inventory_nodes",
        "odl_inventory_nodes_operational"})
    # nports = config.gmodels.neutron_neutron.get_ports_by_key(key='mac-address')
    nports = config.gmodels.neutron_neutron.get_objects_by_key(obj=Neutron.PORTS, key='mac-address')
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping()

    flows = utils.sort(get_all_flows(args, ['elan']), 'table')
    for flow_info in flows:
        flow = flow_info.get('flow')
        dpnid = flow_info.get('dpnid')
        host = compute_map.get(dpnid, dpnid)
        if ((flow_info.get('table') == 50 and flow.get('idle-timeout') == 300
             and not nports.get(flow_info.get('src-mac')))
            or (flow_info.get('table') == 51 and not nports.get(flow_info.get('dst-mac')))):  # NOQA

            flow['host'] = host
            result = utils.show_all(flow_info)
            print(result)
            print("Flow: {}".format(utils.format_json(args, flow_parser.parse_flow(flow))))
Esempio n. 11
0
def show_stale_bindings(args):
    config.get_models(args, {"ietf_interfaces_interfaces", "interface_service_bindings_service_bindings"})
    stale_ids, bindings = flows.get_stale_bindings(args)
    for iface_id in sorted(stale_ids):
        for binding in bindings[iface_id].values():
            # if binding.get('bound-services'):
            path = get_data_path('bindings', binding)
            print(utils.format_json(args, bindings[iface_id]))
            print('http://{}:{}/restconf/config/{}'.format(args.ip, args.port, path))
Esempio n. 12
0
def show_groups(args):
    config.get_models(args, {"odl_inventory_nodes_config"})
    of_nodes = config.gmodels.odl_inventory_nodes_config.get_clist_by_key()
    groups = config.gmodels.odl_inventory_nodes_config.get_groups(of_nodes)
    for dpn in groups:
        for group_key in groups[dpn]:
            print("Dpn: {}, ID: {}, Group: {}".format(
                dpn, group_key, utils.format_json(args,
                                                  groups[dpn][group_key])))
Esempio n. 13
0
def show_tables(args):
    config.get_models(args, {"odl_inventory_nodes_config"})
    of_nodes = config.gmodels.odl_inventory_nodes_config.get_clist_by_key()

    tables = set()
    for node in of_nodes.values():
        for table in node[Nodes.NODE_TABLE]:
            if table.get('flow'):
                tables.add(table['id'])
    print(list(tables))
Esempio n. 14
0
def show_all_idpools(args):
    config.get_models(args, {"id_manager_id_pools"})
    pools = config.gmodels.id_manager_id_pools.get_clist_by_key()
    print("\nid-pools\n")
    if not args.short:
        print(utils.format_json(args, pools))
    else:
        print("pool-name                          ")
        print("-----------------------------------")
        for k, v in sorted(pools.items()):
            print("{:30}".format(v.get("pool-name")))
Esempio n. 15
0
def get_all_models(args):
    config.get_models(args, {
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "itm_transport_zones",
        "itm_state_tunnel_list",
        "itm_state_tunnels_state",
        "itm_state_dpn_endpoints",
        "itm_state_dpn_teps_state",
        "network_topology_network_topology",
        "network_topology_network_topology_operational"})
Esempio n. 16
0
def show_all_idpools(args):
    config.get_models(args, {"id_manager_id_pools"})
    pools = config.gmodels.id_manager_id_pools.get_clist_by_key()
    print("\nid-pools\n")
    if not args.short:
        print(utils.format_json(args, pools))
    else:
        print("pool-name                          ")
        print("-----------------------------------")
        for k, v in sorted(pools.items()):
            print("{:30}".format(v.get("pool-name")))
Esempio n. 17
0
def show_all_flows(args):
    config.get_models(
        args, {
            "elan_elan_instances", "elan_elan_interfaces",
            "ietf_interfaces_interfaces", "ietf_interfaces_interfaces_state",
            "interface_service_bindings_service_bindings",
            "l3vpn_vpn_interfaces", "neutron_neutron", "odl_fib_fib_entries",
            "odl_interface_meta_if_index_interface_map",
            "odl_l3vpn_vpn_instance_to_vpn_id", "odl_inventory_nodes_config",
            "odl_inventory_nodes_operational"
        })
    dump_flows(args, modules=['all'])
Esempio n. 18
0
def show_neutron(args):
    objs = []
    config.get_models(args, {"neutron_neutron"})
    if args.object == "all":
        objs = Neutron.ALL_OBJECTS
    else:
        objs.append(args.object)

    for obj in objs:
        print("\nneutron {}:\n".format(obj))
        data = config.gmodels.neutron_neutron.get_objects_by_key(obj=obj)
        print_neutron(args, obj, data)
Esempio n. 19
0
def show_neutron(args):
    objs = []
    config.get_models(args, {"neutron_neutron"})
    if args.object == "all":
        objs = Neutron.ALL_OBJECTS
    else:
        objs.append(args.object)

    for obj in objs:
        print("\nneutron {}:\n".format(obj))
        data = config.gmodels.neutron_neutron.get_objects_by_key(obj=obj)
        print_neutron(args, obj, data)
Esempio n. 20
0
def show_tables(args):
    config.get_models(args, {"odl_inventory_nodes"})
    of_nodes = config.gmodels.odl_inventory_nodes.get_clist_by_key()

    tableset = set()
    for node in of_nodes.values():
        for table in node[Nodes.NODE_TABLE]:
            if table.get('flow'):
                tableset.add(table['id'])
    result = ''
    for table in (sorted(tableset)):
        result = '{:3}:{} '.format(table, tables.get_table_name(table))
        print(result)
Esempio n. 21
0
def show_tables(args):
    config.get_models(args, {"odl_inventory_nodes"})
    of_nodes = config.gmodels.odl_inventory_nodes.get_clist_by_key()

    tableset = set()
    for node in of_nodes.values():
        for table in node[Nodes.NODE_TABLE]:
            if table.get('flow'):
                tableset.add(table['id'])
    result = ''
    for table in (sorted(tableset)):
        result = '{:3}:{} '.format(table, tables.get_table_name(table))
        print(result)
Esempio n. 22
0
def show_stale_bindings(args):
    config.get_models(
        args, {
            "ietf_interfaces_interfaces",
            "interface_service_bindings_service_bindings"
        })
    stale_ids, bindings = flows.get_stale_bindings(args)
    for iface_id in sorted(stale_ids):
        for binding in bindings[iface_id].values():
            # if binding.get('bound-services'):
            path = get_data_path('bindings', binding)
            print(utils.format_json(args, bindings[iface_id]))
            print('http://{}:{}/restconf/config/{}'.format(
                args.ip, args.port, path))
Esempio n. 23
0
def show_dup_flows(args):
    config.get_models(
        args,
        {
            "elan_elan_instances",
            "elan_elan_interfaces",
            "ietf_interfaces_interfaces",
            "ietf_interfaces_interfaces_state",
            "interface_service_bindings_service_bindings",
            "l3vpn_vpn_interfaces",
            # "mip_mac",
            "odl_fib_fib_entries",
            "odl_interface_meta_if_index_interface_map",
            "odl_l3vpn_vpn_instance_to_vpn_id",
            "odl_inventory_nodes",
            "odl_inventory_nodes_operational"
        })
    mmac = {}  # config.gmodels.mip_mac.get_entries_by_key()
    einsts = config.gmodels.elan_elan_instances.get_clist_by_key()
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping(
    )

    flows = utils.sort(get_all_flows(args, ['elan']), 'table')
    matches = collections.defaultdict(list)
    for flow in flows:
        dup_key = get_key_for_dup_detect(args, flow)
        if dup_key:
            if matches and matches.get(dup_key):
                matches[dup_key].append(flow)
            else:
                matches[dup_key].append(flow)
    for k, v in matches.iteritems():
        if len(v) > 1:
            dpnid = k.split(':')[0]
            host = compute_map.get(dpnid, dpnid)
            result = "Host:{}, FlowCount:{}, MatchKey:{}, ElanTag:{}".format(
                host, len(v), k, v[0].get('elan-tag'))
            print(result)
            for idx, flow in enumerate(v):
                result = "Duplicate"
                mac_addr = flow.get('dst-mac')
                if mac_addr and mmac.get(mac_addr):
                    result = is_correct_elan_flow(flow, mmac.get(mac_addr),
                                                  einsts, host)
                print("    {} Flow-{}:{}".format(
                    result, idx,
                    utils.format_json(args,
                                      flow_parser.parse_flow(
                                          flow.get('flow')))))
Esempio n. 24
0
def show_elan_flows(args):
    config.get_models(args, {
        "elan_elan_instances",
        "elan_elan_interfaces",
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "odl_interface_meta_if_index_interface_map",
        "odl_inventory_nodes",
        "odl_inventory_nodes_operational"})
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping()
    for flow in utils.sort(get_all_flows(args, modules=['elan']), 'id'):
        host = compute_map.get(flow.get('dpnid'), flow.get('dpnid'))
        result = "MacHost:{}{}, Table:{}, FlowId:{}, {}, Flow:{}".format(
            flow['id'][-17:], host, flow['table'], flow['id'], utils.show_optionals(flow),
            utils.format_json(args, flow_parser.parse_flow(flow['flow'])))
        print(result)
Esempio n. 25
0
def show_neutron(args):
    objs = []
    config.get_models(args, {"neutron_neutron"})
    if args.object == "all":
        objs = Neutron.ALL_OBJECTS
    elif args.object == "unused-security-groups":
        print_unused_neutron_resource(args)
    else:
        objs.append(args.object)

    for obj in objs:
        print("\nneutron {}:\n".format(obj))
        data = config.gmodels.neutron_neutron.get_objects_by_key(obj=obj)
        print_neutron(args, obj, data)
    if objs:
        print_neutron_resource_count(args, objs)
Esempio n. 26
0
def show_elan_flows(args):
    config.get_models(args, {
        "elan_elan_instances",
        "elan_elan_interfaces",
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "odl_interface_meta_if_index_interface_map",
        "odl_inventory_nodes",
        "odl_inventory_nodes_operational"})
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping()
    for flow in utils.sort(get_all_flows(args, modules=['elan']), 'id'):
        host = compute_map.get(flow.get('dpnid'), flow.get('dpnid'))
        flow['host'] = host
        result = "{}, Flow:{}".format(utils.show_all(flow),
                                      utils.format_json(args, flow_parser.parse_flow(flow['flow'])))
        print(result)
Esempio n. 27
0
def show_all_flows(args):
    config.get_models(args, {
        "elan_elan_instances",
        "elan_elan_interfaces",
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "interface_service_bindings_service_bindings",
        "l3vpn_vpn_interfaces",
        "neutron_neutron",
        "odl_fib_fib_entries",
        "odl_interface_meta_if_index_interface_map",
        "odl_l3vpn_vpn_instance_to_vpn_id",
        "odl_inventory_nodes",
        "odl_inventory_nodes_operational"})
    modules = [args.modules] if args.modules else tbls.get_all_modules()
    dump_flows(args, modules)
Esempio n. 28
0
def by_ifname(args, ifname, ifstates, ifaces):
    config.get_models(args, {"itm_state_tunnels_state", "neutron_neutron"})
    ifstate = ifstates.get(ifname)
    iface = ifaces.get(ifname)
    port = None
    tunnel = None
    tun_state = None
    if iface and iface.get('type') == constants.IFTYPE_VLAN:
        ports = config.gmodels.neutron_neutron.get_ports_by_key()
        port = ports.get(ifname)
    elif iface and iface.get('type') == constants.IFTYPE_TUNNEL:
        tun_states = config.gmodels.itm_state_tunnels_state.get_clist_by_key()
        tun_state = tun_states.get(ifname)
    else:
        print("UNSUPPORTED IfType")
    return iface, ifstate, port, tunnel, tun_state
Esempio n. 29
0
def by_ifname(args, ifname, ifstates, ifaces):
    config.get_models(args, {"itm_state_tunnels_state", "neutron_neutron"})
    ifstate = ifstates.get(ifname)
    iface = ifaces.get(ifname)
    port = None
    tunnel = None
    tun_state = None
    if is_vlan_port(iface):
        ports = config.gmodels.neutron_neutron.get_objects_by_key(
            obj=Neutron.PORTS)
        port = ports.get(ifname)
    elif is_tunnel_port(iface):
        tun_states = config.gmodels.itm_state_tunnels_state.get_clist_by_key()
        tun_state = tun_states.get(ifname)
    else:
        print("UNSUPPORTED IfType")
    return iface, ifstate, port, tunnel, tun_state
Esempio n. 30
0
def get_vteps(args, tz_name="default-transport-zone"):
    config.get_models(args, {
        "itm_transport_zones"})
    t_zones = config.gmodels.itm_transport_zones.get_clist_by_key()
    t_zone = t_zones.get(tz_name)
    if not t_zone or (not t_zone.get('subnets') and not t_zone.get('vteps')):
        return None
    if t_zone.get('vteps'):
        # From ODL Sodium version onwards subnets are removed from.
        # transport_zone yang model
        return t_zone.get('vteps')
    for subnet in t_zone.get('subnets'):
        # Currently assume just one subnet configured.
        # Revisit when multiple supported
        if subnet.get('vteps'):
            return subnet.get('vteps')
    return None
Esempio n. 31
0
def show_eos(args):
    global ovs_nodes
    global dpn_host_map
    config.get_models(
        args, {
            "entity_owners_entity_owners",
            "network_topology_network_topology_operational"
        })
    owners = config.gmodels.entity_owners_entity_owners.get_clist_by_key()
    ovs_nodes = config.gmodels.network_topology_network_topology_operational.get_nodes_by_tid_and_key(
    )
    dpn_host_map = config.gmodels.network_topology_network_topology_operational.get_dpn_host_mapping(
    )
    print("========================")
    print("Entity Ownership Service")
    print("========================")
    print_entity_owners(args, owners)
Esempio n. 32
0
def show_dup_idpools(args):
    config.get_models(args, {"neutron_neutron"})
    ports = config.gmodels.neutron_neutron.get_objects_by_key(obj=Neutron.PORTS)
    iface_ids = []
    for k, v in get_duplicate_ids(args).iteritems():
        result = "Id:{},Keys:{}".format(k, json.dumps(v.get('id-keys')))
        if v.get('pool-name'):
            result = "{},Pool:{}".format(result, v.get('pool-name'))
            if v.get('pool-name') == 'interfaces':
                iface_ids.extend(v.get('id-keys'))
        if v.get('parent-pool-name'):
            result = "{},ParentPool:{}".format(result, v.get('parent-pool-name'))
        print(result)
    print("\nNeutron Ports")
    print("=============")
    for id in iface_ids:
        port = ports.get(id, {})
        print("Iface={}, NeutronPort={}".format(id, utils.format_json(args, port)))
Esempio n. 33
0
def by_ifname(args, ifname, ifstates, ifaces):
    config.get_models(args, {
        "itm_state_tunnels_state",
        "neutron_neutron"})
    ifstate = ifstates.get(ifname)
    iface = ifaces.get(ifname)
    port = None
    tunnel = None
    tun_state = None
    if iface and iface.get('type') == constants.IFTYPE_VLAN:
        ports = config.gmodels.neutron_neutron.get_objects_by_key(obj=Neutron.PORTS)
        port = ports.get(ifname)
    elif iface and iface.get('type') == constants.IFTYPE_TUNNEL:
        tun_states = config.gmodels.itm_state_tunnels_state.get_clist_by_key()
        tun_state = tun_states.get(ifname)
    else:
        print("UNSUPPORTED IfType")
    return iface, ifstate, port, tunnel, tun_state
Esempio n. 34
0
def show_elan_flows(args):
    config.get_models(
        args, {
            "elan_elan_instances", "elan_elan_interfaces",
            "ietf_interfaces_interfaces", "ietf_interfaces_interfaces_state",
            "odl_interface_meta_if_index_interface_map", "odl_inventory_nodes",
            "odl_inventory_nodes_operational"
        })
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping(
    )
    for flow in sort(get_all_flows(args, modules=['elan']), 'id'):
        host = compute_map.get(flow.pdata.get('dpnid'),
                               flow.pdata.get('dpnid'))
        flow.pdata['host'] = host
        result = "{}, Flow:{}".format(
            show_all(flow),
            utils.format_json(args, inv_flow_parser.parse_flow(flow.rdata)))
        print(result)
Esempio n. 35
0
def dump_flows(args, modules=None, sort_by='table', filter_by=None):
    config.get_models(args,
                      {"neutron_neutron", "odl_inventory_nodes_operational"})

    modules = modules if modules else ['ifm']
    filter_by = filter_by if filter_by else []
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping(
    )
    nports = config.gmodels.neutron_neutron.get_ports_by_key()
    for flow in utils.sort(get_all_flows(args, modules, filter_by), sort_by):
        host = compute_map.get(flow.get('dpnid'), flow.get('dpnid'))
        ip_list = get_ips_for_iface(nports, flow.get('ifname'))
        if ip_list:
            flow['iface-ips'] = ip_list
        result = 'Table:{}, Host:{}, FlowId:{}{}'.format(
            flow['table'], host, flow['id'], utils.show_optionals(flow))
        print(result)
        print("Flow: {}".format(
            utils.format_json(args, flow_parser.parse_flow(flow['flow']))))
Esempio n. 36
0
def show_idpools(args):
    config.get_models(args, {"neutron_neutron"})
    ports = config.gmodels.neutron_neutron.get_ports_by_key()
    iface_ids = []
    for k, v in get_duplicate_ids(args).iteritems():
        result = "Id:{},Keys:{}".format(k, json.dumps(v.get('id-keys')))
        if v.get('pool-name'):
            result = "{},Pool:{}".format(result, v.get('pool-name'))
            if v.get('pool-name') == 'interfaces':
                iface_ids.extend(v.get('id-keys'))
        if v.get('parent-pool-name'):
            result = "{},ParentPool:{}".format(result,
                                               v.get('parent-pool-name'))
        print(result)
    print("\nNeutron Ports")
    print("=============")
    for id in iface_ids:
        port = ports.get(id, {})
        print("Iface={}, NeutronPort={}".format(id,
                                                utils.format_json(args, port)))
Esempio n. 37
0
def get_duplicate_ids(args):
    config.get_models(args, {"id_manager_id_pools"})
    duplicate_ids = {}
    pools = config.gmodels.id_manager_id_pools.get_clist_by_key()
    for k, pool in pools.items():
        id_values = {}
        for id_entry in pool.get('id-entries', []):
            id_info = {}
            id_value = id_entry.get('id-value')[0]
            id_key = id_entry.get('id-key')
            if id_values and id_values.get(id_value, None):
                key_list = id_values.get(id_value)
                key_list.append(id_key)
                id_info['id-value'] = id_value
                id_info['id-keys'] = key_list
                id_info['pool-name'] = pool.get('pool-name')
                id_info['parent-pool-name'] = pool.get('parent-pool-name')
                duplicate_ids[id_value] = id_info
            else:
                id_values[id_value] = [id_key]
    return duplicate_ids
Esempio n. 38
0
def get_duplicate_ids(args):
    config.get_models(args, {"id_manager_id_pools"})
    duplicate_ids = {}
    pools = config.gmodels.id_manager_id_pools.get_clist_by_key()
    for k, pool in pools.items():
        id_values = {}
        for id_entry in pool.get('id-entries', []):
            id_info = {}
            id_value = id_entry.get('id-value')[0]
            id_key = id_entry.get('id-key')
            if id_values and id_values.get(id_value, None):
                key_list = id_values.get(id_value)
                key_list.append(id_key)
                id_info['id-value'] = id_value
                id_info['id-keys'] = key_list
                id_info['pool-name'] = pool.get('pool-name')
                id_info['parent-pool-name'] = pool.get('parent-pool-name')
                duplicate_ids[id_value] = id_info
            else:
                id_values[id_value] = [id_key]
    return duplicate_ids
Esempio n. 39
0
def show_dup_flows(args):
    config.get_models(args, {
        "elan_elan_instances",
        "elan_elan_interfaces",
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "interface_service_bindings_service_bindings",
        "l3vpn_vpn_interfaces",
        # "mip_mac",
        "odl_fib_fib_entries",
        "odl_interface_meta_if_index_interface_map",
        "odl_l3vpn_vpn_instance_to_vpn_id",
        "odl_inventory_nodes",
        "odl_inventory_nodes_operational"})
    mmac = {}  # config.gmodels.mip_mac.get_entries_by_key()
    einsts = config.gmodels.elan_elan_instances.get_clist_by_key()
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping()

    flows = utils.sort(get_all_flows(args, ['elan']), 'table')
    matches = collections.defaultdict(list)
    for flow in flows:
        dup_key = get_key_for_dup_detect(args, flow)
        if dup_key:
            if matches and matches.get(dup_key):
                matches[dup_key].append(flow)
            else:
                matches[dup_key].append(flow)
    for k, v in matches.iteritems():
        if len(v) > 1:
            dpnid = k.split(':')[0]
            host = compute_map.get(dpnid, dpnid)
            result = "Host:{}, FlowCount:{}, MatchKey:{}, ElanTag:{}".format(host, len(v), k, v[0].get('elan-tag'))
            print(result)
            for idx, flow in enumerate(v):
                result = "Duplicate"
                mac_addr = flow.get('dst-mac')
                if mac_addr and mmac.get(mac_addr):
                    result = is_correct_elan_flow(flow, mmac.get(mac_addr), einsts, host)
                print("    {} Flow-{}:{}".format(result, idx,
                                                 utils.format_json(args, flow_parser.parse_flow(flow.get('flow')))))
Esempio n. 40
0
def dump_flows(args, modules=None, sort_by='table', filter_by=None):
    config.get_models(args, {
        "neutron_neutron",
        "odl_inventory_nodes_operational",
        "network_topology_network_topology_operational"})
    filter_by = filter_by if filter_by else []
    compute_map = config.gmodels.odl_inventory_nodes_operational.get_dpn_host_mapping()
    node_map = config.gmodels.network_topology_network_topology_operational.get_dpn_host_mapping()
    nports = config.gmodels.neutron_neutron.get_objects_by_key(obj=Neutron.PORTS)
    for flow in utils.sort(get_all_flows(args, modules, filter_by), sort_by):
        dpnid = flow.get('dpnid')
        host = compute_map.get(dpnid)
        if not host:
            host = node_map.get(int(dpnid))
        ip_list = get_ips_for_iface(nports, flow.get('ifname'))
        if ip_list:
            flow['iface-ips'] = ip_list
        flow['host'] = host
        result = utils.show_all(flow)
        print(result)
        if not args.metaonly:
            print("Flow: {}".format(utils.format_json(args, flow_parser.parse_flow(flow['flow']))))
Esempio n. 41
0
def analyze_interface(args):
    config.get_models(args, {
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state"})
    ifaces = config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
    ifstates = config.gmodels.ietf_interfaces_interfaces_state.get_clist_by_key()

    if not args.ifname:
        print_keys(args, ifaces, ifstates)
        return

    ifname = args.ifname
    iface, ifstate, port, tunnel, tunState = by_ifname(args, ifname, ifstates, ifaces)
    print("InterfaceConfig: \n{}".format(utils.format_json(args, iface)))
    print("InterfaceState: \n{}".format(utils.format_json(args, ifstate)))
    if port:
        print("NeutronPort: \n{}".format(utils.format_json(args, port)))
        # analyze_neutron_port(port, iface, ifstate)
        return
    if tunnel:
        print("Tunnel: \n{}".format(utils.format_json(args, tunnel)))
    if tunState:
        print("TunState: \n{}".format(utils.format_json(args, tunState)))
Esempio n. 42
0
def analyze_trunks(args):
    config.get_models(
        args,
        {
            "ietf_interfaces_interfaces",
            # "ietf_interfaces_interfaces_state",
            "l3vpn_vpn_interfaces",
            "neutron_neutron"
        })

    vpninterfaces = config.gmodels.l3vpn_vpn_interfaces.get_clist_by_key()
    ifaces = config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
    # ifstates = config.gmodels.ietf_interfaces_interfaces_state.get_clist_by_key()
    nports = config.gmodels.neutron_neutron.get_objects_by_key(
        obj=Neutron.PORTS)
    ntrunks = config.gmodels.neutron_neutron.get_trunks_by_key()
    subport_dict = {}
    for v in ntrunks.values():
        nport = nports.get(v.get('port-id'))
        s_subports = []
        for subport in v.get('sub-ports'):
            sport_id = subport.get('port-id')
            snport = nports.get(sport_id)
            svpniface = vpninterfaces.get(sport_id)
            siface = ifaces.get(sport_id)
            # sifstate = ifstates.get(sport_id)
            subport['SubNeutronPort'] = 'Correct' if snport else 'Wrong'
            subport['SubVpnInterface'] = 'Correct' if svpniface else 'Wrong'
            subport['ofport'] = Model.get_ofport_from_ncid()
            if siface:
                vlan_mode = siface.get('odl-interface:l2vlan-mode')
                parent_iface_id = siface.get('odl-interface:parent-interface')
                if vlan_mode != 'trunk-member':
                    subport['SubIface'] = 'WrongMode'
                elif parent_iface_id != v.get('port-id'):
                    subport['SubIface'] = 'WrongParent'
                elif siface.get('odl-interface:vlan-id') != subport.get(
                        'segmentation-id'):
                    subport['SubIface'] = 'WrongVlanId'
                else:
                    subport['SubIface'] = 'Correct'
            else:
                subport['SubIface'] = 'Wrong'
                # s_subport = 'SegId:{}, PortId:{}, SubNeutronPort:{}, SubIface:{}, SubVpnIface:{}'.format(
                #     subport.get('segmentation-id'), subport.get('port-id'),
                #     subport.get('SubNeutronPort'),
                #     subport.get('SubIface'),
                #     subport.get('SubVpnInterface'))
            s_subports.append(subport)
            subport_dict[subport['port-id']] = subport
            s_trunk = 'TrunkName:{}, TrunkId:{}, PortId:{}, NeutronPort:{}, SubPorts:{}'.format(
                v.get('name'), v.get('uuid'), v.get('port-id'),
                'Correct' if nport else 'Wrong',
                utils.format_json(args, s_subports))
            print(s_trunk)
            print("\n------------------------------------")
            print("Analyzing Flow status for SubPorts")
            print("------------------------------------")
            for flow in utils.sort(
                    flows.get_all_flows(args, ['ifm'], ['vlanid']), 'ifname'):
                subport = subport_dict.get(flow.get('ifname')) or None
                vlanid = subport.get('segmentation-id') if subport else None
                ofport = subport.get('ofport') if subport else None
                flow_status = 'Okay'
                if flow.get('ofport') and flow.get('ofport') != ofport:
                    flow_status = 'OfPort mismatch for SubPort:{} and Flow:{}'.format(
                        subport, flow.get('flow'))
                if flow.get('vlanid') and flow.get('vlanid') != vlanid:
                    flow_status = 'VlanId mismatch for SubPort:{} and Flow:{}'.format(
                        subport, flow.get('flow'))
                if subport:
                    print("SubPort:{},Table:{},FlowStatus:{}".format(
                        subport.get('port-id'), flow.get('table'),
                        flow_status))
Esempio n. 43
0
def get_all_flows(args, modules=None, filter_by=None):
    config.get_models(
        args, {
            "elan_elan_instances", "elan_elan_interfaces",
            "ietf_interfaces_interfaces", "ietf_interfaces_interfaces_state",
            "l3vpn_vpn_interfaces", "odl_fib_fib_entries",
            "odl_interface_meta_if_index_interface_map",
            "odl_l3vpn_vpn_instance_to_vpn_id", "odl_inventory_nodes"
        })

    modules = modules if modules else args.modules if args.modules else "all"
    filter_by = filter_by if filter_by else []
    if not modules:
        return 'No modules specified'
    ifaces = {}
    ifstates = {}
    ifindexes = {}
    # bindings = {}
    einsts = {}
    eifaces = {}
    fibentries = {}
    vpnids = {}
    vpninterfaces = {}
    groups = {}
    if 'all' in modules:
        table_list = list(range(0, 255))
    else:
        table_list = list(
            set([
                table for mod in modules for table in tbls.get_table_map(mod)
            ]))
    of_nodes = config.gmodels.odl_inventory_nodes.get_clist_by_key()
    if 'ifm' in modules:
        ifaces = config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
        ifstates = config.gmodels.ietf_interfaces_interfaces_state.get_clist_by_key(
        )
    if 'l3vpn' in modules:
        ifaces = ifaces or config.gmodels.ietf_interfaces_interfaces.get_clist_by_key(
        )
        ifindexes = ifindexes or config.gmodels.odl_interface_meta_if_index_interface_map.get_clist_by_key(
        )
        fibentries = fibentries or config.gmodels.odl_fib_fib_entries.get_vrf_entries_by_key(
        )
        vpnids = vpnids or config.gmodels.odl_l3vpn_vpn_instance_to_vpn_id.get_clist_by_key(
        )
        vpninterfaces = vpninterfaces or config.gmodels.l3vpn_vpn_interfaces.get_clist_by_key(
        )
        groups = groups or config.gmodels.odl_inventory_nodes.get_groups(
            of_nodes)
    if 'acl' in modules:
        ifaces = ifaces or config.gmodels.ietf_interfaces_interfaces.get_clist_by_key(
        )
        ifindexes = ifindexes or config.gmodels.odl_interface_meta_if_index_interface_map.get_clist_by_key(
        )
        einsts = einsts or config.gmodels.elan_elan_instances.get_clist_by_key(
        )
        eifaces = eifaces or config.gmodels.elan_elan_interfaces.get_clist_by_key(
        )
    if 'elan' in modules:
        ifaces = ifaces or config.gmodels.ietf_interfaces_interfaces.get_clist_by_key(
        )
        einsts = einsts or config.gmodels.elan_elan_instances.get_clist_by_key(
        )
        eifaces = eifaces or config.gmodels.elan_elan_interfaces.get_clist_by_key(
        )
        ifindexes = ifindexes or config.gmodels.odl_interface_meta_if_index_interface_map.get_clist_by_key(
        )
    if 'all' in modules:
        groups = groups or config.gmodels.odl_inventory_nodes.get_groups(
            of_nodes)
        ifaces = ifaces or config.gmodels.ietf_interfaces_interfaces.get_clist_by_key(
        )
        ifstates = ifstates or config.gmodels.ietf_interfaces_interfaces_state.get_clist_by_key(
        )
        ifindexes = ifindexes or config.gmodels.odl_interface_meta_if_index_interface_map.get_clist_by_key(
        )
        fibentries = fibentries or config.gmodels.odl_fib_fib_entries.get_vrf_entries_by_key(
        )
        vpnids = vpnids or config.gmodels.odl_l3vpn_vpn_instance_to_vpn_id.get_clist_by_key(
        )
        vpninterfaces = vpninterfaces or config.gmodels.l3vpn_vpn_interfaces.get_clist_by_key(
        )
        einsts = einsts or config.gmodels.elan_elan_instances.get_clist_by_key(
        )
        eifaces = eifaces or config.gmodels.elan_elan_interfaces.get_clist_by_key(
        )
    flows = []
    for node in of_nodes.values():
        tables = [x for x in node[Nodes.NODE_TABLE] if x['id'] in table_list]
        for table in tables:
            for odl_flow in table.get('flow', []):
                flow = OdlFlow(odl_flow)
                flow.pdata = {'dpnid': Model.get_dpn_from_ofnodeid(node['id'])}
                get_any_flow(flow, groups, ifaces, ifstates, ifindexes,
                             fibentries, vpnids, vpninterfaces, einsts,
                             eifaces)
                if flow.pdata is not None and filter_flow(
                        flow.pdata, filter_by):
                    flows.append(flow)
    return flows
Esempio n. 44
0
def show_elan_instances(args):
    config.get_models(args, {"elan_elan_instances"})
    instances = config.gmodels.elan_elan_instances.get_clist_by_key()
    for k, v in instances.items():
        print("ElanInstance: {}, {}".format(k, utils.format_json(args, v)))
Esempio n. 45
0
def analyze_trunks(args):
    config.get_models(args, {
        "ietf_interfaces_interfaces",
        # "ietf_interfaces_interfaces_state",
        "l3vpn_vpn_interfaces",
        "neutron_neutron"})

    vpninterfaces = config.gmodels.l3vpn_vpn_interfaces.get_clist_by_key()
    ifaces = config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
    # ifstates = config.gmodels.ietf_interfaces_interfaces_state.get_clist_by_key()
    nports = config.gmodels.neutron_neutron.get_objects_by_key(obj=Neutron.PORTS)
    ntrunks = config.gmodels.neutron_neutron.get_trunks_by_key()
    subport_dict = {}
    for v in ntrunks.values():
        nport = nports.get(v.get('port-id'))
        s_subports = []
        for subport in v.get('sub-ports'):
            sport_id = subport.get('port-id')
            snport = nports.get(sport_id)
            svpniface = vpninterfaces.get(sport_id)
            siface = ifaces.get(sport_id)
            # sifstate = ifstates.get(sport_id)
            subport['SubNeutronPort'] = 'Correct' if snport else 'Wrong'
            subport['SubVpnInterface'] = 'Correct' if svpniface else 'Wrong'
            subport['ofport'] = Model.get_ofport_from_ncid()
            if siface:
                vlan_mode = siface.get('odl-interface:l2vlan-mode')
                parent_iface_id = siface.get('odl-interface:parent-interface')
                if vlan_mode != 'trunk-member':
                    subport['SubIface'] = 'WrongMode'
                elif parent_iface_id != v.get('port-id'):
                    subport['SubIface'] = 'WrongParent'
                elif siface.get('odl-interface:vlan-id') != subport.get('segmentation-id'):
                    subport['SubIface'] = 'WrongVlanId'
                else:
                    subport['SubIface'] = 'Correct'
            else:
                subport['SubIface'] = 'Wrong'
                # s_subport = 'SegId:{}, PortId:{}, SubNeutronPort:{}, SubIface:{}, SubVpnIface:{}'.format(
                #     subport.get('segmentation-id'), subport.get('port-id'),
                #     subport.get('SubNeutronPort'),
                #     subport.get('SubIface'),
                #     subport.get('SubVpnInterface'))
            s_subports.append(subport)
            subport_dict[subport['port-id']] = subport
            s_trunk = 'TrunkName:{}, TrunkId:{}, PortId:{}, NeutronPort:{}, SubPorts:{}'.format(
                v.get('name'), v.get('uuid'), v.get('port-id'),
                'Correct' if nport else 'Wrong', utils.format_json(args, s_subports))
            print(s_trunk)
            print("\n------------------------------------")
            print("Analyzing Flow status for SubPorts")
            print("------------------------------------")
            for flow in utils.sort(flows.get_all_flows(args, ['ifm'], ['vlanid']), 'ifname'):
                subport = subport_dict.get(flow.get('ifname')) or None
                vlanid = subport.get('segmentation-id') if subport else None
                ofport = subport.get('ofport') if subport else None
                flow_status = 'Okay'
                if flow.get('ofport') and flow.get('ofport') != ofport:
                    flow_status = 'OfPort mismatch for SubPort:{} and Flow:{}'.format(subport, flow.get('flow'))
                if flow.get('vlanid') and flow.get('vlanid') != vlanid:
                    flow_status = 'VlanId mismatch for SubPort:{} and Flow:{}'.format(subport, flow.get('flow'))
                if subport:
                    print("SubPort:{},Table:{},FlowStatus:{}".format(
                        subport.get('port-id'), flow.get('table'), flow_status))
Esempio n. 46
0
def get_all_flows(args, modules=None, filter_by=None):
    config.get_models(args, {
        "elan_elan_instances",
        "elan_elan_interfaces",
        "ietf_interfaces_interfaces",
        "ietf_interfaces_interfaces_state",
        "l3vpn_vpn_interfaces",
        "odl_fib_fib_entries",
        "odl_interface_meta_if_index_interface_map",
        "odl_l3vpn_vpn_instance_to_vpn_id",
        "odl_inventory_nodes"})

    modules = modules if modules else "all"
    filter_by = filter_by if filter_by else []
    if not modules:
        return 'No modules specified'
    ifaces = {}
    ifstates = {}
    ifindexes = {}
    # bindings = {}
    einsts = {}
    eifaces = {}
    fibentries = {}
    vpnids = {}
    vpninterfaces = {}
    groups = {}
    if 'all' in modules:
        table_list = list(range(0, 255))
    else:
        table_list = list(set([table for mod in modules for table in tbls.get_table_map(mod)]))
    of_nodes = config.gmodels.odl_inventory_nodes.get_clist_by_key()
    if 'ifm' in modules:
        ifaces = config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
        ifstates = config.gmodels.ietf_interfaces_interfaces_state.get_clist_by_key()
    if 'l3vpn' in modules:
        ifaces = ifaces or config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
        ifindexes = ifindexes or config.gmodels.odl_interface_meta_if_index_interface_map.get_clist_by_key()
        fibentries = fibentries or config.gmodels.odl_fib_fib_entries.get_vrf_entries_by_key()
        vpnids = vpnids or config.gmodels.odl_l3vpn_vpn_instance_to_vpn_id.get_clist_by_key()
        vpninterfaces = vpninterfaces or config.gmodels.l3vpn_vpn_interfaces.get_clist_by_key()
        groups = groups or config.gmodels.odl_inventory_nodes.get_groups(of_nodes)
    if 'acl' in modules:
        ifaces = ifaces or config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
        ifindexes = ifindexes or config.gmodels.odl_interface_meta_if_index_interface_map.get_clist_by_key()
        einsts = einsts or config.gmodels.elan_elan_instances.get_clist_by_key()
        eifaces = eifaces or config.gmodels.elan_elan_interfaces.get_clist_by_key()
    if 'elan' in modules:
        ifaces = ifaces or config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
        einsts = einsts or config.gmodels.elan_elan_instances.get_clist_by_key()
        eifaces = eifaces or config.gmodels.elan_elan_interfaces.get_clist_by_key()
        ifindexes = ifindexes or config.gmodels.odl_interface_meta_if_index_interface_map.get_clist_by_key()
    if 'all' in modules:
        groups = groups or config.gmodels.odl_inventory_nodes.get_groups(of_nodes)
        ifaces = ifaces or config.gmodels.ietf_interfaces_interfaces.get_clist_by_key()
        ifstates = ifstates or config.gmodels.ietf_interfaces_interfaces_state.get_clist_by_key()
        ifindexes = ifindexes or config.gmodels.odl_interface_meta_if_index_interface_map.get_clist_by_key()
        fibentries = fibentries or config.gmodels.odl_fib_fib_entries.get_vrf_entries_by_key()
        vpnids = vpnids or config.gmodels.odl_l3vpn_vpn_instance_to_vpn_id.get_clist_by_key()
        vpninterfaces = vpninterfaces or config.gmodels.l3vpn_vpn_interfaces.get_clist_by_key()
        einsts = einsts or config.gmodels.elan_elan_instances.get_clist_by_key()
        eifaces = eifaces or config.gmodels.elan_elan_interfaces.get_clist_by_key()
    flows = []
    for node in of_nodes.values():
        tables = [x for x in node[Nodes.NODE_TABLE] if x['id'] in table_list]
        for table in tables:
            for flow in table.get('flow', []):
                flow_info = {'dpnid': Model.get_dpn_from_ofnodeid(node['id'])}
                flow_dict = get_any_flow(flow, flow_info, groups,
                                         ifaces, ifstates, ifindexes,
                                         fibentries, vpnids, vpninterfaces,
                                         einsts, eifaces)
                if flow_dict is not None and filter_flow(flow_dict, filter_by):
                    flows.append(flow_dict)
    return flows
Esempio n. 47
0
def show_elan_instances(args):
    config.get_models(args, {"elan_elan_instances"})
    instances = config.gmodels.elan_elan_instances.get_clist_by_key()
    for k, v in instances.items():
        print("ElanInstance: {}, {}".format(k, utils.format_json(args, v)))