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

code clean up

parent cdc8a6b4
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 e2e_orchestrator"}
export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device pathcomp service slice nbi webui load_generator"}

# Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import "context.proto";
service E2EOrchestratorService {
  rpc Compute(E2EOrchestratorRequest) returns (E2EOrchestratorReply)  {}
  rpc PushTopology(context.Topology)  returns (context.Empty)         {}
  rpc RunPathAlgorithm(E2EOrchestratorRequest) returns (E2EOrchestratorReply) {}
}

message E2EOrchestratorRequest {
+0 −49
Original line number Diff line number Diff line
@@ -23,10 +23,6 @@ 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
@@ -71,48 +67,3 @@ class E2EOrchestratorClient:
            "Compute result: {:s}".format(str(grpc_message_to_json(response)))
        )
        return response

    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