Commit be514b78 authored by Pablo Armingol's avatar Pablo Armingol
Browse files

Update TFS IP address, refactor NSController methods, and add new JSON...

Update TFS IP address, refactor NSController methods, and add new JSON templates for optical slice management
parent 910cc1dd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ TEMPLATES_PATH = os.path.join(SRC_PATH, "templates")
# Flag to determine if configurations should be uploaded to Teraflow
TFS_UPLOAD = False
# Teraflow IP
TFS_IP = "10.95.86.58"
TFS_IP = "172.24.36.55"
# Flag to determine if additional L2VPN configuration support is
# required for deploying L2VPNs with path selection
TFS_L2VPN_SUPPORT = False
+71 −19
Original line number Diff line number Diff line
@@ -234,8 +234,8 @@ class NSController:
            if action == 'delete':
                logging.info("\n\n--------NEW REQUEST--------\n")
                logging.info("DELETE REQUEST RECEIVED: %s", intent_json)

                rules = self.__planner(intent_json ,action = action)
                rules = []
                # rules = self.__planner(intent_json ,action = action)
                tfs_request = self.__realizer(rules=rules)
            else:
                self.start_time = time.perf_counter()
@@ -249,7 +249,8 @@ class NSController:

                        self.__extract_data(intent)
                        self.__mapper(intent, action)
                        rules = self.__planner(intent,action = action)
                        with open(os.path.join(TEMPLATES_PATH, "rules_4.json"), 'r', encoding='utf-8') as file:
                            rules = json.load(file)
                        for rule in rules:
                            service_uuid = rule.get("network-slice-uuid")
                            logging.info(f"Rules generated by planner: \n {rule}")
