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

Merge branch 'feat/28-tid-improvements-and-fixes-on-layer-2-and-layer-3-realizers' into 'develop'

Resolve "(TID) Improvements and fixes on layer 2 and layer 3 realizers"

See merge request !28
parents d0a1d22e 4037a3ca
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -618,7 +618,7 @@ class Api:
                        slice_type = "L2"
                        logging.warning(f"Slice type not found in slice intent. Defaulting to L2")
                    logging.debug(f"Send slice to delete in TFS with slice_type {slice_type}")
                    tfs_connector().nbi_delete(current_app.config["TFS_IP"], slice_type, slice.get("id"))
                    tfs_connector().nbi_delete(current_app.config["RESTCONF_IP"], slice_type, slice.get("id"))
                if current_app.config["TFS_L2VPN_SUPPORT"]:
                    self.slice_service.tfs_l2vpn_delete()
            
@@ -670,7 +670,7 @@ class Api:
                        slice_type = "L2"
                        logging.warning(f"Slice type not found in slice intent. Defaulting to L2")
                    logging.debug(f"Send slice to delete in TFS with slice_type {slice_type}")
                    tfs_connector().nbi_delete(current_app.config["TFS_IP"], slice_type, existing_slice.get("id"))
                    tfs_connector().nbi_delete(current_app.config["RESTCONF_IP"], slice_type, existing_slice.get("id"))
                if current_app.config["TFS_L2VPN_SUPPORT"]:
                    self.slice_service.tfs_l2vpn_delete()                

@@ -689,7 +689,7 @@ class Api:
                            slice_type = "L2"
                            logging.warning(f"Slice type not found in slice intent. Defaulting to L2")
                        logging.debug(f"Send slice to delete in TFS with slice_type {slice_type}")
                        tfs_connector().nbi_delete(current_app.config["TFS_IP"], slice_type, slice.get("id"))
                        tfs_connector().nbi_delete(current_app.config["RESTCONF_IP"], slice_type, slice.get("id"))
                    if current_app.config["TFS_L2VPN_SUPPORT"]:
                        self.slice_service.tfs_l2vpn_delete()
                delete_data_store(xpath)
+2 −2
Original line number Diff line number Diff line
@@ -31,14 +31,14 @@ def apply_metric_constraint(service, qos_class, constraint, vpn_id, layer_type):
                        "direction": "input-bw",
                        "vpn-id": vpn_id,
                        "cir": bandwidth,
                        "cbs": bandwidth*0.05
                        "cbs": int(bandwidth*0.05)
                    },
                    {
                        "type": "bw-per-svc",
                        "direction": "output-bw",
                        "vpn-id": vpn_id,
                        "cir": bandwidth,
                        "cbs": bandwidth*0.05
                        "cbs": int(bandwidth*0.05)
                    },
                ]
            }
+34 −4
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ import logging
from src.utils.safe_get import safe_get


def configure_match_criteria(network_access, sdp, layer_type):
def configure_match_criteria(network_access, site, sdp, layer_type):
    """Configura los criterios de coincidencia en el acceso a la red."""
    MATCH_TYPE_MAPPING = {
        "dscp": "dscp"
        "dscp": "dscp",
        "vlan": "dot1q",
        "any": "any"
    }
    if layer_type == "l3":
        MATCH_TYPE_MAPPING["source-ip-prefix"] = "ipv4-src-prefix"
