Loading src/common/Constants.py +11 −0 Original line number Diff line number Diff line Loading @@ -135,3 +135,14 @@ DEFAULT_SERVICE_HTTP_BASEURLS = { ServiceNameEnum.NBI .value : None, ServiceNameEnum.WEBUI.value : None, } def OpticalServiceType(value): if value == "multi_granular": return 1 elif value == "flexi_grid": return 2 elif value == "pmp": return 3 else: return 1 src/opticalcontroller/OpticalController.py +2 −2 Original line number Diff line number Diff line Loading @@ -43,8 +43,8 @@ def index(): return render_template('index.html') #@optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>') @optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>') #@optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>') @optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>') @optical.response(200, 'Success') @optical.response(404, 'Error, not found') class AddLightpath(Resource): Loading src/opticalcontroller/RSA.py +21 −35 Original line number Diff line number Diff line Loading @@ -309,7 +309,6 @@ class RSA(): #fib[band].keys().sort() #set_link_update(fib,link,test="restoration") def restore_optical_band(self, optical_band_id, slots, band): for i in slots: Loading @@ -318,11 +317,6 @@ class RSA(): #self.optical_bands[optical_band_id][band].append(int(i)) #self.optical_bands[optical_band_id][band].sort() def restore_optical_band_2(self, optical_band_id, slots, band ,links): print(f"example of band { band}") print(f"example of slots {slots}") Loading Loading @@ -362,11 +356,7 @@ class RSA(): self.restore_link_2(fib, slots, band, link=link) if debug: print(fib[band]) if o_b_id is not None: if debug: print("restoring OB") print(f"invoking restore_optical_band o_b_id: {o_b_id} , slots {slots} , band {band} ") Loading Loading @@ -413,8 +403,6 @@ class RSA(): def del_band(self, flow, o_b_id = None): print(f"delete band {flow} ") flows = flow["flows"] band = None #slots = flow["slots"] Loading @@ -430,13 +418,17 @@ class RSA(): links= self.optical_bands[o_b_id]["links"] band = self.optical_bands[o_b_id]["band_type"] n_slots =self.optical_bands[o_b_id]["n_slots"] if isinstance(n_slots, str): if n_slots == "full_band": for key in self.optical_bands[o_b_id][band].keys(): slots.append(int(key)) slots.sort() elif isinstance(n_slots, int): if n_slots > 0: #slots=[i+1 for i in range(n_slots)] for key in self.optical_bands[o_b_id][band].keys(): slots.append(int(key)) slots.sort() for l in links: if debug: print(l) Loading Loading @@ -593,18 +585,6 @@ class RSA(): self.get_fibers_forward(links, slots, band) if bidir: self.get_fibers_backward(links, slots, band) ''' fibers_f = self.get_fibers_forward(links, slots, band) fibers_b = [] if bidir: fibers_b = self.get_fibers_backward(links, fibers_f, slots, band) if debug: print("forward") print(fibers_f) print("backward") print(fibers_b) ''' add = links[0] drop = links[-1] inport = "0" Loading Loading @@ -764,6 +744,12 @@ class RSA(): return t_flows, band, slots, {}, {} def rsa_computation(self, src, dst, rate, bidir): if self.flow_id == 0: self.flow_id += 1 else: if (self.db_flows[self.flow_id]["bidir"] == 1): self.flow_id += 2 else: self.flow_id += 1 self.db_flows[self.flow_id] = {} self.db_flows[self.flow_id]["flow_id"] = self.flow_id Loading src/service/service/ServiceServiceServicerImpl.py +44 −28 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ from common.tools.context_queries.Service import get_service_by_id from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Topology import json_topology_id from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.Constants import OpticalServiceType, DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.Settings import ( is_deployed_e2e_orch, is_deployed_optical, is_deployed_te ) Loading @@ -43,7 +43,7 @@ from .service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory from .task_scheduler.TaskScheduler import TasksScheduler from .tools.GeodesicDistance import gps_distance from .tools.OpticalTools import ( add_lightpath, delete_lightpath, adapt_reply, get_device_name_from_uuid, add_flex_lightpath, add_lightpath, delete_lightpath, adapt_reply, get_device_name_from_uuid, get_optical_band, refresh_opticalcontroller, DelFlexLightpath , extend_optical_band ) Loading Loading @@ -287,6 +287,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): dst = devs[1] bidir = None ob_band = None oc_type = 1 bitrate = 100 for constraint in service.service_constraints: if "bandwidth" in constraint.custom.constraint_type: Loading @@ -295,11 +296,19 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): bidir = int(constraint.custom.constraint_value) elif "optical-band-width" in constraint.custom.constraint_type: ob_band = int(constraint.custom.constraint_value) elif "type" in constraint.custom.constraint_type: oc_type = OpticalServiceType(str(constraint.custom.constraint_value)) reply_txt = "" # to get the reply form the optical module reply_txt = add_lightpath(src, dst, bitrate, bidir, ob_band) #multi-granular if oc_type == 1: reply_txt = add_flex_lightpath(src, dst, bitrate, bidir, ob_band) elif oc_type == 2: reply_txt = add_lightpath(src, dst, bitrate, bidir) else: reply_txt = add_flex_lightpath(src, dst, bitrate, bidir, ob_band) # reply with 2 transponders and 2 roadms reply_json = json.loads(reply_txt) LOGGER.debug('[optical] reply_json[{:s}]={:s}'.format(str(type(reply_json)), str(reply_json))) optical_band_txt = "" Loading Loading @@ -406,17 +415,24 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): dst = get_device_name_from_uuid(devices, devs[1]) bitrate = 100 bidir = 0 oc_type = 1 for constraint in service.service_constraints: if "bandwidth" in constraint.custom.constraint_type: bitrate = int(float(constraint.custom.constraint_value)) break if "type" in constraint.custom.constraint_type: oc_type = OpticalServiceType(str(constraint.custom.constraint_value)) ''' if service.service_constraints: bitrate = int(float( service.service_constraints[0].custom.constraint_value )) ''' #multi-granular if oc_type == 1: if len(service.service_config.config_rules) > 0: c_rules_dict = json.loads( service.service_config.config_rules[0].custom.resource_value) service.service_config.config_rules[0].custom.resource_value ) ob_id = None flow_id = None if "ob_id" in c_rules_dict: Loading src/service/service/tools/OpticalTools.py +19 −1 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ def refresh_opticalcontroller(topology_id : dict): log.debug(f"GetTopology Response {res}") def add_lightpath(src, dst, bitrate, bidir, ob_band) -> str: def add_flex_lightpath(src, dst, bitrate, bidir, ob_band) -> str: if not TESTING: urlx = "" headers = {"Content-Type": "application/json"} Loading @@ -143,6 +143,24 @@ def add_lightpath(src, dst, bitrate, bidir, ob_band) -> str: return reply_uni_txt return reply_bid_txt def add_lightpath(src, dst, bitrate, bidir) -> str: if not TESTING: urlx = "" headers = {"Content-Type": "application/json"} base_url = get_optical_controller_base_url() if bidir is None: bidir = 1 urlx = "{:s}/AddLightpath/{:s}/{:s}/{:s}/{:s}".format(base_url, src, dst, str(bitrate), str(bidir)) r = requests.put(urlx, headers=headers) print(f"addpathlight {r}") reply = r.text return reply else: if bidir is not None: if bidir == 0: return reply_uni_txt return reply_bid_txt def get_optical_band(idx) -> str: if not TESTING: Loading Loading
src/common/Constants.py +11 −0 Original line number Diff line number Diff line Loading @@ -135,3 +135,14 @@ DEFAULT_SERVICE_HTTP_BASEURLS = { ServiceNameEnum.NBI .value : None, ServiceNameEnum.WEBUI.value : None, } def OpticalServiceType(value): if value == "multi_granular": return 1 elif value == "flexi_grid": return 2 elif value == "pmp": return 3 else: return 1
src/opticalcontroller/OpticalController.py +2 −2 Original line number Diff line number Diff line Loading @@ -43,8 +43,8 @@ def index(): return render_template('index.html') #@optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>') @optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>') #@optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>') @optical.route('/AddLightpath/<string:src>/<string:dst>/<int:bitrate>/<int:bidir>') @optical.response(200, 'Success') @optical.response(404, 'Error, not found') class AddLightpath(Resource): Loading
src/opticalcontroller/RSA.py +21 −35 Original line number Diff line number Diff line Loading @@ -309,7 +309,6 @@ class RSA(): #fib[band].keys().sort() #set_link_update(fib,link,test="restoration") def restore_optical_band(self, optical_band_id, slots, band): for i in slots: Loading @@ -318,11 +317,6 @@ class RSA(): #self.optical_bands[optical_band_id][band].append(int(i)) #self.optical_bands[optical_band_id][band].sort() def restore_optical_band_2(self, optical_band_id, slots, band ,links): print(f"example of band { band}") print(f"example of slots {slots}") Loading Loading @@ -362,11 +356,7 @@ class RSA(): self.restore_link_2(fib, slots, band, link=link) if debug: print(fib[band]) if o_b_id is not None: if debug: print("restoring OB") print(f"invoking restore_optical_band o_b_id: {o_b_id} , slots {slots} , band {band} ") Loading Loading @@ -413,8 +403,6 @@ class RSA(): def del_band(self, flow, o_b_id = None): print(f"delete band {flow} ") flows = flow["flows"] band = None #slots = flow["slots"] Loading @@ -430,13 +418,17 @@ class RSA(): links= self.optical_bands[o_b_id]["links"] band = self.optical_bands[o_b_id]["band_type"] n_slots =self.optical_bands[o_b_id]["n_slots"] if isinstance(n_slots, str): if n_slots == "full_band": for key in self.optical_bands[o_b_id][band].keys(): slots.append(int(key)) slots.sort() elif isinstance(n_slots, int): if n_slots > 0: #slots=[i+1 for i in range(n_slots)] for key in self.optical_bands[o_b_id][band].keys(): slots.append(int(key)) slots.sort() for l in links: if debug: print(l) Loading Loading @@ -593,18 +585,6 @@ class RSA(): self.get_fibers_forward(links, slots, band) if bidir: self.get_fibers_backward(links, slots, band) ''' fibers_f = self.get_fibers_forward(links, slots, band) fibers_b = [] if bidir: fibers_b = self.get_fibers_backward(links, fibers_f, slots, band) if debug: print("forward") print(fibers_f) print("backward") print(fibers_b) ''' add = links[0] drop = links[-1] inport = "0" Loading Loading @@ -764,6 +744,12 @@ class RSA(): return t_flows, band, slots, {}, {} def rsa_computation(self, src, dst, rate, bidir): if self.flow_id == 0: self.flow_id += 1 else: if (self.db_flows[self.flow_id]["bidir"] == 1): self.flow_id += 2 else: self.flow_id += 1 self.db_flows[self.flow_id] = {} self.db_flows[self.flow_id]["flow_id"] = self.flow_id Loading
src/service/service/ServiceServiceServicerImpl.py +44 −28 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ from common.tools.context_queries.Service import get_service_by_id from common.tools.grpc.Tools import grpc_message_to_json, grpc_message_to_json_string from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Topology import json_topology_id from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.Constants import OpticalServiceType, DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.Settings import ( is_deployed_e2e_orch, is_deployed_optical, is_deployed_te ) Loading @@ -43,7 +43,7 @@ from .service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory from .task_scheduler.TaskScheduler import TasksScheduler from .tools.GeodesicDistance import gps_distance from .tools.OpticalTools import ( add_lightpath, delete_lightpath, adapt_reply, get_device_name_from_uuid, add_flex_lightpath, add_lightpath, delete_lightpath, adapt_reply, get_device_name_from_uuid, get_optical_band, refresh_opticalcontroller, DelFlexLightpath , extend_optical_band ) Loading Loading @@ -287,6 +287,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): dst = devs[1] bidir = None ob_band = None oc_type = 1 bitrate = 100 for constraint in service.service_constraints: if "bandwidth" in constraint.custom.constraint_type: Loading @@ -295,11 +296,19 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): bidir = int(constraint.custom.constraint_value) elif "optical-band-width" in constraint.custom.constraint_type: ob_band = int(constraint.custom.constraint_value) elif "type" in constraint.custom.constraint_type: oc_type = OpticalServiceType(str(constraint.custom.constraint_value)) reply_txt = "" # to get the reply form the optical module reply_txt = add_lightpath(src, dst, bitrate, bidir, ob_band) #multi-granular if oc_type == 1: reply_txt = add_flex_lightpath(src, dst, bitrate, bidir, ob_band) elif oc_type == 2: reply_txt = add_lightpath(src, dst, bitrate, bidir) else: reply_txt = add_flex_lightpath(src, dst, bitrate, bidir, ob_band) # reply with 2 transponders and 2 roadms reply_json = json.loads(reply_txt) LOGGER.debug('[optical] reply_json[{:s}]={:s}'.format(str(type(reply_json)), str(reply_json))) optical_band_txt = "" Loading Loading @@ -406,17 +415,24 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): dst = get_device_name_from_uuid(devices, devs[1]) bitrate = 100 bidir = 0 oc_type = 1 for constraint in service.service_constraints: if "bandwidth" in constraint.custom.constraint_type: bitrate = int(float(constraint.custom.constraint_value)) break if "type" in constraint.custom.constraint_type: oc_type = OpticalServiceType(str(constraint.custom.constraint_value)) ''' if service.service_constraints: bitrate = int(float( service.service_constraints[0].custom.constraint_value )) ''' #multi-granular if oc_type == 1: if len(service.service_config.config_rules) > 0: c_rules_dict = json.loads( service.service_config.config_rules[0].custom.resource_value) service.service_config.config_rules[0].custom.resource_value ) ob_id = None flow_id = None if "ob_id" in c_rules_dict: Loading
src/service/service/tools/OpticalTools.py +19 −1 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ def refresh_opticalcontroller(topology_id : dict): log.debug(f"GetTopology Response {res}") def add_lightpath(src, dst, bitrate, bidir, ob_band) -> str: def add_flex_lightpath(src, dst, bitrate, bidir, ob_band) -> str: if not TESTING: urlx = "" headers = {"Content-Type": "application/json"} Loading @@ -143,6 +143,24 @@ def add_lightpath(src, dst, bitrate, bidir, ob_band) -> str: return reply_uni_txt return reply_bid_txt def add_lightpath(src, dst, bitrate, bidir) -> str: if not TESTING: urlx = "" headers = {"Content-Type": "application/json"} base_url = get_optical_controller_base_url() if bidir is None: bidir = 1 urlx = "{:s}/AddLightpath/{:s}/{:s}/{:s}/{:s}".format(base_url, src, dst, str(bitrate), str(bidir)) r = requests.put(urlx, headers=headers) print(f"addpathlight {r}") reply = r.text return reply else: if bidir is not None: if bidir == 0: return reply_uni_txt return reply_bid_txt def get_optical_band(idx) -> str: if not TESTING: Loading