Commit c6cc0086 authored by Javier Velázquez's avatar Javier Velázquez
Browse files

Merge branch 'feat/16-tid-new-controller-type' into 'develop'

Resolve "(TID) New Controller Type"

See merge request !15
parents 4ce74038 08cf840e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ from flask_restx import Api
from flask_cors import CORS
from swagger.tfs_namespace import tfs_ns
from swagger.ixia_namespace import ixia_ns
from swagger.E2E_namespace import e2e_ns
from src.config.constants import NSC_PORT
from src.webui.gui import gui_bp
from src.config.config import create_config
@@ -50,6 +51,7 @@ def create_app():
    # Register namespaces
    api.add_namespace(tfs_ns, path="/tfs")
    api.add_namespace(ixia_ns, path="/ixia")
    api.add_namespace(e2e_ns, path="/e2e")

    if app.config["WEBUI_DEPLOY"]:
        app.secret_key = "clave-secreta-dev"
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ class Api:
                code=201,
                data=result 
            )
        except RuntimeError as e:
            # Handle case where there is no content to process
            return send_response(False, code=200, message=str(e))
        except Exception as e:
            # Handle unexpected errors
            return send_response(False, code=500, message=str(e))
+11 −0
Original line number Diff line number Diff line
@@ -29,6 +29,12 @@ NRP_ENABLED=false
PLANNER_ENABLED=true
# Flag to determine if external PCE is used
PCE_EXTERNAL=false
# Type of planner to be used. Options: ENERGY, HRAT, TFS_OPTICAL
PLANNER_TYPE=ENERGY
# HRAT
HRAT_IP=10.0.0.1
# TFS_OPTICAL
OPTICAL_PLANNER_IP=10.0.0.1

# -------------------------
# Realizer
@@ -49,6 +55,11 @@ TFS_L2VPN_SUPPORT=false
# -------------------------
IXIA_IP=127.0.0.1

# -------------------------
# E2E Controller
# -------------------------
TFS_E2E_IP=127.0.0.1

# -------------------------
# WebUI
# -------------------------
+6 −0
Original line number Diff line number Diff line
@@ -42,7 +42,10 @@ def create_config(app: Flask):
    # Mapper
    app.config["NRP_ENABLED"] = os.getenv("NRP_ENABLED", "false").lower() == "true"
    app.config["PLANNER_ENABLED"] = os.getenv("PLANNER_ENABLED", "false").lower() == "true"
    app.config["PLANNER_TYPE"] = os.getenv("PLANNER_TYPE", "ENERGY")
    app.config["PCE_EXTERNAL"] = os.getenv("PCE_EXTERNAL", "false").lower() == "true"
    app.config["HRAT_IP"] = os.getenv("HRAT_IP", "192.168.1.143")
    app.config["OPTICAL_PLANNER_IP"] = os.getenv("OPTICAL_PLANNER_IP", "10.30.7.66")

    # Realizer
    app.config["DUMMY_MODE"] = os.getenv("DUMMY_MODE", "true").lower() == "true"
@@ -55,6 +58,9 @@ def create_config(app: Flask):
    # IXIA
    app.config["IXIA_IP"] = os.getenv("IXIA_IP", "127.0.0.1")

    # E2E Controller
    app.config["TFS_E2E_IP"] = os.getenv("TFS_E2E_IP", "127.0.0.1")

    # WebUI
    app.config["WEBUI_DEPLOY"] = os.getenv("WEBUI_DEPLOY", "false").lower() == "true"

+27 −19
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

# This file includes original contributions from Telefonica Innovación Digital S.L.

import logging
import time
from src.utils.dump_templates import dump_templates
from src.utils.build_response import build_response
@@ -88,23 +89,30 @@ class NSController:

        # Reset requests
        requests = {"services":[]}
        response = None

        # Process intent (translate if 3GPP)
        ietf_intents = nbi_processor(intent_json)

        for intent in ietf_intents:
            # Mapper
            mapper(intent)
            # Store slice request details and build response
            store_data(intent, slice_id, controller_type=self.controller_type)   
            self.response = build_response(intent, self.response)
            rules = mapper(intent)
            # Build response
            self.response = build_response(intent, self.response, controller_type= self.controller_type)
            # Realizer
            request = realizer(intent, controller_type=self.controller_type, response = self.response)
            request = realizer(intent, controller_type=self.controller_type, response = self.response, rules = rules)
            # Store slice request details
            if request: 
                requests["services"].append(request)
                store_data(intent, slice_id, controller_type=self.controller_type)

        # Store the generated template for debugging
        dump_templates(intent_json, ietf_intents, requests)

        # Check if there are services to process
        if not requests.get("services"):
            raise RuntimeError("No service to process.")

        # Send config to controllers
        response = send_controller(self.controller_type, requests)

Loading