Commit 3b4c4f81 authored by Maria Ruiz's avatar Maria Ruiz
Browse files

implementacion ddbb sat

parent 7f6f0a8a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ PCE_EXTERNAL = False

# Controller Flags
# If True, config is not sent to controllers
DUMMY_MODE = True
DUMMY_MODE = False
#DUMMY_MODE = True #MR

#####TERAFLOW#####
+12 −2
Original line number Diff line number Diff line
@@ -20,7 +20,9 @@ from src.helpers import tfs_connector, cisco_connector
from src.Constants import DEFAULT_LOGGING_LEVEL, TFS_IP, TFS_L2VPN_SUPPORT, IXIA_IP, SRC_PATH, TEMPLATES_PATH, DUMMY_MODE, DUMP_TEMPLATES, PLANNER_ENABLED, NRP_ENABLED, UPLOAD_TYPE, NBI_L2_PATH, NBI_L3_PATH, SATNMS_IP
from src.realizers.ixia.NEII_V4 import NEII_controller
from src.realizers.sat.SATNMS import SAT_NMS 
from src.realizers.sat.SATRM import SAT_RM
from src.planner.planner import Planner
from src.planner.sat_planner import SATPlanner

# Configure logging to provide clear and informative log messages
logging.basicConfig(
@@ -337,8 +339,10 @@ class NSController:

                elif self.controller_type == "sat":
                    sat_nms = SAT_NMS()
                    sat_rm = SAT_RM()
                    for intent in requests["services"]:
                        sat_nms.nscSATNMS(intent)
                        sat_rm.nscSATRM(intent)
                    logging.info("Request sent to SATELLITE NMS")

            # End performance tracking
@@ -405,6 +409,8 @@ class NSController:
        Raises:
            Exception: If no suitable NRP is found and slice creation fails.
        """ 

        
        if NRP_ENABLED:
            # Retrieve NRP view
            self.__realizer(None, True, "READ")
@@ -438,9 +444,13 @@ class NSController:
                    # TODO Here we should put how the slice is attached to the new nrp
        
        if PLANNER_ENABLED:
            optimal_path = Planner().planner(ietf_intent)

            if self.controller_type == "sat":
                optimal_path = SATPlanner().satplanner(ietf_intent)
                logging.info(f"Optimal path: {optimal_path}")  
            else:
                viability = Planner().planner(ietf_intent)
                logging.info(f"Resource allocation in the satellite segment: {viability}")

    def __realizer(self, ietf_intent, need_nrp=False, order=None, nrp=None):
        """
+46 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 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.

# This file is an original contribution from Telefonica Innovación Digital S.L.

import json, os
from src.Constants import SRC_PATH

class SATPlanner:
    """
    Planner class to compute the optimal path for a network slice based on satellite resources availability.
    """
    def satplanner(self, intent):

        resources = self.__retrieve_resources()

        type = intent.get("ietf-network-slice-service:network-slice-services", {}).get("slo-sle-templates", {}).get("slo-sle-template", [])[0].get("id")
        source = intent.get("ietf-network-slice-service:network-slice-services", {}).get("slice-service", [])[0].get("sdps", {}).get("sdp", [])[0].get("node-id") 
        destination = intent.get("ietf-network-slice-service:network-slice-services", {}).get("slice-service", [])[0].get("sdps", {}).get("sdp", [])[1].get("node-id") 
        service = intent.get("ietf-network-slice-service:network-slice-services", {}).get("slice-service", [])[0].get("sdps", {}).get("sdp", [])[0].get("match-criterion",[]).get("match-type")
        serviceid = intent.get("ietf-network-slice-service:network-slice-services", {}).get("slice-service", [])[0].get("sdps", {}).get("sdp", [])[0].get("match-criterion",[]).get("value")
        bandwidth = intent.get("ietf-network-slice-service:network-slice-services", {}).get("slo-sle-templates", {}).get("slo-sle-template", [])[0].get("slo-policy", {}).get("metric-bound",[])[0].get("bound")
        delay =  intent.get("ietf-network-slice-service:network-slice-services", {}).get("slo-sle-templates", {}).get("slo-sle-template", [])[0].get("slo-policy", {}).get("metric-bound",[])[1].get("bound")



        return {""}

    def __retrieve_resources(self):
        
        with open(os.path.join(SRC_PATH, "planner/sat_resurces_ddbb.json"), "r") as archivo:
            resources = json.load(archivo)
      
        return resources
+35 −0
Original line number Diff line number Diff line
{
"satellite-segment-nodes":[
    {
        "segmentId": 1,
        "nodeId": 1,
        "name": "HUB_STATION",
        "source": "HUB",
        "destination": "STATION",
        "links":{
            "link":[
                {
                    "link-id": "1",
                    "slo-profile":"A",
                    "type": "GEO" ,
                    "bandwidth": 4,
                    "capacity": 10,
                    "latency": 50,
                    "FRW_frequency": 1200000,
                    "RTN_frequency": 1338000                   
                },
                {
                    "link-id": "2",
                    "slo-profile":"B",
                    "type": "LEO" ,
                    "bandwidth": 8,
                    "capacity": 20,
                    "latency": 30,
                    "FRW_frequency": 12000004,
                    "RTN_frequency": 1338000                   
                }]
             }
  
        }
    ]
}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -267,6 +267,9 @@ class SAT_NMS:
            print(f"Error al aplicar el shaper; error code:"+str(response.json().get("error_code",None))+ "; error log: "+str(response.json().get("error_log",None)))
            return None

def actualizacion_ddbb():
    #función para actualizar el estado de los recursos en la BBDD. importante que sea una vez que se haya realizado la configuración en el NMS 
    return



Loading