Feat/25 tid improve mapping of slice requests

Closes #25 (closed)

Merge request reports

Loading
+7 −0
Changes for src/config/.env.example: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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
# -------------------------
+4 −0
Changes for src/config/config.py: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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
+3 −5
Changes for src/database/sysrepo_store.py: 3 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -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()
@@ -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:
@@ -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()
+31 −0
Changes for src/mapper/extract_sdp_info.py: 31 added lines, 0 removed lines.
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
+20 −0
Changes for src/mapper/get_service_template.py: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
from src.utils.safe_get import safe_get
from .get_template import get_template

def get_service_template(service_element, available_templates):
    """
    Extract template from service element.
    
    Args:
        service_element: Dictionary containing service configuration
        available_templates: List of available templates
        
    Returns:
        Template object or None
    """
    if "slo-sle-template" in service_element:
        template_ref = safe_get(service_element, ["slo-sle-template"])
        return get_template(template_ref, available_templates)
    elif "service-slo-sle-policy" in service_element:
        return safe_get(service_element, ["service-slo-sle-policy"])
    return None
 No newline at end of file
Loading
Loading