Commit d2fffae3 authored by Leandro Campos's avatar Leandro Campos
Browse files

E2E client

parent e2a32baf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ export TFS_REGISTRY_IMAGES=${TFS_REGISTRY_IMAGES:-"http://localhost:32000/tfs/"}

# If not already set, set the list of components, separated by spaces, you want to build images for, and deploy.
# By default, only basic components are deployed
export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device pathcomp service slice nbi webui load_generator"}
export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device pathcomp service slice nbi webui load_generator e2e_orchestrator"}

# Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
+1 −1
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"
export TFS_COMPONENTS="context device pathcomp service slice nbi webui e2e_orchestrator"

# Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
+42 −12
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@ from common.Settings import get_service_host, get_service_port_grpc
from common.tools.client.RetryDecorator import delay_exponential, retry
from common.tools.grpc.Tools import grpc_message_to_json
from common.proto.e2eorchestrator_pb2 import E2EOrchestratorRequest, E2EOrchestratorReply
from common.proto.context_pb2 import Service

from decimal import Decimal, ROUND_HALF_EVEN
import json

LOGGER = logging.getLogger(__name__)
MAX_RETRIES = 15
@@ -68,21 +72,47 @@ class E2EOrchestratorClient:
        )
        return response

    def RunPathAlgorithm(self, service: Service) -> E2EOrchestratorReply:
    def RunPathAlgorithm(self, service: Service) -> dict:
        # Extraer appInsId
        appInsId = service.service_id.service_uuid.uuid

        # Extraer fixedAllocation
        bw = None
        for c in service.service_constraints:
            if c.WhichOneof('constraint') == 'sla_capacity':
                bw = str(Decimal(c.sla_capacity.capacity_gbps * 1.e9).quantize(Decimal('0.1'), rounding=ROUND_HALF_EVEN))
                break

        # Extraer origen/destino
        origen = None
        destino = None
        for cr in service.service_config.config_rules:
            if cr.WhichOneof('config_rule') != 'custom':
                continue
            val = json.loads(cr.custom.resource_value)
            if "sessionFilter" in val:
                origen = val["sessionFilter"].get("sourceIp")
                destino = val["sessionFilter"].get("dstAddress")
                break

        LOGGER.info(
            "Llegó a RunPathAlgorithm con service_id=%s, origen=%s, destino=%s, bw=%s",
            appInsId, origen, destino, bw
        )

        # Retorno simulado para pruebas
        reply = {
            "origen": origen,
            "destino": destino,
            "bw": bw,
            "appInsId": appInsId,
            "message": "Recibido correctamente"
        }
        return reply

        #request = E2EOrchestratorRequest(service=service)
        #LOGGER.info("PathAlgorithm request: %s", grpc_message_to_json(request))
        #response = self.stub.RunPathAlgorithm(request)  # si el proto define RunPathAlgorithm
        #LOGGER.info("PathAlgorithm result: %s", grpc_message_to_json(response))
        #return response

       
        LOGGER.info("Llegó a RunPathAlgorithm con service: %s", service.service_id.service_uuid.uuid)
        # Retorno simulado para no bloquear
        class FakeReply:
            def __init__(self):
                self.message = "Prueba completada"
        return FakeReply()

        
        return response
+4 −0
Original line number Diff line number Diff line
@@ -87,6 +87,10 @@ COPY src/qos_profile/__init__.py qos_profile/__init__.py
COPY src/qos_profile/client/. qos_profile/client/
COPY src/vnt_manager/__init__.py vnt_manager/__init__.py
COPY src/vnt_manager/client/. vnt_manager/client/

COPY src/e2e_orchestrator/. e2e_orchestrator/__init__.py
COPY src/e2e_orchestrator/client/. e2e_orchestrator/client/

RUN mkdir -p /var/teraflow/tests/tools
COPY src/tests/tools/mock_osm/. tests/tools/mock_osm/

+2 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ from .tfs_api import register_tfs_api
#from .topology_updates import register_topology_updates
from .vntm_recommend import register_vntm_recommend
from .well_known_meta import register_well_known
from .etsi_e2e_path_computation import register_etsi_e2e_path_computation


LOG_LEVEL = get_log_level()
@@ -98,6 +99,7 @@ register_qkd_app (nbi_app)
#register_topology_updates(nbi_app) # does not work; check if eventlet-grpc side effects
register_vntm_recommend  (nbi_app)
register_camara_qod      (nbi_app)
register_etsi_e2e_path_computation (nbi_app)
LOGGER.info('All connectors registered')

nbi_app.dump_configuration()
Loading