Commit e7de0d3e authored by Javier Velázquez's avatar Javier Velázquez
Browse files

Adapt code to be comnpatible with previous tests

parent 067c1b38
Loading
Loading
Loading
Loading
Loading
+3 −5
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()
+3 −2
Original line number Diff line number Diff line
@@ -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
+78 −74
Original line number Diff line number Diff line
@@ -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).

@@ -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")
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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