Commit 37d374b7 authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

Merge branch 'cnit_tapi' of https://labs.etsi.org/rep/tfs/controller into cnit_tapi

parents 81d3827e 8fdf7bbe
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -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

@@ -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
@@ -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,