diff --git a/src/api/main.py b/src/api/main.py index a4a59576927c4dd572cfcdda95b314ecc4f744da..221a45ff6c091f71d54a16008607d643ef507e21 100644 --- a/src/api/main.py +++ b/src/api/main.py @@ -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) diff --git a/src/realizer/restconf/service_types/builders/apply_metric_constraint.py b/src/realizer/restconf/service_types/builders/apply_metric_constraint.py index 06f799e467f46670c591d10774a0e3cc8455c1d6..f98ec941e498367980e4528b6e2c057ce292d9c1 100644 --- a/src/realizer/restconf/service_types/builders/apply_metric_constraint.py +++ b/src/realizer/restconf/service_types/builders/apply_metric_constraint.py @@ -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) }, ] } diff --git a/src/realizer/restconf/service_types/builders/configure_match_criteria.py b/src/realizer/restconf/service_types/builders/configure_match_criteria.py index ffff4788760aca7ddc6f223b6308dd53fcbce8de..af7c8e944db9920b51a85d54611728448b596ff6 100644 --- a/src/realizer/restconf/service_types/builders/configure_match_criteria.py +++ b/src/realizer/restconf/service_types/builders/configure_match_criteria.py @@ -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,11 +43,39 @@ 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": { MATCH_TYPE_MAPPING[match_type]: value } } - - network_access["service"]["qos"]["qos-classification-policy"]["rule"].append(rule) \ No newline at end of file + + network_access["service"]["qos"]["qos-classification-policy"]["rule"].append(rule) diff --git a/src/realizer/restconf/service_types/builders/create_network_access.py b/src/realizer/restconf/service_types/builders/create_network_access.py index c4725b510b84697ec955ef61e9d582b6f2ec46dc..0876f50fea1e70480f8ca7e2a40b814a96f69ec0 100644 --- a/src/realizer/restconf/service_types/builders/create_network_access.py +++ b/src/realizer/restconf/service_types/builders/create_network_access.py @@ -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 diff --git a/src/realizer/restconf/service_types/builders/create_site_from_sdp.py b/src/realizer/restconf/service_types/builders/create_site_from_sdp.py index 0053f0b5dd3aafc63502ee25ac26b39f2a3cd42a..5f05f42d24440b29d5c91e173c86564bc9c6de69 100644 --- a/src/realizer/restconf/service_types/builders/create_site_from_sdp.py +++ b/src/realizer/restconf/service_types/builders/create_site_from_sdp.py @@ -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 diff --git a/src/realizer/restconf/service_types/builders/initialize_structure.py b/src/realizer/restconf/service_types/builders/initialize_structure.py index 7d81f641282f80402f068fe9566fcbe580616be3..05c1267338a960c75730771c4793c3361ce07c52 100644 --- a/src/realizer/restconf/service_types/builders/initialize_structure.py +++ b/src/realizer/restconf/service_types/builders/initialize_structure.py @@ -29,10 +29,9 @@ def initialize_structure(vpn_id, connectivity_type, layer_type): } } if layer_type == "l2": - structure[f"ietf-{layer_type}vpn-svc:{layer_type}vpn-svc"]["vpn-services"]["vpn-service"] = { + structure[f"ietf-{layer_type}vpn-svc:{layer_type}vpn-svc"]["vpn-services"]["vpn-service"][0] = { "vpn-id": vpn_id, - "customer-name": "osm", - "vpn-svc-type": "vpws", # Lo dejamos en vpws porque es el unico que encaja - "svc-topo": connectivity_type, + "ce-vlan-preservation": False, + "ce-vlan-cos-preservation": False } return structure \ No newline at end of file