Commit f504b4eb authored by Pablo Armingol's avatar Pablo Armingol
Browse files

Update deployment script and Dockerfile for PCEP integration; modify LSP_DB...

Update deployment script and Dockerfile for PCEP integration; modify LSP_DB error handling and add new dependencies
parent 96e3beee
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"

# Set the list of components, separated by spaces, you want to build images for, and deploy.
export TFS_COMPONENTS="context device pathcomp service slice nbi webui load_generator"
export TFS_COMPONENTS="context device pathcomp service slice nbi webui pcep"

# Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
@@ -29,7 +29,7 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui load_gene
#export TFS_COMPONENTS="${TFS_COMPONENTS} kpi_manager kpi_value_writer kpi_value_api"

# Uncomment to activate pcep
export TFS_COMPONENTS="${TFS_COMPONENTS} pcep"
# export TFS_COMPONENTS="${TFS_COMPONENTS} pcep"

# Uncomment to activate BGP-LS Speaker
#export TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker"
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ FROM python:3.9-slim

# Install dependencies
RUN apt-get --yes --quiet --quiet update && \
    apt-get --yes --quiet --quiet install wget g++ && \
    apt-get --yes --quiet --quiet install wget g++ libxml2-dev libxslt-dev iputils-ping && \
    rm -rf /var/lib/apt/lists/*

# Set Python to show logs as they occur
+2 −1
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@ class LspDB:
        self.db_engine = LSPEngine.get_engine()
        if self.db_engine is None:
            LOGGER.error('Unable to get SQLAlchemy DB Engine...')
            return False
            return None
            #return False
        self.db_name = DB_NAME
        self.Session = sessionmaker(bind=self.db_engine)

+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@

anytree==2.8.0
APScheduler==3.8.1
lxml==4.9.3
#networkx==2.6.3
#pydot==1.4.2
#redis==4.1.2
@@ -34,6 +35,7 @@ protobuf==3.20.*
prometheus_client==0.13.0

#DB
psycopg2-binary==2.9.*
SQLAlchemy==1.4.*
sqlalchemy-cockroachdb==1.4.*
SQLAlchemy-Utils==0.38.*
 No newline at end of file
+42 −42
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ class PcepServiceServicerImpl(PcepServiceServicer):
        LOGGER.debug("(ConfiguratePCE) Create pce instance %s",request)
        configurateIP=self.pcepServer.connectToJavaPcep(request.address)
        #return PceIpRp(addressRp=configurateIP)
        return PceIpRp(addressRp="10.95.90.56")
        return PceIpRp(addressRp="10.95.90.150")
    
    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def sendRequest(self, request : RequestRq, context : grpc.ServicerContext) -> RequestRp:
@@ -63,51 +63,51 @@ class PcepServiceServicerImpl(PcepServiceServicer):



    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def GetLSPDescriptor(self, request: LspID, grpc_context: grpc.ServicerContext) -> LspDescriptor:
        response = LspDescriptor()
        LOGGER.info(f"Received gRPC message object: {request}")

        try:
            # Obtener el identificador del LSP desde la solicitud
            lsp_id_to_search = request.lsp_id.uuid  # El LspID contiene el lsp_id que se busca
            row = self.lsp_db_obj.search_db_row_by_id(LspModel, 'lsp_id', lsp_id_to_search)

            if row is None:
                LOGGER.info(f"No matching row found for LSP id: {lsp_id_to_search}")
                return Empty()  # Si no se encuentra el LSP, devolvemos un Empty
                
            # Convertir la fila obtenida a un LspDescriptor y devolverla
            response = LspModel.convert_row_to_LspDescriptor(row)
            return response
        
        except Exception as e:
            LOGGER.error(f"Unable to search LSP id. Error: {e}")
            raise e
        
    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def SetKpiDescriptor(self, request: LspDescriptor, grpc_context: grpc.ServicerContext # type: ignore
                        ) -> LspID: # type: ignore
        response = LspID()
        LOGGER.info("Received gRPC message object: {:}".format(request))
        try:
            lsp_to_insert = LspModel.convert_LspDescriptor_to_row(request)
            if (self.lsp_db_obj.add_row_to_db(lsp_to_insert)):
                response.lsp_id.uuid = request.lsp_id.uuid
                # LOGGER.info("Added Row: {:}".format(response))
            return response
        except Exception as e:
            LOGGER.info("Unable to create LspModel class object. {:}".format(e))
    
    
    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def DeleteKpiDescriptor(self, request: LspID, grpc_context: grpc.ServicerContext # type: ignore
                            ) -> Empty: # type: ignore
        LOGGER.info("Received gRPC message object: {:}".format(request))
        try:
            lsp_id_to_search = request.lsp_id.uuid  # El LspID contiene el lsp_id que se busca
            self.lsp_db_obj.delete_db_row_by_id(LspModel, 'kpi_id', lsp_id_to_search)
        except Exception as e:
            LOGGER.info('Unable to search kpi id. {:}'.format(e))
        finally:
            return Empty()
 No newline at end of file
    # @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    # def GetLSPDescriptor(self, request: LspID, grpc_context: grpc.ServicerContext) -> LspDescriptor:
    #     response = LspDescriptor()
    #     LOGGER.info(f"Received gRPC message object: {request}")

    #     try:
    #         # Obtener el identificador del LSP desde la solicitud
    #         lsp_id_to_search = request.lsp_id.uuid  # El LspID contiene el lsp_id que se busca
    #         row = self.lsp_db_obj.search_db_row_by_id(LspModel, 'lsp_id', lsp_id_to_search)

    #         if row is None:
    #             LOGGER.info(f"No matching row found for LSP id: {lsp_id_to_search}")
    #             return Empty()  # Si no se encuentra el LSP, devolvemos un Empty
                
    #         # Convertir la fila obtenida a un LspDescriptor y devolverla
    #         response = LspModel.convert_row_to_LspDescriptor(row)
    #         return response
        
    #     except Exception as e:
    #         LOGGER.error(f"Unable to search LSP id. Error: {e}")
    #         raise e
        
    # @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    # def SetKpiDescriptor(self, request: LspDescriptor, grpc_context: grpc.ServicerContext # type: ignore
    #                     ) -> LspID: # type: ignore
    #     response = LspID()
    #     LOGGER.info("Received gRPC message object: {:}".format(request))
    #     try:
    #         lsp_to_insert = LspModel.convert_LspDescriptor_to_row(request)
    #         if (self.lsp_db_obj.add_row_to_db(lsp_to_insert)):
    #             response.lsp_id.uuid = request.lsp_id.uuid
    #             # LOGGER.info("Added Row: {:}".format(response))
    #         return response
    #     except Exception as e:
    #         LOGGER.info("Unable to create LspModel class object. {:}".format(e))
    
    
    # @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    # def DeleteKpiDescriptor(self, request: LspID, grpc_context: grpc.ServicerContext # type: ignore
    #                         ) -> Empty: # type: ignore
    #     LOGGER.info("Received gRPC message object: {:}".format(request))
    #     try:
    #         lsp_id_to_search = request.lsp_id.uuid  # El LspID contiene el lsp_id que se busca
    #         self.lsp_db_obj.delete_db_row_by_id(LspModel, 'kpi_id', lsp_id_to_search)
    #     except Exception as e:
    #         LOGGER.info('Unable to search kpi id. {:}'.format(e))
    #     finally:
    #         return Empty()
 No newline at end of file