From fc16b40610986249153e18fc9650469671b46b95 Mon Sep 17 00:00:00 2001 From: rahhal Date: Thu, 26 Jun 2025 10:05:08 +0000 Subject: [PATCH 1/3] =?UTF-8?q?Challenge=20#3=20=E2=80=93=20L2VPN=20Suppor?= =?UTF-8?q?t=20-=20Change=20L2VPN=20realizer=20to=20use=20IETF=20L2NM=20YA?= =?UTF-8?q?NG=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- our-temp/ietf-l3vpn-service.json | 83 ++++++++++++ src/Constants.py | 9 +- src/helpers.py | 47 ++++--- src/network_slice_controller.py | 209 ++++++++++++++++++++----------- src/templates/l2vpn_request.json | 34 +++++ 5 files changed, 289 insertions(+), 93 deletions(-) create mode 100644 our-temp/ietf-l3vpn-service.json create mode 100644 src/templates/l2vpn_request.json diff --git a/our-temp/ietf-l3vpn-service.json b/our-temp/ietf-l3vpn-service.json new file mode 100644 index 0000000..9eb70db --- /dev/null +++ b/our-temp/ietf-l3vpn-service.json @@ -0,0 +1,83 @@ +{ + "ietf-l3vpn-svc:l3vpn-svc": { + "vpn-services": {"vpn-service": [{"vpn-id": "ietf-l3vpn-svc"}]}, + "sites": { + "site": [ + { + "site-id": "site_DC1", + "management": {"type": "ietf-l3vpn-svc:provider-managed"}, + "locations": {"location": [{"location-id": "DC1"}]}, + "devices": {"device": [{"device-id": "dc1", "location": "DC1"}]}, + "site-network-accesses": { + "site-network-access": [ + { + "site-network-access-id": "eth1", + "site-network-access-type": "ietf-l3vpn-svc:multipoint", + "device-reference": "dc1", + "vpn-attachment": {"vpn-id": "ietf-l3vpn-svc", "site-role": "ietf-l3vpn-svc:spoke-role"}, + "ip-connection": { + "ipv4": { + "address-allocation-type": "ietf-l3vpn-svc:static-address", + "addresses": { + "provider-address": "192.168.1.1", + "customer-address": "192.168.1.10", + "prefix-length": 24 + } + } + }, + "service": { + "svc-mtu": 1500, + "svc-input-bandwidth": 1000000000, + "svc-output-bandwidth": 1000000000, + "qos": {"qos-profile": {"classes": {"class": [{ + "class-id": "qos-realtime", + "direction": "ietf-l3vpn-svc:both", + "latency": {"latency-boundary": 10}, + "bandwidth": {"guaranteed-bw-percent": 100} + }]}}} + } + } + ] + } + }, + { + "site-id": "site_DC2", + "management": {"type": "ietf-l3vpn-svc:provider-managed"}, + "locations": {"location": [{"location-id": "DC2"}]}, + "devices": {"device": [{"device-id": "dc2", "location": "DC2"}]}, + "site-network-accesses": { + "site-network-access": [ + { + "site-network-access-id": "eth1", + "site-network-access-type": "ietf-l3vpn-svc:multipoint", + "device-reference": "dc2", + "vpn-attachment": {"vpn-id": "ietf-l3vpn-svc", "site-role": "ietf-l3vpn-svc:hub-role"}, + "ip-connection": { + "ipv4": { + "address-allocation-type": "ietf-l3vpn-svc:static-address", + "addresses": { + "provider-address": "192.168.2.1", + "customer-address": "192.168.2.10", + "prefix-length": 24 + } + } + }, + "service": { + "svc-mtu": 1500, + "svc-input-bandwidth": 1000000000, + "svc-output-bandwidth": 1000000000, + "qos": {"qos-profile": {"classes": {"class": [{ + "class-id": "qos-realtime", + "direction": "ietf-l3vpn-svc:both", + "latency": {"latency-boundary": 10}, + "bandwidth": {"guaranteed-bw-percent": 100} + }]}}} + } + } + ] + } + } + ] + } + } +} diff --git a/src/Constants.py b/src/Constants.py index 337be88..d5e54f7 100644 --- a/src/Constants.py +++ b/src/Constants.py @@ -1,4 +1,4 @@ -# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# Copyright 2025 Telefonica Innovación Digital S.L. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This file is an original contribution from Telefonica Innovación Digital S.L. - import logging, os # Default logging level DEFAULT_LOGGING_LEVEL = logging.INFO @@ -33,5 +31,10 @@ TEMPLATES_PATH = os.path.join(SRC_PATH, "templates") TFS_UPLOAD = False # Teraflow IP TFS_IP = "192.168.165.10" +path = "restconf/data/ietf-l2vpn-svc:l2vpn-svc/vpn-services" +#path_l3 = "restconf/data/ietf-l3vpn-svc:l3vpn-svc/vpn-services" + +#json_file = "/home/tfs/nsc-hackfest7/src/hackfest7/slice_request.json" +#/home/tfs/nsc-hackfest7/src/hackfest7/slice_request.json # Flag to determine if additional L2VPN configuration support is required for deploying L2VPNs with path selection TFS_L2VPN_SUPPORT = False \ No newline at end of file diff --git a/src/helpers.py b/src/helpers.py index 47adc16..4fcf2bb 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -1,4 +1,4 @@ -# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# Copyright 2025 Telefonica Innovación Digital S.L. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ import logging, requests, json from netmiko import ConnectHandler from src.Constants import DEFAULT_LOGGING_LEVEL +from requests.auth import HTTPBasicAuth # Configure logging to provide clear and informative log messages logging.basicConfig( @@ -23,25 +24,39 @@ logging.basicConfig( #Teraflow class tfs_connector(): - - def simple_post(self, tfs_ip, service): + #curl -X POST -H "Content-Type: application/json" --user "admin:admin" --data @ietf-l3vpn-service.json http://10.1.7.197/restconf/data/ietf-l3vpn-svc:l3vpn-svc/vpn-services + + def simple_post(self, tfs_ip,service,path): user="admin" password="admin" token="" - session = requests.Session() - session.auth = (user, password) - url=f'http://{tfs_ip}/webui' - response=session.get(url=url) - for item in response.iter_lines(): - if("csrf_token" in str(item)): - string=str(item).split(' Date: Thu, 26 Jun 2025 10:05:08 +0000 Subject: [PATCH 2/3] =?UTF-8?q?Challenge=20#3=20=E2=80=93=20L2VPN=20Suppor?= =?UTF-8?q?t=20-=20Change=20L2VPN=20realizer=20to=20use=20IETF=20L2NM=20YA?= =?UTF-8?q?NG=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- our-temp/ietf-l3vpn-service.json | 83 +++++++++++++++++++++++++ src/Constants.py | 4 +- src/helpers.py | 42 ++++++++----- src/network_slice_controller.py | 103 ++++++++++++++++--------------- src/templates/l2vpn_request.json | 34 ++++++++++ 5 files changed, 199 insertions(+), 67 deletions(-) create mode 100644 our-temp/ietf-l3vpn-service.json create mode 100644 src/templates/l2vpn_request.json diff --git a/our-temp/ietf-l3vpn-service.json b/our-temp/ietf-l3vpn-service.json new file mode 100644 index 0000000..9eb70db --- /dev/null +++ b/our-temp/ietf-l3vpn-service.json @@ -0,0 +1,83 @@ +{ + "ietf-l3vpn-svc:l3vpn-svc": { + "vpn-services": {"vpn-service": [{"vpn-id": "ietf-l3vpn-svc"}]}, + "sites": { + "site": [ + { + "site-id": "site_DC1", + "management": {"type": "ietf-l3vpn-svc:provider-managed"}, + "locations": {"location": [{"location-id": "DC1"}]}, + "devices": {"device": [{"device-id": "dc1", "location": "DC1"}]}, + "site-network-accesses": { + "site-network-access": [ + { + "site-network-access-id": "eth1", + "site-network-access-type": "ietf-l3vpn-svc:multipoint", + "device-reference": "dc1", + "vpn-attachment": {"vpn-id": "ietf-l3vpn-svc", "site-role": "ietf-l3vpn-svc:spoke-role"}, + "ip-connection": { + "ipv4": { + "address-allocation-type": "ietf-l3vpn-svc:static-address", + "addresses": { + "provider-address": "192.168.1.1", + "customer-address": "192.168.1.10", + "prefix-length": 24 + } + } + }, + "service": { + "svc-mtu": 1500, + "svc-input-bandwidth": 1000000000, + "svc-output-bandwidth": 1000000000, + "qos": {"qos-profile": {"classes": {"class": [{ + "class-id": "qos-realtime", + "direction": "ietf-l3vpn-svc:both", + "latency": {"latency-boundary": 10}, + "bandwidth": {"guaranteed-bw-percent": 100} + }]}}} + } + } + ] + } + }, + { + "site-id": "site_DC2", + "management": {"type": "ietf-l3vpn-svc:provider-managed"}, + "locations": {"location": [{"location-id": "DC2"}]}, + "devices": {"device": [{"device-id": "dc2", "location": "DC2"}]}, + "site-network-accesses": { + "site-network-access": [ + { + "site-network-access-id": "eth1", + "site-network-access-type": "ietf-l3vpn-svc:multipoint", + "device-reference": "dc2", + "vpn-attachment": {"vpn-id": "ietf-l3vpn-svc", "site-role": "ietf-l3vpn-svc:hub-role"}, + "ip-connection": { + "ipv4": { + "address-allocation-type": "ietf-l3vpn-svc:static-address", + "addresses": { + "provider-address": "192.168.2.1", + "customer-address": "192.168.2.10", + "prefix-length": 24 + } + } + }, + "service": { + "svc-mtu": 1500, + "svc-input-bandwidth": 1000000000, + "svc-output-bandwidth": 1000000000, + "qos": {"qos-profile": {"classes": {"class": [{ + "class-id": "qos-realtime", + "direction": "ietf-l3vpn-svc:both", + "latency": {"latency-boundary": 10}, + "bandwidth": {"guaranteed-bw-percent": 100} + }]}}} + } + } + ] + } + } + ] + } + } +} diff --git a/src/Constants.py b/src/Constants.py index fee596b..e038b5b 100644 --- a/src/Constants.py +++ b/src/Constants.py @@ -1,4 +1,4 @@ -# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# Copyright 2025 Telefonica Innovación Digital S.L. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This file is an original contribution from Telefonica Innovación Digital S.L. +# This file includes original contributions from Telefonica Innovación Digital S.L. import logging, os, json diff --git a/src/helpers.py b/src/helpers.py index 0e15079..928a6b5 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -1,4 +1,4 @@ -# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# Copyright 2025 Telefonica Innovación Digital S.L. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ import logging, requests, json from netmiko import ConnectHandler from src.Constants import DEFAULT_LOGGING_LEVEL +from requests.auth import HTTPBasicAuth # Configure logging to provide clear and informative log messages logging.basicConfig( @@ -30,20 +31,33 @@ class tfs_connector(): user="admin" password="admin" token="" - session = requests.Session() - session.auth = (user, password) - url=f'http://{tfs_ip}/webui' - response=session.get(url=url) - for item in response.iter_lines(): - if("csrf_token" in str(item)): - string=str(item).split(' Date: Tue, 26 Aug 2025 12:28:14 +0200 Subject: [PATCH 3/3] Modify code to realize l2vpn slices depending on the flag (webUI or NBI) --- our-temp/ietf-l3vpn-service.json | 83 -------- src/Constants.py | 12 +- src/helpers.py | 42 ++-- src/network_slice_controller.py | 128 ++++++------ ...ate.json => ietfL2VPN_template_empty.json} | 16 +- src/templates/ietfL3VPN_template.json | 184 ------------------ src/templates/l2vpn_request.json | 34 ---- 7 files changed, 100 insertions(+), 399 deletions(-) delete mode 100644 our-temp/ietf-l3vpn-service.json rename src/templates/{ietfL2VPN_template.json => ietfL2VPN_template_empty.json} (58%) delete mode 100644 src/templates/ietfL3VPN_template.json delete mode 100644 src/templates/l2vpn_request.json diff --git a/our-temp/ietf-l3vpn-service.json b/our-temp/ietf-l3vpn-service.json deleted file mode 100644 index 9eb70db..0000000 --- a/our-temp/ietf-l3vpn-service.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "ietf-l3vpn-svc:l3vpn-svc": { - "vpn-services": {"vpn-service": [{"vpn-id": "ietf-l3vpn-svc"}]}, - "sites": { - "site": [ - { - "site-id": "site_DC1", - "management": {"type": "ietf-l3vpn-svc:provider-managed"}, - "locations": {"location": [{"location-id": "DC1"}]}, - "devices": {"device": [{"device-id": "dc1", "location": "DC1"}]}, - "site-network-accesses": { - "site-network-access": [ - { - "site-network-access-id": "eth1", - "site-network-access-type": "ietf-l3vpn-svc:multipoint", - "device-reference": "dc1", - "vpn-attachment": {"vpn-id": "ietf-l3vpn-svc", "site-role": "ietf-l3vpn-svc:spoke-role"}, - "ip-connection": { - "ipv4": { - "address-allocation-type": "ietf-l3vpn-svc:static-address", - "addresses": { - "provider-address": "192.168.1.1", - "customer-address": "192.168.1.10", - "prefix-length": 24 - } - } - }, - "service": { - "svc-mtu": 1500, - "svc-input-bandwidth": 1000000000, - "svc-output-bandwidth": 1000000000, - "qos": {"qos-profile": {"classes": {"class": [{ - "class-id": "qos-realtime", - "direction": "ietf-l3vpn-svc:both", - "latency": {"latency-boundary": 10}, - "bandwidth": {"guaranteed-bw-percent": 100} - }]}}} - } - } - ] - } - }, - { - "site-id": "site_DC2", - "management": {"type": "ietf-l3vpn-svc:provider-managed"}, - "locations": {"location": [{"location-id": "DC2"}]}, - "devices": {"device": [{"device-id": "dc2", "location": "DC2"}]}, - "site-network-accesses": { - "site-network-access": [ - { - "site-network-access-id": "eth1", - "site-network-access-type": "ietf-l3vpn-svc:multipoint", - "device-reference": "dc2", - "vpn-attachment": {"vpn-id": "ietf-l3vpn-svc", "site-role": "ietf-l3vpn-svc:hub-role"}, - "ip-connection": { - "ipv4": { - "address-allocation-type": "ietf-l3vpn-svc:static-address", - "addresses": { - "provider-address": "192.168.2.1", - "customer-address": "192.168.2.10", - "prefix-length": 24 - } - } - }, - "service": { - "svc-mtu": 1500, - "svc-input-bandwidth": 1000000000, - "svc-output-bandwidth": 1000000000, - "qos": {"qos-profile": {"classes": {"class": [{ - "class-id": "qos-realtime", - "direction": "ietf-l3vpn-svc:both", - "latency": {"latency-boundary": 10}, - "bandwidth": {"guaranteed-bw-percent": 100} - }]}}} - } - } - ] - } - } - ] - } - } -} diff --git a/src/Constants.py b/src/Constants.py index 39a51bd..b05deea 100644 --- a/src/Constants.py +++ b/src/Constants.py @@ -1,4 +1,4 @@ -# Copyright 2025 Telefonica Innovación Digital S.L. +# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +# This file includes original contributions from Telefonica Innovación Digital S.L. + +import logging, os, json + # Default logging level DEFAULT_LOGGING_LEVEL = logging.INFO @@ -44,12 +48,16 @@ PCE_EXTERNAL = False # Controller Flags # If True, config is not sent to controllers DUMMY_MODE = False + +#####TERAFLOW##### # Teraflow IP TFS_IP = ips.get('TFS_IP') -UPLOAD_TYPE = "NBI" # "WEBUI" or "NBI" +UPLOAD_TYPE = "WEBUI" # "WEBUI" or "NBI" NBI_L2_PATH = "restconf/data/ietf-l2vpn-svc:l2vpn-svc/vpn-services" # Flag to determine if additional L2VPN configuration support is required for deploying L2VPNs with path selection TFS_L2VPN_SUPPORT = False + +#####IXIA##### # IXIA NEII IP IXIA_IP = ips.get('IXIA_IP') diff --git a/src/helpers.py b/src/helpers.py index 928a6b5..0e15079 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -1,4 +1,4 @@ -# Copyright 2025 Telefonica Innovación Digital S.L. +# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ import logging, requests, json from netmiko import ConnectHandler from src.Constants import DEFAULT_LOGGING_LEVEL -from requests.auth import HTTPBasicAuth # Configure logging to provide clear and informative log messages logging.basicConfig( @@ -31,33 +30,20 @@ class tfs_connector(): user="admin" password="admin" token="" - #session = requests.Session() - #session.auth = (user, password) - #url = f'http://{tfs_ip}/{path}' - url_l2 = f'http://{user}:{password}@{tfs_ip}/{path}' - #url_l3 = f'http://{user}:{password}@{tfs_ip}/{path_l3}' - logging.info(service) - #response=session.get(url=url) - #for item in response.iter_lines(): - # if("csrf_token" in str(item)): - # string=str(item).split('