From 1a650c3076c03324bfdfe6754a125f0e1fa8a145 Mon Sep 17 00:00:00 2001 From: rahhal Date: Thu, 26 Jun 2025 09:45:52 +0000 Subject: [PATCH 1/3] Challanege 1 - Use NBI instead of uploading templates to webui --- src/Constants.py | 1 + src/helpers.py | 20 ++- src/network_slice_controller.py | 207 +++++++++++++++++++++----------- 3 files changed, 142 insertions(+), 86 deletions(-) diff --git a/src/Constants.py b/src/Constants.py index f699aed..8916cb3 100644 --- a/src/Constants.py +++ b/src/Constants.py @@ -31,5 +31,6 @@ 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" # 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 abbac02..700adba 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -28,20 +28,14 @@ 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: Thu, 26 Jun 2025 09:45:52 +0000 Subject: [PATCH 2/3] Challanege 1 - Use NBI instead of uploading templates to webui --- src/Constants.py | 1 + src/helpers.py | 22 ++++++++-------------- src/network_slice_controller.py | 8 +++++--- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Constants.py b/src/Constants.py index 62ec457..7fd1dae 100644 --- a/src/Constants.py +++ b/src/Constants.py @@ -50,6 +50,7 @@ PCE_EXTERNAL = False DUMMY_MODE = True # Teraflow IP TFS_IP = ips.get('TFS_IP') +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 NEII IP diff --git a/src/helpers.py b/src/helpers.py index 080238e..df4a30f 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -26,24 +26,18 @@ logging.basicConfig( #Teraflow class tfs_connector(): - def simple_post(self, tfs_ip, service): + 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: Mon, 25 Aug 2025 14:50:10 +0200 Subject: [PATCH 3/3] Modify code to support both webui and nbi TFS uploads --- src/Constants.py | 7 +-- src/helpers.py | 34 +++++++++--- src/network_slice_controller.py | 75 ++++++++++++++------------- src/templates/ietfL2VPN_template.json | 66 +++++++++++------------ 4 files changed, 101 insertions(+), 81 deletions(-) diff --git a/src/Constants.py b/src/Constants.py index 7fd1dae..fee596b 100644 --- a/src/Constants.py +++ b/src/Constants.py @@ -17,7 +17,7 @@ import logging, os, json # Default logging level -DEFAULT_LOGGING_LEVEL = logging.DEBUG +DEFAULT_LOGGING_LEVEL = logging.INFO # Default port for NSC deployment NSC_PORT = 8081 @@ -47,10 +47,11 @@ PCE_EXTERNAL = False # Controller Flags # If True, config is not sent to controllers -DUMMY_MODE = True +DUMMY_MODE = False # Teraflow IP TFS_IP = ips.get('TFS_IP') -path = "restconf/data/ietf-l2vpn-svc:l2vpn-svc/vpn-services" +UPLOAD_TYPE = "NBI" # "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 NEII IP diff --git a/src/helpers.py b/src/helpers.py index df4a30f..0e15079 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -26,18 +26,40 @@ logging.basicConfig( #Teraflow class tfs_connector(): - def simple_post(self, tfs_ip, service, path): + def webui_post(self, tfs_ip, service): 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('