Loading src/tapi/service/topology/routes.py +9 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import requests from flask import jsonify, redirect, render_template, Blueprint, flash, session, url_for, request , make_response from common.proto.context_pb2 import (ContextList, Empty, TopologyId, TopologyList, Topology) from common.proto.tapi_pb2 import (ChildTopology) from google.protobuf.json_format import MessageToDict from common.tools.grpc.Tools import grpc_message_to_json_string Loading Loading @@ -44,11 +45,12 @@ def get_topology (context_uuid,topology_uuid) : if context_uuid and topology_uuid : topo_id = TopologyId() topo_id.topology_uuid.uuid = topology_uuid topo_id.context_id.context_uuid.uuid =context_uuid try: context_client.connect() topology = context_client.GetTopologyDetails(topo_id) return jsonify(topology.to_dict()), 200 return jsonify(MessageToDict(topology)), 200 except Exception as e : logging.info(f'get_topology error {e}') return jsonify({'error':'Failed in getting topology'}),500 Loading Loading @@ -89,15 +91,16 @@ def add_children () : host = child.get('host',None) port = child.get('port',None) url = ('http://{}:8008/topology/get_topology/{}/{}').format(host,context_uuid,topo_uuid) url = ('{}:8008/tapi/topology/get_topology/{}/{}').format(host,context_uuid,topo_uuid) response = requests.get(url) if response.status_code == 200 : logging.info(f"get_child_topo_details {response.json}") data = response.data logging.info(f"get_child_topo_details {data}") child_topo.topology_id.topology_uuid.uuid = topo_uuid child_topo.host = host for dev in response.devices : child_topo.port = port for dev in data.devices : for en in dev.device_endpoints: endpoints.append({ 'endpoint_id':en.endpoint_id, Loading Loading
src/tapi/service/topology/routes.py +9 −6 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import requests from flask import jsonify, redirect, render_template, Blueprint, flash, session, url_for, request , make_response from common.proto.context_pb2 import (ContextList, Empty, TopologyId, TopologyList, Topology) from common.proto.tapi_pb2 import (ChildTopology) from google.protobuf.json_format import MessageToDict from common.tools.grpc.Tools import grpc_message_to_json_string Loading Loading @@ -44,11 +45,12 @@ def get_topology (context_uuid,topology_uuid) : if context_uuid and topology_uuid : topo_id = TopologyId() topo_id.topology_uuid.uuid = topology_uuid topo_id.context_id.context_uuid.uuid =context_uuid try: context_client.connect() topology = context_client.GetTopologyDetails(topo_id) return jsonify(topology.to_dict()), 200 return jsonify(MessageToDict(topology)), 200 except Exception as e : logging.info(f'get_topology error {e}') return jsonify({'error':'Failed in getting topology'}),500 Loading Loading @@ -89,15 +91,16 @@ def add_children () : host = child.get('host',None) port = child.get('port',None) url = ('http://{}:8008/topology/get_topology/{}/{}').format(host,context_uuid,topo_uuid) url = ('{}:8008/tapi/topology/get_topology/{}/{}').format(host,context_uuid,topo_uuid) response = requests.get(url) if response.status_code == 200 : logging.info(f"get_child_topo_details {response.json}") data = response.data logging.info(f"get_child_topo_details {data}") child_topo.topology_id.topology_uuid.uuid = topo_uuid child_topo.host = host for dev in response.devices : child_topo.port = port for dev in data.devices : for en in dev.device_endpoints: endpoints.append({ 'endpoint_id':en.endpoint_id, Loading