Commit 69a5d5db authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

WebUI component:

- Optimized topology retrieval for network plotting
parent c706fba8
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -131,25 +131,18 @@ def topology():
        topology_uuid = session['topology_uuid']

        json_topo_id = json_topology_id(topology_uuid, context_id=json_context_id(context_uuid))
        grpc_topology = context_client.GetTopology(TopologyId(**json_topo_id))
        response = context_client.GetTopologyDetails(TopologyId(**json_topo_id))

        topo_device_uuids = {device_id.device_uuid.uuid for device_id in grpc_topology.device_ids}
        topo_link_uuids   = {link_id  .link_uuid  .uuid for link_id   in grpc_topology.link_ids  }

        response = context_client.ListDevices(Empty())
        devices = []
        for device in response.devices:
            if device.device_id.device_uuid.uuid not in topo_device_uuids: continue
            devices.append({
                'id': device.device_id.device_uuid.uuid,
                'name': device.name,
                'type': device.device_type,
            })

        response = context_client.ListLinks(Empty())
        links = []
        for link in response.links:
            if link.link_id.link_uuid.uuid not in topo_link_uuids: continue
            if len(link.link_endpoint_ids) != 2:
                str_link = grpc_message_to_json_string(link)
                LOGGER.warning('Unexpected link with len(endpoints) != 2: {:s}'.format(str_link))