@@ -41,6 +43,34 @@ def configure_match_criteria(network_access, sdp, layer_type):
        logging.warning(f"Unknown match type: {match_type}")
        return
    
    provider_address = safe_get(sdp, ["sdp", "attachment-circuits", "attachment-circuit", 0, "ac-ipv4-address"])
    prefix_length = safe_get(sdp, ["sdp", "attachment-circuits", "attachment-circuit", 0, "ac-ipv4-prefix-length"])
    lan = f"{provider_address}/{prefix_length}" if provider_address and prefix_length else None

    if layer_type == "l3" and match_type == "vlan":
        site["routing-protocols"] = {"routing-protocol": []}
        routing_protocol = {
            "type": "static",
            "static": {
                "cascaded-lan-prefixes": {
                    "ipv4-lan-prefixes": [
                        {
                            "lan": lan,
                            "lan-tag": value,
                            "next-hop": provider_address # This is not correct, should be the management ip of the provider router, but we don't have that info in the SDP. Need to check how to handle this.
                        }
                    ]
                }
            }
        }

        site["routing-protocols"]["routing-protocol"].append(routing_protocol)
        return

    # Do not add rule when match type is any
    if match_type == "any":
        return

    rule = {
        "id": f"match-{match_type}-{index}",
        "match-flow": {
+18 −7
Original line number Diff line number Diff line
@@ -33,19 +33,27 @@ def create_network_access(sdp, ietf_intent, connectivity_type, router_id, router
                "address-allocation-type": "static-address",
                "addresses": {
                    "provider-address": safe_get(sdp, ["sdp", "attachment-circuits", "attachment-circuit", 0, "ac-ipv4-address"]),
                    # "customer-address": "",
                    "customer-address": safe_get(sdp, ["sdp", "attachment-circuits", "attachment-circuit", 0, "ac-ipv4-address"]), # We set the same address for provider and customer because we don't have the customer address in the SDP. This is not correct and should be fixed in the future when we have that info.
                    "prefix-length": safe_get(sdp, ["sdp", "attachment-circuits", "attachment-circuit", 0, "ac-ipv4-prefix-length"])
                }
            }
        }

    if sdp['type'] == "sender":
        site_role = "hub-role"
    elif sdp['type'] == "receiver":
        site_role = "spoke-role"
    else:
        site_role = "any-to-any-role"

    network_access = {
        access_id: router_if,
        access_type: f"{connectivity_type}",
        # access_type: f"{connectivity_type}",
        access_type: "multipoint", # We set to multipoint to avoid errors in Teraflow
        "device-reference": router_id,
        "vpn-attachment": {
            "vpn-id": ietf_intent["id"],
            # "site-role": f"{sdp['type']}" # Revisar esto!!!!
            "site-role": site_role # This will be changed in the future. Hub and spoke roles are only for multipoint connectivity constructs, there is no defined roles por point to point constructs
        },
        "service": {
            "qos": {
@@ -63,9 +71,12 @@ def create_network_access(sdp, ietf_intent, connectivity_type, router_id, router
    }
    if layer_type == "l3":
        network_access["ip-connection"] = ip_connection
    
    # Configurar match criteria y SLOs
    configure_match_criteria(network_access, sdp, layer_type)
    configure_slos(network_access, ietf_intent, layer_type)
    elif layer_type == "l2": # This should not be needed, but we add it because TFS requires it
        network_access["connection"] = {
            "oam": {
                "md-name": "test",
                "md-level": 0
            }
        }
    
    return network_access
+12 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
import logging
from src.utils.safe_get import safe_get
from .create_network_access import create_network_access
from .configure_match_criteria import configure_match_criteria
from .configure_slos import configure_slos

def create_site_from_sdp(sdp, ietf_intent, connectivity_type, layer_type):
    """
@@ -39,6 +41,8 @@ def create_site_from_sdp(sdp, ietf_intent, connectivity_type, layer_type):
    
    logging.debug(f"Configured site for SDP {safe_get(sdp, ['sdp', 'id'])} with location: {location}, router_id: {router_id}, router_if: {router_if}")
    
    network_access = create_network_access(sdp, ietf_intent, connectivity_type, router_id, router_if, layer_type)

    # Crear estructura del site
    site = {
        "site-id": safe_get(sdp, ["sdp", "id"]),
@@ -55,8 +59,15 @@ def create_site_from_sdp(sdp, ietf_intent, connectivity_type, layer_type):
            "type": "provider-managed"
        },
        "site-network-accesses": {
            "site-network-access": [create_network_access(sdp, ietf_intent, connectivity_type, router_id, router_if, layer_type)]
            "site-network-access": [network_access]
        }
    }

    if layer_type == "l3":
        site["routing-protocols"] = {"routing-protocol": []}

    # Configure match criteria and SLOs
    configure_match_criteria(network_access, site, sdp, layer_type)
    configure_slos(network_access, ietf_intent, layer_type)
    
    return site
Loading