Commit c72736f9 authored by Maria Ruiz's avatar Maria Ruiz
Browse files

mejoras planner y sat nms

parent 28f953b8
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -287,14 +287,18 @@ class NSController:
                    self.__extract_data(intent)
                    self.__store_data(intent, slice_id)       
                    # Mapper
                    self.__mapper(intent)
                    
                    # Realizer
                    if self.controller_type == "sat":
                        viability = self.__mapper(intent)
                        if viability != "error":
                            tfs_request, sat_request = self.__realizer(intent)
                            requests["services"].append(tfs_request)
                            requests2 = {"services":[]}
                            requests2["services"].append(sat_request)
                        logging.info(f"Realizing request: {tfs_request} and {sat_request}")
                            logging.info(f"Realizing request to: SAT NMS {tfs_request} and SAT RM {sat_request}")
                        else:
                            logging.info("Slice request cannot be realized due to insufficient satellite resources")
                    else:
                        tfs_request = self.__realizer(intent)
                        requests["services"].append(tfs_request)
@@ -449,8 +453,10 @@ class NSController:
                viability = SATPlanner().satplanner(ietf_intent)
                if viability == "error":
                    logging.info(f"Resource allocation : Not enough satellite resources")
                    return viability
                elif viability == "ok":
                    logging.info(f"Resource allocation : Sufficient satellite resources available")
                    return viability 
                else:
                    logging.info(f"Resource allocation : Partial resources available, need to configure shaper with CIR {viability} ")
                    return viability
+3 −3
Original line number Diff line number Diff line
@@ -27,11 +27,11 @@ class SATPlanner:
        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")
       
        #primero comprobamos los recursos disponibles 
        with open(os.path.join(SRC_PATH, "planner/sat_resurces_ddbb.json"), "r") as archivo:
        with open(os.path.join(SRC_PATH, "planner/sat_resources_ddbb.json"), "r") as archivo:
            data = json.load(archivo)

        links = data["satellite-segment-nodes"][0]["links"]["link"]
        total = sum(link.get("bandwidth", 0) for link in links)
        total = sum(link.get("bandwidth-Mbps", 0) for link in links)

        print("Total occupied bandwidth in satellite resources:", total)

@@ -46,5 +46,5 @@ class SATPlanner:
                return viability
            elif type == "A":
                extra = bandwidth - disponible 
                P4_cir = extra - 5 # CIR que hab´ra que configurar en el shaper para limitar el trafico de menor prioridad
                P4_cir = extra - 5 # CIR que hab que configurar en el shaper para limitar el trafico de menor prioridad
                return P4_cir
+31 −31
Original line number Diff line number Diff line
@@ -11,25 +11,25 @@
                    {
                        "link-id": "1",
                        "vlan-id": "106",
                    "slo-profile":"A",
                        "slo-profile": "B",
                        "type": "GEO",
                    "bandwidth": 4,
                    "latency": 50,
                        "bandwidth-Mbps": 60,
                        "latency": 10,
                        "FRW_frequency": 1200000,
                        "RTN_frequency": 1338000
                    },
                    {
                    "link-id": "2",
                    "vlan-id": "106",
                        "id": "2",
                        "vlan-id": "107",
                        "slo-profile": "B",
                        "type": "LEO",
                    "bandwidth": 8,
                    "latency": 30,
                    "FRW_frequency": 12000004,
                        "bandwidth-Mbps": 50,
                        "latency": 20,
                        "FRW_frequency": 1200000,
                        "RTN_frequency": 1338000
                }]
                    }
  
                ]
            }
        }
    ]
}
 No newline at end of file
+25 −23
Original line number Diff line number Diff line
@@ -26,21 +26,13 @@ class SAT_NMS:

    def nscSATNMS(self, json_data):
        
        print(f'\n\n{json_data}\n')

        logging.info("Processing satellite slice request")

        src_node_id = json_data.get("src_node_id", None)
        dst_node_ip = json_data.get("dst_node_id", None)
        src_node_ip = json_data.get("src_node_ip", None)
        dst_node_ip = json_data.get("dst_node_ip", None)
        vlan_id = json_data.get("vlan_id", None)
        QoS_profile = json_data.get("QoS_profile", None)
        bandwidth = json_data.get("bandwidth", None)
        latency = json_data.get("latency", None)
        tolerance = json_data.get("tolerance", None)
        shaper = json_data.get("CIR", None)
        
        shaper = None
        bandwidth = None
        validation = None

@@ -54,7 +46,6 @@ class SAT_NMS:
            #mapeo QoS:
            if QoS_profile == "A":
                qos_mapped = "qos:0 QoS_P7"
                shaper ="shaper:0 shaper1"
            elif QoS_profile == "B":
                qos_mapped = "qos:2 QoS_P4"
            elif QoS_profile == "C":
