Loading src/context/service/database/OpticalConfig.py +52 −47 Original line number Diff line number Diff line Loading @@ -120,12 +120,12 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): #channels = [channel['name']['index'] for channel in config['channels']] channel_num=0 for channel_params in config['media_channels']: channel_num+=1 channel_index=channel_params['channel_index'] if 'channel_index' is not None else None channels.append( { # "opticalconfig_uuid":opticalconfig_uuid, "roadm_uuid" : roadm_get_uuid(device_id), "channel_uuid" : channel_get_uuid(f'media_channel_{channel_num}',device_uuid), "channel_uuid" : channel_get_uuid(f'media_channel_{channel_index}',device_uuid), "band_name" : channel_params['band_name'], "lower_frequency" : int(channel_params["lower_frequency"]) if "lower_frequency" in channel_params else 0, "upper_frequency" : int(channel_params["upper_frequency"]) if "upper_frequency" in channel_params else 0, Loading @@ -134,7 +134,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): "status" : channel_params["status"] if "status" in channel_params else "", "type" : 'media_channel', "optical_band_parent":str(channel_params['optical_band_parent']) if 'optical_band_parent' in channel_params else None, "channel_index" : channel_params['channel_index'] if 'channel_index' in channel_params else None, "channel_index" : channel_index if channel_index is not None else None, } ) if 'optical_bands' in config and len(config['optical_bands']) > 0: Loading Loading @@ -255,7 +255,6 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): channel_index=stmt.excluded.channel_index, optical_band_parent = stmt.excluded.optical_band_parent ) ) Loading Loading @@ -357,22 +356,23 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig): if config_type == "optical-roadm": if 'flow_handled' in config and len(config['flow_handled'])==0 : config['flow_handled'] =[(None,None)] if channel_namespace is None and 'channel_namespace' in config['new_config']: channel_namespace=config['new_config']['channel_namespace'] if 'is_opticalband' in config and not config['is_opticalband']: #channels = [channel['name']['index'] for channel in config['channels']] channel_num=0 if 'flow_handled' in config and len(config['flow_handled'])>0 : num=0 flow_id=config["new_config"]["flow_id"] if 'flow_id' in config['new_config'] else None for flow in config['flow_handled']: src_port,dest_port=flow channel_num+=1 channel_index=flow_id+num num+=1 channels.append( { # "opticalconfig_uuid":opticalconfig_uuid, "roadm_uuid" : roadm_get_uuid(device_id), "channel_uuid" : channel_get_uuid(f'media_channel_{channel_num}',device_uuid), "channel_uuid" : channel_get_uuid(f'media_channel_{channel_index}',device_uuid), "band_name" : config['new_config']['band_type'], "lower_frequency" : int(int(config['new_config']['frequency']) - (int(config['new_config']['band'])/2)) if "frequency" in config['new_config'] else 0, "upper_frequency" :int(int(config['new_config']['frequency']) + (int(config['new_config']['band'])/2)) if "frequency" in config['new_config'] else 0, Loading @@ -381,23 +381,27 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig): "status" : config['new_config']["status"] if "status" in config['new_config'] else "", "type" : 'media_channel', "optical_band_parent":str( config['new_config']['ob_id']) if 'ob_id' in config['new_config'] else None, "channel_index":str(config["new_config"]["flow_id"]) if "flow_id" in config["new_config"] else None "channel_index":str(channel_index) if channel_index is not None else None } ) if 'is_opticalband' in config and config['is_opticalband']: #channels = [channel['name']['index'] for channel in config['channels']] channel_num=0 if 'flow_handled' in config and len(config['flow_handled'])>0 : ob_id =config['new_config']['ob_id'] if 'ob_id' in config['new_config'] else None num=0 for flow in config['flow_handled']: src_port,dest_port=flow LOGGER.info(f"udpate_optical_bands src: {src_port} and dest :{dest_port} for flow {flow}") channel_num+=1 channel_index=ob_id+num num+=1 channels.append( { # "opticalconfig_uuid":opticalconfig_uuid, "roadm_uuid" : roadm_get_uuid(device_id), "channel_uuid" : channel_get_uuid(f'optical_bands_{channel_num}',device_uuid), "channel_uuid" : channel_get_uuid(f'optical_bands_{channel_index}',device_uuid), "band_name" : config['new_config']['band_type'], "lower_frequency" : int(config['new_config']["low-freq"]) if "low-freq" in config['new_config'] else 0, "upper_frequency" : int(config['new_config']["up-freq"]) if "up-freq" in config['new_config'] else 0, Loading @@ -405,7 +409,7 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig): "src_port" : src_port, "status" : config['new_config']["status"] if "status" in config['new_config'] else "", "type" : 'optical_band', "channel_index" :str( config['new_config']['ob_id']) if 'ob_id' in config['new_config'] else None "channel_index" :str( channel_index) if channel_index is not None else None } ) Loading Loading @@ -551,6 +555,7 @@ def delete_opticalchannel(db_engine : Engine ,messagebroker : MessageBroker, re opticalconfig_uuid = request.opticalconfig_id.opticalconfig_uuid channels=[] config_type=None LOGGER.info(f"delete_optical_channel config {config}") if "type" in config : config_type= config["type"] if 'new_config' in config: Loading src/context/service/database/models/OpticalConfig/RoadmModel.py +3 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class ChannelModel(_Base): status = Column(String , nullable=True) src_port = Column(String, nullable=True) dest_port = Column(String, nullable=True) type = Column(String, nullable=False) optical_band_parent = Column(String, nullable=True) Loading @@ -74,6 +75,7 @@ class ChannelModel(_Base): "type" : self.type, "src_port" : self.src_port, "dest_port" : self.dest_port, "status":self.status, "optical_band_parent":self.optical_band_parent, "channel_index":self.channel_index Loading src/device/service/OpenConfigServicer.py +16 −13 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ class OpenConfigServicer(DeviceServiceServicer): resources:list[dict]=[] is_all_good=True config =json.loads(request.config) results=None LOGGER.info(f" config from openconfigservicer {config}") try: context_client = ContextClient() Loading @@ -95,23 +96,25 @@ class OpenConfigServicer(DeviceServiceServicer): for result in results: if not result : is_all_good=False LOGGER.info(f"resluts {results} and is_all_good {is_all_good}") if is_all_good: #driver.GetConfig(resource_keys=[]) config = json.loads(request.config) handled_flow=next((i for i in resources if i['resource_key']=='handled_flow'),None) flow_handled=[ ] if "new_config" in config and "flow" in config: for flow in config['flow']: src,dest= flow LOGGER.info(f"src {src} and dest {dest}") src_raw=get_endpoint_matching(device,src)if src != '0' else '0' dest_raw=get_endpoint_matching(device,dest) if dest != '0' else '0' src_name = src_raw.name if isinstance(src_raw,EndPoint) else '0' dest_name= dest_raw.name if isinstance(dest_raw,EndPoint) else '0' flow_handled.append((src_name,dest_name)) LOGGER.info(f"flow_handled {flow_handled}") if len(flow_handled)>0: config['flow_handled']=flow_handled # if "new_config" in config : # for flow in config['flow']: # src,dest= flow # LOGGER.info(f"src {src} and dest {dest}") # src_raw=get_endpoint_matching(device,src)if src != '0' else '0' # dest_raw=get_endpoint_matching(device,dest) if dest != '0' else '0' # src_name = src_raw.name if isinstance(src_raw,EndPoint) else '0' # dest_name= dest_raw.name if isinstance(dest_raw,EndPoint) else '0' # flow_handled.append((src_name,dest_name)) LOGGER.info(f"flow_handled {handled_flow}") if handled_flow is not None and len(handled_flow)>0: config['flow_handled']=handled_flow['value'] request.config=json.dumps(config) Loading Loading @@ -190,7 +193,7 @@ class OpenConfigServicer(DeviceServiceServicer): for result in results: if not result : is_all_good=False LOGGER.info(f"resluts {results} and is_all_good {is_all_good}") LOGGER.info(f"Disable resluts {results} and is_all_good {is_all_good}") if is_all_good: config = json.loads(request.config) flow_handled=[ ] Loading src/device/service/Tools.py +3 −1 Original line number Diff line number Diff line Loading @@ -491,6 +491,7 @@ def extract_resources(config : dict, device : Device) -> list[list[dict],dict]: #for tuple_value in config['flow'][device.name]: source_vals = [] dest_vals = [] handled_flow=[] for tuple_value in config['flow']: source_port = None destination_port = None Loading @@ -503,9 +504,10 @@ def extract_resources(config : dict, device : Device) -> list[list[dict],dict]: dst_endpoint_obj = get_endpoint_matching(device, destination_port_uuid) destination_port = dst_endpoint_obj.name dest_vals.append(destination_port) handled_flow.append((source_port,destination_port)) resources.append({'resource_key': 'source_port', 'value': source_vals}) resources.append({'resource_key': 'destination_port', 'value': dest_vals }) resources.append({'resource_key':'handled_flow','value':handled_flow}) if 'new_config' in config: lower_frequency = None upper_frequency = None Loading src/device/service/drivers/oc_driver/OCDriver.py +1 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,7 @@ class OCDriver(_Driver): timezone=pytz.utc) self._temp_address=f"{address}{port}" self.__out_samples = queue.Queue() logging.info(f"setting ocdriver address {self.address} and {self.port} {self.settings}") self.__netconf_handler = NetconfSessionHandler(self.address, self.port, **(self.settings)) self.__type = self.settings.get("type","optical-transponder") self.__device_uuid=device_uuid Loading Loading
src/context/service/database/OpticalConfig.py +52 −47 Original line number Diff line number Diff line Loading @@ -120,12 +120,12 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): #channels = [channel['name']['index'] for channel in config['channels']] channel_num=0 for channel_params in config['media_channels']: channel_num+=1 channel_index=channel_params['channel_index'] if 'channel_index' is not None else None channels.append( { # "opticalconfig_uuid":opticalconfig_uuid, "roadm_uuid" : roadm_get_uuid(device_id), "channel_uuid" : channel_get_uuid(f'media_channel_{channel_num}',device_uuid), "channel_uuid" : channel_get_uuid(f'media_channel_{channel_index}',device_uuid), "band_name" : channel_params['band_name'], "lower_frequency" : int(channel_params["lower_frequency"]) if "lower_frequency" in channel_params else 0, "upper_frequency" : int(channel_params["upper_frequency"]) if "upper_frequency" in channel_params else 0, Loading @@ -134,7 +134,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): "status" : channel_params["status"] if "status" in channel_params else "", "type" : 'media_channel', "optical_band_parent":str(channel_params['optical_band_parent']) if 'optical_band_parent' in channel_params else None, "channel_index" : channel_params['channel_index'] if 'channel_index' in channel_params else None, "channel_index" : channel_index if channel_index is not None else None, } ) if 'optical_bands' in config and len(config['optical_bands']) > 0: Loading Loading @@ -255,7 +255,6 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): channel_index=stmt.excluded.channel_index, optical_band_parent = stmt.excluded.optical_band_parent ) ) Loading Loading @@ -357,22 +356,23 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig): if config_type == "optical-roadm": if 'flow_handled' in config and len(config['flow_handled'])==0 : config['flow_handled'] =[(None,None)] if channel_namespace is None and 'channel_namespace' in config['new_config']: channel_namespace=config['new_config']['channel_namespace'] if 'is_opticalband' in config and not config['is_opticalband']: #channels = [channel['name']['index'] for channel in config['channels']] channel_num=0 if 'flow_handled' in config and len(config['flow_handled'])>0 : num=0 flow_id=config["new_config"]["flow_id"] if 'flow_id' in config['new_config'] else None for flow in config['flow_handled']: src_port,dest_port=flow channel_num+=1 channel_index=flow_id+num num+=1 channels.append( { # "opticalconfig_uuid":opticalconfig_uuid, "roadm_uuid" : roadm_get_uuid(device_id), "channel_uuid" : channel_get_uuid(f'media_channel_{channel_num}',device_uuid), "channel_uuid" : channel_get_uuid(f'media_channel_{channel_index}',device_uuid), "band_name" : config['new_config']['band_type'], "lower_frequency" : int(int(config['new_config']['frequency']) - (int(config['new_config']['band'])/2)) if "frequency" in config['new_config'] else 0, "upper_frequency" :int(int(config['new_config']['frequency']) + (int(config['new_config']['band'])/2)) if "frequency" in config['new_config'] else 0, Loading @@ -381,23 +381,27 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig): "status" : config['new_config']["status"] if "status" in config['new_config'] else "", "type" : 'media_channel', "optical_band_parent":str( config['new_config']['ob_id']) if 'ob_id' in config['new_config'] else None, "channel_index":str(config["new_config"]["flow_id"]) if "flow_id" in config["new_config"] else None "channel_index":str(channel_index) if channel_index is not None else None } ) if 'is_opticalband' in config and config['is_opticalband']: #channels = [channel['name']['index'] for channel in config['channels']] channel_num=0 if 'flow_handled' in config and len(config['flow_handled'])>0 : ob_id =config['new_config']['ob_id'] if 'ob_id' in config['new_config'] else None num=0 for flow in config['flow_handled']: src_port,dest_port=flow LOGGER.info(f"udpate_optical_bands src: {src_port} and dest :{dest_port} for flow {flow}") channel_num+=1 channel_index=ob_id+num num+=1 channels.append( { # "opticalconfig_uuid":opticalconfig_uuid, "roadm_uuid" : roadm_get_uuid(device_id), "channel_uuid" : channel_get_uuid(f'optical_bands_{channel_num}',device_uuid), "channel_uuid" : channel_get_uuid(f'optical_bands_{channel_index}',device_uuid), "band_name" : config['new_config']['band_type'], "lower_frequency" : int(config['new_config']["low-freq"]) if "low-freq" in config['new_config'] else 0, "upper_frequency" : int(config['new_config']["up-freq"]) if "up-freq" in config['new_config'] else 0, Loading @@ -405,7 +409,7 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig): "src_port" : src_port, "status" : config['new_config']["status"] if "status" in config['new_config'] else "", "type" : 'optical_band', "channel_index" :str( config['new_config']['ob_id']) if 'ob_id' in config['new_config'] else None "channel_index" :str( channel_index) if channel_index is not None else None } ) Loading Loading @@ -551,6 +555,7 @@ def delete_opticalchannel(db_engine : Engine ,messagebroker : MessageBroker, re opticalconfig_uuid = request.opticalconfig_id.opticalconfig_uuid channels=[] config_type=None LOGGER.info(f"delete_optical_channel config {config}") if "type" in config : config_type= config["type"] if 'new_config' in config: Loading
src/context/service/database/models/OpticalConfig/RoadmModel.py +3 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class ChannelModel(_Base): status = Column(String , nullable=True) src_port = Column(String, nullable=True) dest_port = Column(String, nullable=True) type = Column(String, nullable=False) optical_band_parent = Column(String, nullable=True) Loading @@ -74,6 +75,7 @@ class ChannelModel(_Base): "type" : self.type, "src_port" : self.src_port, "dest_port" : self.dest_port, "status":self.status, "optical_band_parent":self.optical_band_parent, "channel_index":self.channel_index Loading
src/device/service/OpenConfigServicer.py +16 −13 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ class OpenConfigServicer(DeviceServiceServicer): resources:list[dict]=[] is_all_good=True config =json.loads(request.config) results=None LOGGER.info(f" config from openconfigservicer {config}") try: context_client = ContextClient() Loading @@ -95,23 +96,25 @@ class OpenConfigServicer(DeviceServiceServicer): for result in results: if not result : is_all_good=False LOGGER.info(f"resluts {results} and is_all_good {is_all_good}") if is_all_good: #driver.GetConfig(resource_keys=[]) config = json.loads(request.config) handled_flow=next((i for i in resources if i['resource_key']=='handled_flow'),None) flow_handled=[ ] if "new_config" in config and "flow" in config: for flow in config['flow']: src,dest= flow LOGGER.info(f"src {src} and dest {dest}") src_raw=get_endpoint_matching(device,src)if src != '0' else '0' dest_raw=get_endpoint_matching(device,dest) if dest != '0' else '0' src_name = src_raw.name if isinstance(src_raw,EndPoint) else '0' dest_name= dest_raw.name if isinstance(dest_raw,EndPoint) else '0' flow_handled.append((src_name,dest_name)) LOGGER.info(f"flow_handled {flow_handled}") if len(flow_handled)>0: config['flow_handled']=flow_handled # if "new_config" in config : # for flow in config['flow']: # src,dest= flow # LOGGER.info(f"src {src} and dest {dest}") # src_raw=get_endpoint_matching(device,src)if src != '0' else '0' # dest_raw=get_endpoint_matching(device,dest) if dest != '0' else '0' # src_name = src_raw.name if isinstance(src_raw,EndPoint) else '0' # dest_name= dest_raw.name if isinstance(dest_raw,EndPoint) else '0' # flow_handled.append((src_name,dest_name)) LOGGER.info(f"flow_handled {handled_flow}") if handled_flow is not None and len(handled_flow)>0: config['flow_handled']=handled_flow['value'] request.config=json.dumps(config) Loading Loading @@ -190,7 +193,7 @@ class OpenConfigServicer(DeviceServiceServicer): for result in results: if not result : is_all_good=False LOGGER.info(f"resluts {results} and is_all_good {is_all_good}") LOGGER.info(f"Disable resluts {results} and is_all_good {is_all_good}") if is_all_good: config = json.loads(request.config) flow_handled=[ ] Loading
src/device/service/Tools.py +3 −1 Original line number Diff line number Diff line Loading @@ -491,6 +491,7 @@ def extract_resources(config : dict, device : Device) -> list[list[dict],dict]: #for tuple_value in config['flow'][device.name]: source_vals = [] dest_vals = [] handled_flow=[] for tuple_value in config['flow']: source_port = None destination_port = None Loading @@ -503,9 +504,10 @@ def extract_resources(config : dict, device : Device) -> list[list[dict],dict]: dst_endpoint_obj = get_endpoint_matching(device, destination_port_uuid) destination_port = dst_endpoint_obj.name dest_vals.append(destination_port) handled_flow.append((source_port,destination_port)) resources.append({'resource_key': 'source_port', 'value': source_vals}) resources.append({'resource_key': 'destination_port', 'value': dest_vals }) resources.append({'resource_key':'handled_flow','value':handled_flow}) if 'new_config' in config: lower_frequency = None upper_frequency = None Loading
src/device/service/drivers/oc_driver/OCDriver.py +1 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,7 @@ class OCDriver(_Driver): timezone=pytz.utc) self._temp_address=f"{address}{port}" self.__out_samples = queue.Queue() logging.info(f"setting ocdriver address {self.address} and {self.port} {self.settings}") self.__netconf_handler = NetconfSessionHandler(self.address, self.port, **(self.settings)) self.__type = self.settings.get("type","optical-transponder") self.__device_uuid=device_uuid Loading