Loading src/database/sysrepo_store.py +3 −5 Original line number Diff line number Diff line Loading @@ -33,10 +33,9 @@ def create_data_store(intent: dict, xpath: str= ""): sess = conn.start_session() try: logging.info(f"Creating data at {xpath}") _write_dict(sess, xpath, intent) sess.apply_changes() logging.info(f"Created data at {xpath}") logging.debug(f"Created data at {xpath}") return True except Exception as e: sess.discard_changes() Loading Loading @@ -129,7 +128,7 @@ def patch_data_store(intent: dict, xpath: str = ""): # PATCH: Merge con datos existentes _write_dict(sess, xpath, intent) sess.apply_changes() logging.info(f"Merged data at {xpath}") logging.debug(f"Merged data at {xpath}") return True except Exception as e: Loading @@ -148,10 +147,9 @@ def delete_data_store(xpath: str = ""): sess = conn.start_session() try: logging.info(f"Deleting data at {xpath}") sess.delete_item(xpath) sess.apply_changes() logging.info(f"Deleted data at {xpath}") logging.debug(f"Deleted data at {xpath}") return True except Exception as e: sess.discard_changes() Loading src/main.py +3 −2 Original line number Diff line number Diff line Loading @@ -95,9 +95,10 @@ class NSController: ietf_intents = nbi_processor(intent_json) for intent in ietf_intents: logging.info(intent) # Mapper services, rules = mapper(intent) logging.info(f"Services: {services}") services, rules = mapper(intent, controller_type=self.controller_type) logging.debug(f"Services: {services}") # Build response self.response = build_response(intent, self.response, controller_type= self.controller_type) # Realizer Loading src/mapper/main.py +78 −74 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ from src.realizer.main import realizer from flask import current_app from src.database.sysrepo_store import get_data_store, create_data_store, delete_data_store, update_data_store, normalize_libyang_data def mapper(ietf_intent): def mapper(ietf_intent, controller_type="TFS"): """ Map an IETF network slice intent to the most suitable Network Resource Partition (NRP). Loading @@ -42,6 +42,9 @@ def mapper(ietf_intent): Returns: dict or None: Optimal path if planner is enabled; otherwise, None. """ optimal_path = None services = [ietf_intent] if current_app.config["NRP_ENABLED"]: # Retrieve NRP view nrp_view = realizer(None, True, "READ") Loading Loading @@ -77,7 +80,8 @@ def mapper(ietf_intent): if current_app.config["PLANNER_ENABLED"]: optimal_path = Planner().planner(ietf_intent, current_app.config["PLANNER_TYPE"]) logging.debug(f"Optimal path: {optimal_path}") #return optimal_path if controller_type == "RESTCONF": # Initialize available templates templates = get_data_store("/ietf-network-slice-service:network-slice-services/slo-sle-templates/slo-sle-template") normalized_templates = normalize_libyang_data(templates) Loading src/realizer/main.py +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ def realizer(service, need_nrp=False, order=None, nrp=None, controller_type=None return None way = selected_way else: way = service["way"] way = service.get("way", None) or safe_get(service, ['ietf-network-slice-service:network-slice-services', 'slice-service', 0, 'service-tags', 'tag-type', 0, 'tag-type-value', 0]) logging.info(f"Selected way: {way}") request = select_way(controller=controller_type, way=way, ietf_intent=service, response=response, rules = rules) return request src/realizer/tfs/service_types/tfs_l2vpn.py +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ def tfs_l2vpn(ietf_intent, response): """ # Hardcoded router endpoints # TODO (should be dynamically determined) logging.info(ietf_intent) origin_router_id = safe_get(ietf_intent, ["ietf-network-slice-service:network-slice-services", "slice-service", 0, "sdps", "sdp", 0, "attachment-circuits", "attachment-circuit", 0, "sdp-peering", "peer-sap-id"]) if not origin_router_id: logging.warning("Origin router ID not found in the intent. Skipping L2VPN realization.") Loading Loading
src/database/sysrepo_store.py +3 −5 Original line number Diff line number Diff line Loading @@ -33,10 +33,9 @@ def create_data_store(intent: dict, xpath: str= ""): sess = conn.start_session() try: logging.info(f"Creating data at {xpath}") _write_dict(sess, xpath, intent) sess.apply_changes() logging.info(f"Created data at {xpath}") logging.debug(f"Created data at {xpath}") return True except Exception as e: sess.discard_changes() Loading Loading @@ -129,7 +128,7 @@ def patch_data_store(intent: dict, xpath: str = ""): # PATCH: Merge con datos existentes _write_dict(sess, xpath, intent) sess.apply_changes() logging.info(f"Merged data at {xpath}") logging.debug(f"Merged data at {xpath}") return True except Exception as e: Loading @@ -148,10 +147,9 @@ def delete_data_store(xpath: str = ""): sess = conn.start_session() try: logging.info(f"Deleting data at {xpath}") sess.delete_item(xpath) sess.apply_changes() logging.info(f"Deleted data at {xpath}") logging.debug(f"Deleted data at {xpath}") return True except Exception as e: sess.discard_changes() Loading
src/main.py +3 −2 Original line number Diff line number Diff line Loading @@ -95,9 +95,10 @@ class NSController: ietf_intents = nbi_processor(intent_json) for intent in ietf_intents: logging.info(intent) # Mapper services, rules = mapper(intent) logging.info(f"Services: {services}") services, rules = mapper(intent, controller_type=self.controller_type) logging.debug(f"Services: {services}") # Build response self.response = build_response(intent, self.response, controller_type= self.controller_type) # Realizer Loading
src/mapper/main.py +78 −74 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ from src.realizer.main import realizer from flask import current_app from src.database.sysrepo_store import get_data_store, create_data_store, delete_data_store, update_data_store, normalize_libyang_data def mapper(ietf_intent): def mapper(ietf_intent, controller_type="TFS"): """ Map an IETF network slice intent to the most suitable Network Resource Partition (NRP). Loading @@ -42,6 +42,9 @@ def mapper(ietf_intent): Returns: dict or None: Optimal path if planner is enabled; otherwise, None. """ optimal_path = None services = [ietf_intent] if current_app.config["NRP_ENABLED"]: # Retrieve NRP view nrp_view = realizer(None, True, "READ") Loading Loading @@ -77,7 +80,8 @@ def mapper(ietf_intent): if current_app.config["PLANNER_ENABLED"]: optimal_path = Planner().planner(ietf_intent, current_app.config["PLANNER_TYPE"]) logging.debug(f"Optimal path: {optimal_path}") #return optimal_path if controller_type == "RESTCONF": # Initialize available templates templates = get_data_store("/ietf-network-slice-service:network-slice-services/slo-sle-templates/slo-sle-template") normalized_templates = normalize_libyang_data(templates) Loading
src/realizer/main.py +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ def realizer(service, need_nrp=False, order=None, nrp=None, controller_type=None return None way = selected_way else: way = service["way"] way = service.get("way", None) or safe_get(service, ['ietf-network-slice-service:network-slice-services', 'slice-service', 0, 'service-tags', 'tag-type', 0, 'tag-type-value', 0]) logging.info(f"Selected way: {way}") request = select_way(controller=controller_type, way=way, ietf_intent=service, response=response, rules = rules) return request
src/realizer/tfs/service_types/tfs_l2vpn.py +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ def tfs_l2vpn(ietf_intent, response): """ # Hardcoded router endpoints # TODO (should be dynamically determined) logging.info(ietf_intent) origin_router_id = safe_get(ietf_intent, ["ietf-network-slice-service:network-slice-services", "slice-service", 0, "sdps", "sdp", 0, "attachment-circuits", "attachment-circuit", 0, "sdp-peering", "peer-sap-id"]) if not origin_router_id: logging.warning("Origin router ID not found in the intent. Skipping L2VPN realization.") Loading