@@ -68,14 +59,15 @@ class SAT_NMS:
            if validation == "error":
                return
            else:
                print(f'\n\n{add_route_controller}\n')
                print(f'\n\n')
                #print(f'\n\n{add_route_controller}\n')

            add_route_station, validation = self.add_routes_station(self.satnms_ip, num_service, vlan_id, qos_mapped)
            if validation == "error":
                return
            else:
                print(f'\n\n{add_route_station}\n')

                print(f'\n\n')
                #print(f'\n\n{add_route_station}\n')

            #cambio del bandwidth en función del symbol rate. Aquí ojoporque lo que soporta el NMS es limitado. Mejor para las pruebas a none y reefinar si queda tiempo 
            if bandwidth is not None:
@@ -93,7 +85,7 @@ class SAT_NMS:
                else:
                    print(f'\n\n{shaper_applied}\n')

            self.actualizacion_ddbb(json_data)
            self.actualizacion_ddbb(json_data,self.satnms_ip)


        else: 
@@ -107,7 +99,7 @@ class SAT_NMS:

        if HTTPStatus.OK == response.status_code:
            cookies = response.cookies
            logging.info("sesion iniciada en el NMS")
            #logging.info("sesion iniciada en el NMS")
            #print(f'\n\n{cookies}\n')
            return cookies
            
@@ -282,10 +274,18 @@ class SAT_NMS:
            print("No se pudo iniciar sesion en el NMS")
            return None

        url = "http://"+ip+":8000/api/object/write/qos=2"
       #primero hay que modificar el valor del max_cir en el shaper y luego asignarlo al el perfil de QoS

        url = "http://"+ip+":8000/api/object/write/shaper=0"
        body_dict = {
            "shaper": shaper
            "max_cir": shaper
        }
        payload = json.dumps(body_dict)
        response = requests.post(url, cookies=session, auth=('admin', '12345'), data=payload)
       
        url = "http://"+ip+":8000/api/object/write/qos=2"
        body_dict = {
            "shaper": "shaper:0 shaper1"
        }

        payload = json.dumps(body_dict)
@@ -329,10 +329,12 @@ class SAT_NMS:
        else:
            type = "GEO"
       
        FRW_frequency = self.get_controller_data(ip).get("tx_freq", None)
        RTN_frequency = self.get_controller_data(ip).get("rx_freq", None)
        nms_data = self.get_controller_data(ip)
        FRW_frequency = nms_data["reply"]["tx_frq"]
        RTN_frequency = nms_data["reply"]["a_dama_tx_frq"]


        with open(os.path.join(SRC_PATH, "planner/sat_resurces_ddbb.json"), "r") as archivo:
        with open(os.path.join(SRC_PATH, "planner/sat_resources_ddbb.json"), "r") as archivo:
            data = json.load(archivo)
        links = data["satellite-segment-nodes"][0]["links"]["link"]
        next_id = len(links) + 1
@@ -341,12 +343,12 @@ class SAT_NMS:
            "vlan-id": vlan_id,
            "slo-profile":QoS_profile,
            "type": type,
            "bandwidth": bandwidth,
            "bandwidth-Mbps": bandwidth,
            "latency": latency,
            "FRW_frequency": FRW_frequency,
            "RTN_frequency": RTN_frequency     
        }
        links.append(new_link)
        with open(os.path.join(SRC_PATH, "planner/sat_resurces_ddbb.json"), "w") as archivo:
        with open(os.path.join(SRC_PATH, "planner/sat_resources_ddbb.json"), "w") as archivo:
            json.dump(data, archivo, indent=4)      
            logging.info("Database updated with new link")    
 No newline at end of file
+12 −8
Original line number Diff line number Diff line
@@ -28,16 +28,18 @@ class SAT_RM:
        configuraciones = {}
        ip = self.ixia_ip
        puerto = "5"
        activacion = False #cambiar a true para activar perfiles IXIA

        latency = json_data.get("latency", None)

        if activacion is True:

        configuracion = self.delay(latency)


            configuracion = self.delay(latency,activacion)
            # Enviar la configuración
            automatizacion.envio_peticion(ip, puerto, configuracion)
            return automatizacion.obtener_informacion_puerto(ip, puerto)
        else:
            return


    def delay(self,delay_perfil):
@@ -46,3 +48,5 @@ class SAT_RM:
        configuracion_delay = automatizacion.cambiar_perfil_puerto_delay(delay_perfil)
        print(f"Config delay:\n{configuracion_delay}")
        return configuracion_delay 
      
                  
 No newline at end of file
Loading