Loading src/Constants.py +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading src/helpers.py +8 −14 Original line number Diff line number Diff line Loading @@ -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('<input id="csrf_token" name="csrf_token" type="hidden" value=')[1] token=string.split(">")[0].strip('"') logging.debug("csrf token %s",token) files = {'descriptors': ("data.json", json.dumps(service).encode("utf-8"), "application/json")} url = f'http://{tfs_ip}/{path}' logging.info(service) headers = {'Content-Type': 'application/json'} json_data = json.dumps(service) json_decoded = json_data token={'csrf_token':token} response = session.post(url,files=files,data=token,timeout=60) logging.debug("Http response: %s",response.text) response = requests.post(url,headers=headers,data=json_decoded,timeout=60) logging.info(response.text) return response #CISCO Loading src/network_slice_controller.py +5 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ import json, time, os, logging, uuid, traceback, sys from datetime import datetime from src.helpers import tfs_connector, cisco_connector from src.Constants import DEFAULT_LOGGING_LEVEL, TFS_IP, TFS_L2VPN_SUPPORT, IXIA_IP, SRC_PATH, TEMPLATES_PATH, DUMMY_MODE, DUMP_TEMPLATES, PLANNER_ENABLED, NRP_ENABLED from src.Constants import DEFAULT_LOGGING_LEVEL, TFS_IP, TFS_L2VPN_SUPPORT, IXIA_IP, SRC_PATH, TEMPLATES_PATH, DUMMY_MODE, DUMP_TEMPLATES, PLANNER_ENABLED, NRP_ENABLED, path, path_l3 from src.realizers.ixia.NEII_V4 import NEII_controller from src.planner.planner import Planner Loading @@ -42,7 +42,7 @@ class NSController: - Slice Realization: Convert intents to specific network configurations (L2VPN, L3VPN) """ def __init__(self, controller_type = "TFS", tfs_ip=TFS_IP, ixia_ip =IXIA_IP, need_l2vpn_support=TFS_L2VPN_SUPPORT): def __init__(self, controller_type = "TFS", tfs_ip=TFS_IP, ixia_ip =IXIA_IP, need_l2vpn_support=TFS_L2VPN_SUPPORT, path=path): """ Initialize the Network Slice Controller. Loading @@ -61,6 +61,8 @@ class NSController: """ self.controller_type = controller_type self.tfs_ip = tfs_ip self.path = path self.path_l3 = path_l3 self.answer = {} self.cool_answer = {} self.start_time = 0 Loading Loading @@ -298,7 +300,7 @@ class NSController: # Optional: Upload template to Teraflow if not DUMMY_MODE: if self.controller_type == "TFS": response = tfs_connector().simple_post(self.tfs_ip, requests) response = tfs_connector().simple_post(self.tfs_ip, requests, self.path) if not response.ok: return self.__send_response(False, code=response.status_code, message=f"Teraflow upload failed. Response: {response.text}") Loading Loading
src/Constants.py +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
src/helpers.py +8 −14 Original line number Diff line number Diff line Loading @@ -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('<input id="csrf_token" name="csrf_token" type="hidden" value=')[1] token=string.split(">")[0].strip('"') logging.debug("csrf token %s",token) files = {'descriptors': ("data.json", json.dumps(service).encode("utf-8"), "application/json")} url = f'http://{tfs_ip}/{path}' logging.info(service) headers = {'Content-Type': 'application/json'} json_data = json.dumps(service) json_decoded = json_data token={'csrf_token':token} response = session.post(url,files=files,data=token,timeout=60) logging.debug("Http response: %s",response.text) response = requests.post(url,headers=headers,data=json_decoded,timeout=60) logging.info(response.text) return response #CISCO Loading
src/network_slice_controller.py +5 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ import json, time, os, logging, uuid, traceback, sys from datetime import datetime from src.helpers import tfs_connector, cisco_connector from src.Constants import DEFAULT_LOGGING_LEVEL, TFS_IP, TFS_L2VPN_SUPPORT, IXIA_IP, SRC_PATH, TEMPLATES_PATH, DUMMY_MODE, DUMP_TEMPLATES, PLANNER_ENABLED, NRP_ENABLED from src.Constants import DEFAULT_LOGGING_LEVEL, TFS_IP, TFS_L2VPN_SUPPORT, IXIA_IP, SRC_PATH, TEMPLATES_PATH, DUMMY_MODE, DUMP_TEMPLATES, PLANNER_ENABLED, NRP_ENABLED, path, path_l3 from src.realizers.ixia.NEII_V4 import NEII_controller from src.planner.planner import Planner Loading @@ -42,7 +42,7 @@ class NSController: - Slice Realization: Convert intents to specific network configurations (L2VPN, L3VPN) """ def __init__(self, controller_type = "TFS", tfs_ip=TFS_IP, ixia_ip =IXIA_IP, need_l2vpn_support=TFS_L2VPN_SUPPORT): def __init__(self, controller_type = "TFS", tfs_ip=TFS_IP, ixia_ip =IXIA_IP, need_l2vpn_support=TFS_L2VPN_SUPPORT, path=path): """ Initialize the Network Slice Controller. Loading @@ -61,6 +61,8 @@ class NSController: """ self.controller_type = controller_type self.tfs_ip = tfs_ip self.path = path self.path_l3 = path_l3 self.answer = {} self.cool_answer = {} self.start_time = 0 Loading Loading @@ -298,7 +300,7 @@ class NSController: # Optional: Upload template to Teraflow if not DUMMY_MODE: if self.controller_type == "TFS": response = tfs_connector().simple_post(self.tfs_ip, requests) response = tfs_connector().simple_post(self.tfs_ip, requests, self.path) if not response.ok: return self.__send_response(False, code=response.status_code, message=f"Teraflow upload failed. Response: {response.text}") Loading