Loading src/config/.env.example +3 −1 Original line number Diff line number Diff line Loading @@ -31,12 +31,14 @@ 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 # Type of planner to be used. Options: ENERGY, HRAT, TFS_OPTICAL, E2E_OPTICAL PLANNER_TYPE=ENERGY # HRAT HRAT_IP=10.0.0.1 # TFS_OPTICAL OPTICAL_PLANNER_IP=10.0.0.1 # E2E_OPTICAL E2E_OPTICAL_IP=127.0.0.1 # ------------------------- # Realizer Loading src/config/config.py +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ def create_config(app: Flask): 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") app.config["E2E_OPTICAL_IP"] = os.getenv("E2E_OPTICAL_IP", "127.0.0.1") # Realizer app.config["DUMMY_MODE"] = os.getenv("DUMMY_MODE", "true").lower() == "true" Loading src/planner/e2e_optical_planner/e2e_optical.py 0 → 100644 +57 −0 Original line number Diff line number Diff line # Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import logging import requests import json from src.utils.safe_get import safe_get def e2e_optical_planner(intent, ip: str, action: str = "create") -> dict: """ Plan E2E optical layer configuration using TFS NBI. Args: intent (dict or str): Network slice intent ip (str): IP address of the TFS NBI service action (str, optional): Operation to perform - "create" or "delete". Defaults to "create" """ if action == 'delete': logging.debug("DELETE REQUEST RECEIVED FOR E2EOptical: %s", intent) return None url = f"http://{ip}/restconf/e2epathcomp/v0/e2e_path_computation" headers = { "Content-Type": "application/json", "Accept": "application/json" } payload = intent logging.debug(f"Sending request to E2EOptical Planner: {url}") try: response = requests.post(url, headers=headers, json=payload, timeout=10) if response.status_code in [200, 201]: response_data = response.json() logging.info(f"E2EOptical Planner Response: {json.dumps(response_data, indent=2)}") return response_data else: logging.warning(f"E2EOptical Planner returned status {response.status_code}: {response.text}") return None except requests.exceptions.RequestException as e: logging.warning(f"Error connecting to the E2EOptical Planner service: {e}") return None src/planner/planner.py +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import logging from src.planner.energy_planner.energy import energy_planner from src.planner.hrat_planner.hrat import hrat_planner from src.planner.tfs_optical_planner.tfs_optical import tfs_optical_planner from src.planner.e2e_optical_planner.e2e_optical import e2e_optical_planner from flask import current_app Loading Loading @@ -49,5 +50,7 @@ class Planner: elif type == "HRAT" : return hrat_planner(intent, current_app.config["HRAT_IP"]) # Use TFS optical planner with configured IP elif type == "TFS_OPTICAL": return tfs_optical_planner(intent, current_app.config["OPTICAL_PLANNER_IP"], action = "create") # Use E2E optical planner with configured IP elif type == "E2E_OPTICAL": return e2e_optical_planner(intent, current_app.config["E2E_OPTICAL_IP"], action = "create") # Return None if planner type is unsupported else : return None Loading
src/config/.env.example +3 −1 Original line number Diff line number Diff line Loading @@ -31,12 +31,14 @@ 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 # Type of planner to be used. Options: ENERGY, HRAT, TFS_OPTICAL, E2E_OPTICAL PLANNER_TYPE=ENERGY # HRAT HRAT_IP=10.0.0.1 # TFS_OPTICAL OPTICAL_PLANNER_IP=10.0.0.1 # E2E_OPTICAL E2E_OPTICAL_IP=127.0.0.1 # ------------------------- # Realizer Loading
src/config/config.py +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ def create_config(app: Flask): 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") app.config["E2E_OPTICAL_IP"] = os.getenv("E2E_OPTICAL_IP", "127.0.0.1") # Realizer app.config["DUMMY_MODE"] = os.getenv("DUMMY_MODE", "true").lower() == "true" Loading
src/planner/e2e_optical_planner/e2e_optical.py 0 → 100644 +57 −0 Original line number Diff line number Diff line # Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import logging import requests import json from src.utils.safe_get import safe_get def e2e_optical_planner(intent, ip: str, action: str = "create") -> dict: """ Plan E2E optical layer configuration using TFS NBI. Args: intent (dict or str): Network slice intent ip (str): IP address of the TFS NBI service action (str, optional): Operation to perform - "create" or "delete". Defaults to "create" """ if action == 'delete': logging.debug("DELETE REQUEST RECEIVED FOR E2EOptical: %s", intent) return None url = f"http://{ip}/restconf/e2epathcomp/v0/e2e_path_computation" headers = { "Content-Type": "application/json", "Accept": "application/json" } payload = intent logging.debug(f"Sending request to E2EOptical Planner: {url}") try: response = requests.post(url, headers=headers, json=payload, timeout=10) if response.status_code in [200, 201]: response_data = response.json() logging.info(f"E2EOptical Planner Response: {json.dumps(response_data, indent=2)}") return response_data else: logging.warning(f"E2EOptical Planner returned status {response.status_code}: {response.text}") return None except requests.exceptions.RequestException as e: logging.warning(f"Error connecting to the E2EOptical Planner service: {e}") return None
src/planner/planner.py +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import logging from src.planner.energy_planner.energy import energy_planner from src.planner.hrat_planner.hrat import hrat_planner from src.planner.tfs_optical_planner.tfs_optical import tfs_optical_planner from src.planner.e2e_optical_planner.e2e_optical import e2e_optical_planner from flask import current_app Loading Loading @@ -49,5 +50,7 @@ class Planner: elif type == "HRAT" : return hrat_planner(intent, current_app.config["HRAT_IP"]) # Use TFS optical planner with configured IP elif type == "TFS_OPTICAL": return tfs_optical_planner(intent, current_app.config["OPTICAL_PLANNER_IP"], action = "create") # Use E2E optical planner with configured IP elif type == "E2E_OPTICAL": return e2e_optical_planner(intent, current_app.config["E2E_OPTICAL_IP"], action = "create") # Return None if planner type is unsupported else : return None