Loading src/config/.env.example +7 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,13 @@ IXIA_IP=127.0.0.1 # ------------------------- TFS_E2E_IP=127.0.0.1 # ------------------------- # Restconf Controller # ------------------------- RESTCONF_IP=127.0.0.1 # Options: TFS or IXIA SDN_CONTROLLER_TYPE=TFS # ------------------------- # WebUI # ------------------------- Loading src/config/config.py +4 −0 Original line number Diff line number Diff line Loading @@ -64,4 +64,8 @@ def create_config(app: Flask): # WebUI app.config["WEBUI_DEPLOY"] = os.getenv("WEBUI_DEPLOY", "false").lower() == "true" # Restconf Controller app.config["RESTCONF_IP"] = os.getenv("RESTCONF_IP", "127.0.0.1") app.config["SDN_CONTROLLER_TYPE"] = os.getenv("SDN_CONTROLLER_TYPE", "TFS") return app 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 +9 −6 Original line number Diff line number Diff line Loading @@ -95,12 +95,15 @@ class NSController: ietf_intents = nbi_processor(intent_json) for intent in ietf_intents: logging.info(intent) # Mapper rules = mapper(intent) 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 request = realizer(intent, controller_type=self.controller_type, response = self.response, rules = rules) for service in services: request = realizer(service, controller_type=self.controller_type, response = self.response, rules = rules) # Store slice request details if request: requests["services"].append(request) Loading src/mapper/extract_sdp_info.py 0 → 100644 +31 −0 Original line number Diff line number Diff line import logging from src.utils.safe_get import safe_get def extract_sdp_info(sdp_id, slice_service, connection_group_id, connectivity_construct_id): logging.debug(f"Extracting SDP info for SDP ID: {sdp_id}, Connection Group ID: {connection_group_id}, Connectivity Construct ID: {connectivity_construct_id}") logging.debug(f"Slice Service: {slice_service}") selected_sdp = next((sdp for sdp in safe_get(slice_service, ["sdps", "sdp"]) if sdp.get("id") == sdp_id), None) selected_match_criteria = None match_criteria_list = safe_get(selected_sdp, ["service-match-criteria", "match-criterion"]) logging.debug(f"Available match criteria: {match_criteria_list}") logging.debug(f"Selected SDP: {selected_sdp}") if match_criteria_list: # Buscar por connectivity construct if connectivity_construct_id: logging.debug(f"Looking for match criteria with target-connectivity-construct-id: {connectivity_construct_id}") selected_match_criteria = next((mc for mc in match_criteria_list if safe_get(mc, ["target-connectivity-construct-id"]) == connectivity_construct_id), None) # Si no, buscar por connection group if not selected_match_criteria and connection_group_id: logging.debug(f"Looking for match criteria with target-connection-group-id: {connection_group_id}") selected_match_criteria = next((mc for mc in match_criteria_list if safe_get(mc, ["target-connection-group-id"]) == connection_group_id), None) # Si no, usar el primero disponible if not selected_match_criteria: logging.debug("No specific match criteria found for connectivity construct or connection group. Using the first available match criteria.") selected_match_criteria = match_criteria_list[0] return selected_sdp, selected_match_criteria No newline at end of file Loading
src/config/.env.example +7 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,13 @@ IXIA_IP=127.0.0.1 # ------------------------- TFS_E2E_IP=127.0.0.1 # ------------------------- # Restconf Controller # ------------------------- RESTCONF_IP=127.0.0.1 # Options: TFS or IXIA SDN_CONTROLLER_TYPE=TFS # ------------------------- # WebUI # ------------------------- Loading
src/config/config.py +4 −0 Original line number Diff line number Diff line Loading @@ -64,4 +64,8 @@ def create_config(app: Flask): # WebUI app.config["WEBUI_DEPLOY"] = os.getenv("WEBUI_DEPLOY", "false").lower() == "true" # Restconf Controller app.config["RESTCONF_IP"] = os.getenv("RESTCONF_IP", "127.0.0.1") app.config["SDN_CONTROLLER_TYPE"] = os.getenv("SDN_CONTROLLER_TYPE", "TFS") return app
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 +9 −6 Original line number Diff line number Diff line Loading @@ -95,12 +95,15 @@ class NSController: ietf_intents = nbi_processor(intent_json) for intent in ietf_intents: logging.info(intent) # Mapper rules = mapper(intent) 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 request = realizer(intent, controller_type=self.controller_type, response = self.response, rules = rules) for service in services: request = realizer(service, controller_type=self.controller_type, response = self.response, rules = rules) # Store slice request details if request: requests["services"].append(request) Loading
src/mapper/extract_sdp_info.py 0 → 100644 +31 −0 Original line number Diff line number Diff line import logging from src.utils.safe_get import safe_get def extract_sdp_info(sdp_id, slice_service, connection_group_id, connectivity_construct_id): logging.debug(f"Extracting SDP info for SDP ID: {sdp_id}, Connection Group ID: {connection_group_id}, Connectivity Construct ID: {connectivity_construct_id}") logging.debug(f"Slice Service: {slice_service}") selected_sdp = next((sdp for sdp in safe_get(slice_service, ["sdps", "sdp"]) if sdp.get("id") == sdp_id), None) selected_match_criteria = None match_criteria_list = safe_get(selected_sdp, ["service-match-criteria", "match-criterion"]) logging.debug(f"Available match criteria: {match_criteria_list}") logging.debug(f"Selected SDP: {selected_sdp}") if match_criteria_list: # Buscar por connectivity construct if connectivity_construct_id: logging.debug(f"Looking for match criteria with target-connectivity-construct-id: {connectivity_construct_id}") selected_match_criteria = next((mc for mc in match_criteria_list if safe_get(mc, ["target-connectivity-construct-id"]) == connectivity_construct_id), None) # Si no, buscar por connection group if not selected_match_criteria and connection_group_id: logging.debug(f"Looking for match criteria with target-connection-group-id: {connection_group_id}") selected_match_criteria = next((mc for mc in match_criteria_list if safe_get(mc, ["target-connection-group-id"]) == connection_group_id), None) # Si no, usar el primero disponible if not selected_match_criteria: logging.debug("No specific match criteria found for connectivity construct or connection group. Using the first available match criteria.") selected_match_criteria = match_criteria_list[0] return selected_sdp, selected_match_criteria No newline at end of file