def _json_layer2(load_traffic=False, view=None): topology_without_metadata = vlan.build_layer2_graph(( 'to_interface__netbox', 'to_interface__netbox__room', 'to_netbox__room', 'netbox__room', 'to_interface__netbox__room__location', 'to_netbox__room__location', 'netbox__room__location', )) vlan_by_interface, vlan_by_netbox = _get_vlans_map_layer2( topology_without_metadata) graph = build_netmap_layer2_graph(topology_without_metadata, vlan_by_interface, vlan_by_netbox, load_traffic, view) def get_edge_from_meta(meta): edge = meta['metadata'][0] return edge.u.netbox, edge.v.netbox result = { 'vlans': get_vlan_lookup_json(vlan_by_interface), 'nodes': _get_nodes(node_to_json_layer2, graph), 'links': [ edge_to_json_layer2(get_edge_from_meta(meta), meta) for u, v, meta in graph.edges_iter(data=True) ] } return result
def _json_layer2(load_traffic=False, view=None): topology_without_metadata = vlan.build_layer2_graph(( 'to_interface__netbox', 'to_interface__netbox__room', 'to_netbox__room', 'netbox__room', 'to_interface__netbox__room__location', 'to_netbox__room__location', 'netbox__room__location', )) vlan_by_interface, vlan_by_netbox = _get_vlans_map_layer2( topology_without_metadata) graph = build_netmap_layer2_graph(topology_without_metadata, vlan_by_interface, vlan_by_netbox, load_traffic, view) result = { 'vlans': get_vlan_lookup_json(vlan_by_interface), 'nodes': _get_nodes(node_to_json_layer2, graph), 'links': [ edge_to_json_layer2((node_a, node_b), nx_metadata) for node_a, node_b, nx_metadata in graph.edges_iter(data=True) ] } return result
def _json_layer2(load_traffic=False, view=None): _LOGGER.debug("build_netmap_layer2_graph() start") topology_without_metadata = vlan.build_layer2_graph( ( 'to_interface__netbox', 'to_interface__netbox__room', 'to_netbox__room', 'netbox__room', 'to_interface__netbox__room__location', 'to_netbox__room__location', 'netbox__room__location')) _LOGGER.debug("build_netmap_layer2_graph() topology graph done") vlan_by_interface, vlan_by_netbox = _get_vlans_map_layer2( topology_without_metadata) _LOGGER.debug("build_netmap_layer2_graph() vlan mappings done") graph = build_netmap_layer2_graph(topology_without_metadata, vlan_by_interface, vlan_by_netbox, load_traffic, view) return { 'vlans': get_vlan_lookup_json(vlan_by_interface), 'nodes': _get_nodes(node_to_json_layer2, graph), 'links': [edge_to_json_layer2((node_a, node_b), nx_metadata) for node_a, node_b, nx_metadata in graph.edges_iter(data=True)] }