@@ -946,9 +947,37 @@ class NSController:
        elif way == "OPTIC":      self.__optic_slice(ietf_intent,rules=rules)
        elif way == "L3oWDM":     self.__l3ipowdm_slice(ietf_intent,rules=rules)
        elif way == "DEL_L3oWDM": self.__del_l3ipowdm_slice(rules)
        elif way == "DEL_OPTIC":  self.__del_optic(rules)
        else: raise ValueError("Realization way not recognized")

        return realizing_request

    def __del_optic(self, rules):
        for rule in rules["actions"]:
            service_uuid = rule.get("content", {}).get("service", rule.get("tenant-uuid"))
            if not service_uuid:
                logging.warning("No service or tenant UUID found in rule, skipping deletion")
                continue

            # Garantizar que service_uuid es string, no lista
            if isinstance(service_uuid, list):
                service_uuid = ''.join(service_uuid)

            url = f"http://172.24.36.55/restconf/E2E/v1/service/tapi_lsp={service_uuid}"
            logging.info("Sending DELETE Media Channel request to Orchestrator: %s", url)

            try:
                response = requests.delete(url, timeout=300)
                time.sleep(1)
                if response.ok:
                    logging.info("Successfully deleted service: %s", service_uuid)
                else:
                    logging.warning("Failed to delete service: %s, status code: %d, response: %s",
                                    service_uuid, response.status_code, response.text)
            except requests.exceptions.RequestException as e:
                logging.error("RequestException during DELETE: %s", e)


    def __del_l3ipowdm_slice(self, rules):
        """
        Delete a Optical service request for an optical slice.
@@ -1029,25 +1058,48 @@ class NSController:
            logging.info("Processing rule: %s", rule["type"])
            if rule["type"] == "PROVISION_MEDIA_CHANNEL_OLS_PATH":

                origin_router_id = rule["content"]["src-sip-uuid"]
                destination_router_id = rule["content"]["dest-sip-uuid"]
                # direction = rule["content"]["direction"]
                bandwidth = rule["content"]["bandwidth-ghz"]
                # lower_frecuency = rule["content"]["lower-frequency-mhz"]
                # upper_frecuency = rule["content"]["upper-frequency-mhz"]
                service_uuid = str(uuid.uuid5(uuid.NAMESPACE_DNS, rule["content"]["ols-path-uuid"]))
                origin_router_id          = rule.get("content", {}).get("src-sip-uuid", "NONE")
                destination_router_id     = rule.get("content", {}).get("dest-sip-uuid", "NONE")
                direction                 = rule.get("content", {}).get("direction", "NONE")
                bandwidth                 =  "NONE"
                tenant_uuid               = rule.get("tenant-uuid", "NONE")
                layer_protocol_name       = rule.get("content", {}).get("layer-protocol-name", "NONE")
                layer_protocol_qualifier  = rule.get("content", {}).get("layer-protocol-qualifier", "NONE")
                function                  = rule.get("content", {}).get("route-objective-function", "NONE")
                capacity                  = rule.get("content", {}).get("capacity", "NONE")
                lower_frequency_mhz       = rule.get("content", {}).get("lower-frequency-mhz", "NONE")
                upper_frequency_mhz       = rule.get("content", {}).get("upper-frequency-mhz", "NONE")
                link_uuid_path            = rule.get("content", {}).get("link-uuid-path", [])
                granularity               = rule.get("content", {}).get("adjustment-granularity", "NONE")
                grid                      = rule.get("content", {}).get("grid-type", "NONE")
                srv_uuid                   = rule.get("content", {}).get("service", "NONE")

                self.__load_template(2, os.path.join(TEMPLATES_PATH, "TAPI_service.json"))
                tfs_request = json.loads(str(self.__teraflow_template))
                tfs_request["services"][0]["service_id"]["service_uuid"]["uuid"] = service_uuid
                tfs_request["services"][0]["service_id"]["service_uuid"]["uuid"] = tenant_uuid
                config_rules = tfs_request["services"][0]["service_config"]["config_rules"][0]

                config_rules["tapi_lsp"]["rule_set"]["src"]  = origin_router_id
                config_rules["tapi_lsp"]["rule_set"]["dst"]  = destination_router_id
                config_rules["tapi_lsp"]["rule_set"]["bw"]   = str(bandwidth)
                config_rules["tapi_lsp"]["rule_set"]["uuid"] = service_uuid
                config_rules["tapi_lsp"]["rule_set"]["uuid"] = srv_uuid
                config_rules["tapi_lsp"]["rule_set"]["bw"]   = (bandwidth)
                config_rules["tapi_lsp"]["rule_set"]["tenant_uuid"] = tenant_uuid
                config_rules["tapi_lsp"]["rule_set"]["direction"]   = direction
                config_rules["tapi_lsp"]["rule_set"]["layer_protocol_name"] = layer_protocol_name
                config_rules["tapi_lsp"]["rule_set"]["layer_protocol_qualifier"] = layer_protocol_qualifier
                config_rules["tapi_lsp"]["rule_set"]["lower_frequency_mhz"] = str(lower_frequency_mhz)
                config_rules["tapi_lsp"]["rule_set"]["upper_frequency_mhz"] = str(upper_frequency_mhz)
                config_rules["tapi_lsp"]["rule_set"]["link_uuid_path"] = link_uuid_path
                config_rules["tapi_lsp"]["rule_set"]["granularity"]    = granularity
                config_rules["tapi_lsp"]["rule_set"]["grid_type"]      = grid
                config_rules["tapi_lsp"]["rule_set"]["capacity"]       = capacity
                config_rules["tapi_lsp"]["rule_set"]["route_objective_function"]       = function

                logging.info("Sending Media Channel Service to Orchestrator")

                logging.info("Service to send: %s",tfs_request)
                self.tfs_post(self.tfs_ip, tfs_request)
                time.sleep(1)

            else:
                logging.info("Unsupported rule type for optical slice: %s", rule["type"])
+110 −0
Original line number Diff line number Diff line
@@ -4114,5 +4114,115 @@
                ]
            }
        }
    },
    {
        "slice_id": "ecoc25-short-path-188b19d3-3295-442a-8aa9-1a5ca63a44bd",
        "intent": {
            "ietf-network-slice-service:network-slice-services": {
                "slo-sle-templates": {
                    "slo-sle-template": [
                        {
                            "id": "LOW-DELAY",
                            "description": "Prefer direct link: delay <= 2ms",
                            "slo-policy": {
                                "metric-bound": [
                                    {
                                        "metric-type": "two-way-delay-maximum",
                                        "metric-unit": "milliseconds",
                                        "bound": 2
                                    }
                                ]
                            }
                        }
                    ]
                },
                "slice-service": [
                    {
                        "id": "slice-long",
                        "description": "Slice tolerant to intermediate hops",
                        "slo-sle-policy": {
                            "slo-sle-template": "LOW-DELAY"
                        },
                        "sdps": {
                            "sdp": [
                                {
                                    "id": "T1.2",
                                    "node-id": "T1.2",
                                    "attachment-circuits": {
                                        "attachment-circuit": [
                                            {
                                                "id": "ac-r1",
                                                "ac-ipv4-address": "10.10.1.1",
                                                "ac-ipv4-prefix-length": 24
                                            }
                                        ]
                                    }
                                },
                                {
                                    "id": "T1.1",
                                    "node-id": "T1.1",
                                    "attachment-circuits": {
                                        "attachment-circuit": [
                                            {
                                                "id": "ac-r2",
                                                "ac-ipv4-address": "10.10.2.1",
                                                "ac-ipv4-prefix-length": 24
                                            }
                                        ]
                                    }
                                },
                                {
                                    "id": "T2.1",
                                    "node-id": "T2.1",
                                    "attachment-circuits": {
                                        "attachment-circuit": [
                                            {
                                                "id": "ac-r3",
                                                "ac-ipv4-address": "10.10.3.1",
                                                "ac-ipv4-prefix-length": 24
                                            }
                                        ]
                                    }
                                },
                                {
                                    "id": "T1.3",
                                    "node-id": "T1.3",
                                    "attachment-circuits": {
                                        "attachment-circuit": [
                                            {
                                                "id": "ac-r3",
                                                "ac-ipv4-address": "10.10.4.1",
                                                "ac-ipv4-prefix-length": 24
                                            }
                                        ]
                                    }
                                }
                            ]
                        },
                        "connection-groups": {
                            "connection-group": [
                                {
                                    "id": "cg-long",
                                    "connectivity-type": "ietf-vpn-common:any-to-any",
                                    "connectivity-construct": [
                                        {
                                            "id": "cc-p2mp",
                                            "p2mp-sdp": {
                                                "root-sdp-id": "T2.1",
                                                "leaf-sdp-id": [
                                                    "T1.1",
                                                    "T1.2",
                                                    "T1.3"
                                                ]
                                            }
                                        }
                                    ]
                                }
                            ]
                        }
                    }
                ]
            }
        }
    }
]
 No newline at end of file
+4 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
            "service_config": {"config_rules": [
                {"action": 1, "tapi_lsp": {
                    "endpoint_id": {
                        "device_id": {"device_uuid": {"uuid": "TFS-OPTICAL"}},
                        "device_id": {"device_uuid": {"uuid": "TFS-PACKET"}},
                        "endpoint_uuid": {"uuid": "mgmt"}
                    },
                    "rule_set": {
@@ -34,7 +34,9 @@
                        "link_uuid_path": [
                        ],
                        "granularity": "",
                        "grid_type": ""
                        "grid_type": "",
                        "capacity": "",
                        "route_objective_function": ""
                    }
                }}
            ]}
+99 −0
Original line number Diff line number Diff line
[{
    "network-slice-uuid": "ecoc25-short-path-188b19d3-3295-442a-8aa9-1a5ca63a44bd",
    "viability": true,
    "actions": [
        {
            "type": "PROVISION_MEDIA_CHANNEL_OLS_PATH",
            "layer": "OPTICAL",
            "content": {
                "src-sip-uuid": "975f0b9a-309f-51d6-989f-10cf7c3b0829",
                "dest-sip-uuid": "f71a545e-7555-53ce-861e-113db1853a2c",
                "direction": "UNIDIRECTIONAL",
                "layer-protocol-name": "PHOTONIC_MEDIA",
                "layer-protocol-qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_OTS",
                "route-objective-function": "UNSPECIFIED",
                "service": "req-left-fiber1"
            },
            "tenant-uuid": "94033e13-d54d-4e6e-858e-da809cbfb51e"
        },
        {
            "type": "PROVISION_MEDIA_CHANNEL_OLS_PATH",
            "layer": "OPTICAL",
            "content": {
                "src-sip-uuid": "e1963c84-fbdd-529b-9036-b1909845c795",
                "dest-sip-uuid": "8ca602b1-73c5-586a-917d-793a9191c1f2",
                "direction": "UNIDIRECTIONAL",
                "layer-protocol-name": "PHOTONIC_MEDIA",
                "layer-protocol-qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_OTS",
                "route-objective-function": "UNSPECIFIED",
                "service": "req-left-fiber2"

            },
            "tenant-uuid": "cb0c197a-f5ae-4e92-bb20-ae42f2d0cdd7"

        },
        {
            "type": "PROVISION_MEDIA_CHANNEL_OLS_PATH",
            "layer": "OPTICAL",
            "content": {
                "src-sip-uuid": "2ccbb601-c0d9-5683-b407-52c3d1208358",
                "dest-sip-uuid": "9ef7d6f7-89bc-5911-b6ab-9de6a17fcf86",
                "direction": "UNIDIRECTIONAL",
                "layer-protocol-name": "PHOTONIC_MEDIA",
                "layer-protocol-qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_OTS",
                "route-objective-function": "UNSPECIFIED",
                 "service": "req-right-fiber1"

            },
            "tenant-uuid": "dfd311e7-8bb8-4f7d-99b9-606e73aa9131"
        },
        {
            "type": "PROVISION_MEDIA_CHANNEL_OLS_PATH",
            "layer": "OPTICAL",
            "content": {
                "src-sip-uuid": "798c54e4-40aa-599d-afb5-8a5bbc07c941",
                "dest-sip-uuid": "f82d2d49-8aab-54cd-84d9-429739b5f21d",
                "direction": "UNIDIRECTIONAL",
                "layer-protocol-name": "PHOTONIC_MEDIA",
                "layer-protocol-qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_OTS",
                "route-objective-function": "UNSPECIFIED",
                 "service": "req-right-fiber2"

            },
            "tenant-uuid": "e3d6502d-0330-4a3c-bb0c-1fb852794c0c"
        },
        {
            "type": "PROVISION_MEDIA_CHANNEL_OLS_PATH",
            "layer": "OPTICAL",
            "content": {
                "src-sip-uuid": "95bd9727-c673-5297-86a7-faaae7ea39cb",
                "dest-sip-uuid": "d30d68ec-43f2-5a0c-baf4-ab0fffda75f4",
                "direction": "UNIDIRECTIONAL",
                "layer-protocol-name": "DSR",
                "layer-protocol-qualifier": "tapi-dsr:DIGITAL_SIGNAL_TYPE_UNSPECIFIED",
                "capacity": "100-GBPS",
                 "service": "req-left-multiband"
            },
            "tenant-uuid": "14c8dc97-c58a-460d-9cec-bd4effb6a4e5"
        },
        {
            "type": "PROVISION_MEDIA_CHANNEL_OLS_PATH",
            "layer": "OPTICAL",
            "content": {
                "src-sip-uuid": "00000010-0000-0000-0000-000000060958",
                "dest-sip-uuid": "00000010-0000-0000-0000-000000060961",
                "direction": "BIDIRECTIONAL",
                "layer-protocol-name": "PHOTONIC_MEDIA",
                "layer-protocol-qualifier": "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_OCH",
                "capacity": "50-GHz",
                "lower-frequency-mhz": "193075000",
                "upper-frequency-mhz": "193125000",
                "adjustment-granularity": "G_6_25GHZ",
                "grid-type": "FLEX",
                 "service": "req-adtran"
            },
            "tenant-uuid": "95948296-ca2c-48f7-9549-e59a00f64a03"
        }
    ]
}
]
 No newline at end of file
Loading