def _json_layer3(load_traffic=False, view=None): topology_without_metadata = vlan.build_layer3_graph(( 'prefix__vlan__net_type', 'gwportprefix__prefix__vlan__net_type', )) vlans_map = _get_vlans_map_layer3(topology_without_metadata) graph = build_netmap_layer3_graph(topology_without_metadata, load_traffic, view) def get_edge_from_meta(meta): edges = next(iter(meta['metadata'].values())) first = next(iter(edges)) return first.u.netbox, first.v.netbox result = { 'vlans': [vlan_to_json(prefix.vlan) for prefix in vlans_map], 'nodes': _get_nodes(node_to_json_layer3, graph), 'links': [ edge_to_json_layer3(get_edge_from_meta(meta), meta) for u, v, meta in graph.edges_iter(data=True) ] } return result
def _json_layer3(load_traffic=False, view=None): _LOGGER.debug("build_netmap_layer3_graph() start") topology_without_metadata = vlan.build_layer3_graph( ('prefix__vlan__net_type', 'gwportprefix__prefix__vlan__net_type',)) _LOGGER.debug("build_netmap_layer3_graph() topology graph done") vlans_map = _get_vlans_map_layer3(topology_without_metadata) _LOGGER.debug("build_netmap_layer2_graph() vlan mappings done") graph = build_netmap_layer3_graph(topology_without_metadata, load_traffic, view) return { 'vlans': [vlan_to_json(prefix.vlan) for prefix in vlans_map], 'nodes': _get_nodes(node_to_json_layer3, graph), 'links': [edge_to_json_layer3((node_a, node_b), nx_metadata) for node_a, node_b, nx_metadata in graph.edges_iter(data=True)] }
def _json_layer3(load_traffic=False, view=None): topology_without_metadata = vlan.build_layer3_graph(( 'prefix__vlan__net_type', 'gwportprefix__prefix__vlan__net_type', )) vlans_map = _get_vlans_map_layer3(topology_without_metadata) graph = build_netmap_layer3_graph(topology_without_metadata, load_traffic, view) result = { 'vlans': [vlan_to_json(prefix.vlan) for prefix in vlans_map], 'nodes': _get_nodes(node_to_json_layer3, graph), 'links': [ edge_to_json_layer3((node_a, node_b), nx_metadata) for node_a, node_b, nx_metadata in graph.edges_iter(data=True) ] } return result