Commit 8489e9eb authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

get_topo_details in tapi

parent 1501e15b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@ import "context.proto";


service TapiService {
service TapiService {
  rpc GetListTopologies     (context.Empty     ) returns (       context.TopologyList    ) {}
  rpc GetListTopologies     (context.Empty     ) returns (       context.TopologyList    ) {}
  rpc GetTopology        (context.TopologyId    ) returns (       context.Topology        ) {}
  rpc GetTopology        (context.TopologyId    ) returns (       context.TopologyDetails        ) {}
  rpc SetService         (context.ServiceList)    returns (context.Empty) {}
  rpc SetService         (context.ServiceList)    returns (context.Empty) {}
  rpc CheckConnectivity ( SocketID)                returns ( CheckStat) {}
  rpc CheckConnectivity ( SocketID)                returns ( CheckStat) {}
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -18,7 +18,7 @@ from common.Settings import get_service_host, get_service_port_grpc
from common.proto.context_pb2 import (
from common.proto.context_pb2 import (
    Topology, 
    Topology, 
    TopologyList, Empty,
    TopologyList, Empty,
    Service, TopologyId,ServiceList
    Service, TopologyId,ServiceList , TopologyDetails
)
)
from common.proto.tapi_pb2 import TapiRequest , SocketID ,CheckStat
from common.proto.tapi_pb2 import TapiRequest , SocketID ,CheckStat


@@ -52,7 +52,7 @@ class TapiClient:
       
       
            
            
            self.channel = grpc.insecure_channel(self.endpoint)
            self.channel = grpc.insecure_channel(self.endpoint)
            #self.channel = grpc.insecure_channel('10.30.7.61:30582')
            #self.channel = grpc.insecure_channel('10.30.7.61:30491')
            grpc.channel_ready_future(self.channel).result(timeout=5)
            grpc.channel_ready_future(self.channel).result(timeout=5)
            self.stub = TapiServiceStub(self.channel)
            self.stub = TapiServiceStub(self.channel)
            LOGGER.info("Successfully connected to gRPC server at %s", self.endpoint)
            LOGGER.info("Successfully connected to gRPC server at %s", self.endpoint)
@@ -76,7 +76,7 @@ class TapiClient:
        return response
        return response


    @RETRY_DECORATOR
    @RETRY_DECORATOR
    def GetTopology(self, request : TopologyId) -> Topology:
    def GetTopology(self, request : TopologyId) -> TopologyDetails:
        LOGGER.debug('GetTopology request: {:s}'.format(grpc_message_to_json_string(request)))
        LOGGER.debug('GetTopology request: {:s}'.format(grpc_message_to_json_string(request)))
        response = self.stub.GetTopology(request)
        response = self.stub.GetTopology(request)
        LOGGER.debug('GetTopology result: {:s}'.format(grpc_message_to_json_string(response)))
        LOGGER.debug('GetTopology result: {:s}'.format(grpc_message_to_json_string(response)))
+3 −3
Original line number Original line Diff line number Diff line
@@ -19,7 +19,7 @@ from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_


from common.proto.context_pb2 import (
from common.proto.context_pb2 import (
   Topology,TopologyList ,TopologyId,Empty,
   Topology,TopologyList ,TopologyId,Empty,
   Service, ServiceId , ServiceList 
   Service, ServiceId , ServiceList  , TopologyDetails
)
)


from common.proto.tapi_pb2 import TapiRequest , SocketID ,CheckStat
from common.proto.tapi_pb2 import TapiRequest , SocketID ,CheckStat
@@ -75,9 +75,9 @@ class TapiServiceServicerImpl(TapiService):
            LOGGER.info(f"error in Tapi servicer {e}")
            LOGGER.info(f"error in Tapi servicer {e}")
    
    
    
    
    def GetTopology (self ,topology_id : TopologyId , context : grpc.ServicerContext) -> Topology : 
    def GetTopology (self ,topology_id : TopologyId , context : grpc.ServicerContext) -> TopologyDetails : 
        try: 
        try: 
          topology = self._ctxt.GetTopology(topology_id)
          topology = self._ctxt.GetTopologyDetails(topology_id)
          return topology        
          return topology        
          
          
        except Exception as e : 
        except Exception as e : 
+9 −6
Original line number Original line Diff line number Diff line
@@ -64,20 +64,21 @@ def home() :
            if  topo_lsts   is not None  : 
            if  topo_lsts   is not None  : 
                session['tapi_endpoint'] = f'{ip}:{port}'
                session['tapi_endpoint'] = f'{ip}:{port}'
                return  render_template( 'tapi/topo.html',topo_lsts=topo_lsts)
                return  render_template( 'tapi/topo.html',topo_lsts=topo_lsts)
            tapi_client.close()
            
                
                
        except Exception as  err : 
        except Exception as  err : 
            LOGGER.info(f" error from connecting tapi {err}") 
            LOGGER.info(f" error from connecting tapi {err}") 
            flash(f'Connection is failed: `{str(err)}`', 'danger')
            flash(f'Connection is failed: `{str(err)}`', 'danger')
        finally:
        finally:
        
        
           pass      
           tapi_client.close()
                 
    return render_template('tapi/home.html', socket_form=socket_form)
    return render_template('tapi/home.html', socket_form=socket_form)






@tapi.route("/retmote_topo" , methods=['GET', 'POST'])
@tapi.route("/retmote_topo/<path:topo_uuid>/<path:context_uuid>" , methods=['GET', 'POST'])
def get_retmote_topo (topo_uuid  ) : 
def get_retmote_topo (topo_uuid :str ,context_uuid :str) : 
    topo=None
    topo=None
    if 'tapi_endpoint' in session : 
    if 'tapi_endpoint' in session : 
        try: 
        try: 
@@ -88,16 +89,18 @@ def get_retmote_topo (topo_uuid ) :
          
          
                topo_id = TopologyId()
                topo_id = TopologyId()
                topo_id.topology_uuid.uuid = topo_uuid
                topo_id.topology_uuid.uuid = topo_uuid
                topo_id.context_id.context_uuid.uuid=context_uuid
                topo=tapi_client.GetTopology(topo_id)
                topo=tapi_client.GetTopology(topo_id)
                #topo_lsts = tapi_client.CheckConnectivity()
                #topo_lsts = tapi_client.CheckConnectivity()
                LOGGER.info(f'topo existed {topo}')
                LOGGER.info(f'topo existed {topo}')
          
          
            tapi_client.close()
            
                
                
        except Exception as  err : 
        except Exception as  err : 
            LOGGER.info(f" error from connecting tapi {err}") 
            LOGGER.info(f" error from connecting tapi {err}") 
            flash(f'Connection is failed: `{str(err)}`', 'danger')
            flash(f'Connection is failed: `{str(err)}`', 'danger')
       
        finally: 
            tapi_client.close()
         
         
                
                
    return  render_template( 'tapi/topo_detail.html',topo=topo)
    return  render_template( 'tapi/topo_detail.html',topo=topo)
+1 −1
Original line number Original line Diff line number Diff line
@@ -31,7 +31,7 @@
                    
                    
                  
                  
                    <td>
                    <td>
                        <a href="#">
                        <a href="{{url_for ('tapi.get_retmote_topo',topo_uuid=topo.topology_id.topology_uuid.uuid , context_uuid = topo.topology_id.context_id.context_uuid.uuid)}}">
                            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">
                            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">
                                <path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
                                <path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
                                <path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
                                <path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>