Loading .gitignore +0 −1 Original line number Diff line number Diff line Loading @@ -192,4 +192,3 @@ libyang/ # Other logs **/logs/*.log.* proto/context.proto +1 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,7 @@ enum DeviceDriverEnum { DEVICEDRIVER_MORPHEUS = 17; DEVICEDRIVER_RYU = 18; DEVICEDRIVER_GNMI_NOKIA_SRLINUX = 19; DEVICEDRIVER_OPENROADM = 20; } enum DeviceOperationalStatusEnum { Loading src/common/DeviceTypes.py +1 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ class DeviceTypeEnum(Enum): EMULATED_OPEN_LINE_SYSTEM = 'emu-open-line-system' EMULATED_OPTICAL_ROADM = 'emu-optical-roadm' EMULATED_OPTICAL_TRANSPONDER = 'emu-optical-transponder' EMULATED_OPEN_ROADM = 'emu-optical-openroadm' EMULATED_OPTICAL_SPLITTER = 'emu-optical-splitter' # passive component required for XR Constellation EMULATED_P4_SWITCH = 'emu-p4-switch' EMULATED_PACKET_RADIO_ROUTER = 'emu-packet-radio-router' Loading src/common/tools/context_queries/OpticalConfig.py +12 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,18 @@ def opticalconfig_get_uuid( ('name', device_name), ], extra_details=['At least one is required to produce a OpticalConfig UUID']) def opticalconfig_uuid_get_duuid( device_uuid , allow_random : bool = False ) -> str: if (len(device_uuid)>0): return get_uuid_from_string(f"{device_uuid}_opticalconfig") if allow_random: return get_uuid_random() raise InvalidArgumentsException([ ('DeviceId ', device_id), ], extra_details=['device_id is required to produce a OpticalConfig UUID']) def ob_get_uuid( ob_name:str , allow_random : bool = False Loading src/context/service/database/OpticalConfig.py +116 −72 Original line number Diff line number Diff line Loading @@ -77,8 +77,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): if channel_namespace is None and 'channel_namespace' in config: channel_namespace=config['channel_namespace'] # if 'transceivers' in config and len(config['transceivers']['transceiver']) > 0: # transceivers = [transceiver for transceiver in config ['transceivers']['transceiver']] if 'interfaces' in config and len(config['interfaces']) > 0: for interface in config['interfaces']: interface_name=interface["name"] if "name" in interface else None Loading Loading @@ -178,7 +177,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): if 'interfaces' in config: for interface in config['interfaces']: interfaces.append({ "interface_uuid" : interface_get_uuid(interface['name']), "interface_uuid" : interface_get_uuid(interface['name'],device_uuid), 'name' : interface["name"], "type" : interface["type"], "administrative_state": interface["administrative_state"], Loading @@ -186,7 +185,27 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): "port" : interface["port"], "interface_list" : interface["interface_list"], "frequency" : interface["frequency"], "width" : interface["width"], "width" : int(float(interface["width"])) if 'width' in interface else 0, "roadm_uuid" : roadm_get_uuid(device_id), }) if 'circuits' in config: for interface in config['circuits']: ports_g='' if 'port' in interface : for p in interface['port']: if ports_g != '': ports_g +='/' ports_g= ports_g+ p['port_name'] interfaces.append({ "interface_uuid" : interface_get_uuid(interface["interface_uuid"],device_uuid), 'name' : interface["interface_list"] if 'interface_list' in interface else interface["interface_uuid"], "type" : "Null", "administrative_state": interface["administrative_state"] if 'administrative_state' in interface else "not-in-service", "circuit_pack_name" : interface["circuit_pack_name"], "port" : ports_g, "interface_list" : interface["interface_list"] if 'interface_list' in interface else "Null", "frequency" : interface["frequency"] if 'frequency' in interface else 0.0, "width" : int(float(interface["width"])) if 'width' in interface else 0, "roadm_uuid" : roadm_get_uuid(device_id), }) roadms.append({ Loading Loading @@ -300,8 +319,10 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): roadm_id = session.execute(stmt).fetchone() if len(interfaces) > 0: stmt = insert(ORInterfaceModel).values(interfaces) stmt = stmt.on_conflict_do_update( ifc_uuids=[] for ifc in interfaces : stmt = insert(ORInterfaceModel).values(**ifc) update_stmt = stmt.on_conflict_do_update( index_elements=[ORInterfaceModel.interface_uuid], set_=dict( name = stmt.excluded.name, Loading @@ -313,10 +334,11 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): interface_list = stmt.excluded.interface_list, width = stmt.excluded.width, ) ) stmt = stmt.returning(ORInterfaceModel.interface_uuid) opticalChannel_id = session.execute(stmt).fetchone() ).returning(ORInterfaceModel.interface_uuid) result = session.execute(update_stmt).fetchone() ifc_uuids.append(result) else : session.query(ORInterfaceModel).delete() opticalconfig_id = run_transaction(sessionmaker(bind=db_engine), callback) return {'opticalconfig_uuid': opticalconfig_id} Loading @@ -335,7 +357,6 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig): #is_transpondre = False opticalconfig_uuid = opticalconfig_get_uuid(device_id) is_optical_band=None LOGGER.info(f"update_opticalconfig {request}") if request.config : config = json.loads(request.config) Loading Loading @@ -618,7 +639,7 @@ def delete_opticalchannel(db_engine : Engine, messagebroker : MessageBroker, req opticalconfig_uuid = request.opticalconfig_id.opticalconfig_uuid channels = [] config_type = None logging.info(f"DeleteOpticalchannel {request.config}") if "type" in config : config_type= config["type"] if 'new_config' in config: Loading @@ -640,6 +661,23 @@ def delete_opticalchannel(db_engine : Engine, messagebroker : MessageBroker, req "target_output_power": None, "status" : "DISABLED" }) elif config_type == DeviceTypeEnum.OPEN_ROADM._value_: if 'new_config' in config and 'interfaces' in config['new_config']: for i in config['new_config']['interfaces']: channels.append({ "interface_uuid" : interface_get_uuid(i['interface_name'],device_uuid), 'name' : i["interface_name"], "type" :'Null', "administrative_state": "Null", "circuit_pack_name" : 'Null', "port" : "Null", "interface_list" :'Null', "frequency" : "Null", "width" : 0, "roadm_uuid" : roadm_get_uuid(device_id), }) elif config_type == DeviceTypeEnum.OPTICAL_ROADM._value_: channel_num = flow_id Loading Loading @@ -668,7 +706,7 @@ def delete_opticalchannel(db_engine : Engine, messagebroker : MessageBroker, req channels.append(channel_get_uuid(channel_name, device_uuid)) channel_num += 1 LOGGER.info(f"channels to delete {channels}") def callback(session : Session): all_suceed = [] Loading @@ -692,6 +730,12 @@ def delete_opticalchannel(db_engine : Engine, messagebroker : MessageBroker, req stmt = stmt.returning(OpticalChannelModel.channel_uuid) opticalChannel_id = session.execute(stmt).fetchone() all_suceed.append(True) elif config_type == DeviceTypeEnum.OPEN_ROADM._value_: if len(channels) > 0: for i in channels : num_deleted = session.query(ORInterfaceModel).filter_by(interface_uuid=i['interface_uuid']).delete() all_suceed.append(num_deleted > 0) return all_suceed all_deleted = run_transaction(sessionmaker(bind=db_engine), callback) Loading Loading
.gitignore +0 −1 Original line number Diff line number Diff line Loading @@ -192,4 +192,3 @@ libyang/ # Other logs **/logs/*.log.*
proto/context.proto +1 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,7 @@ enum DeviceDriverEnum { DEVICEDRIVER_MORPHEUS = 17; DEVICEDRIVER_RYU = 18; DEVICEDRIVER_GNMI_NOKIA_SRLINUX = 19; DEVICEDRIVER_OPENROADM = 20; } enum DeviceOperationalStatusEnum { Loading
src/common/DeviceTypes.py +1 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ class DeviceTypeEnum(Enum): EMULATED_OPEN_LINE_SYSTEM = 'emu-open-line-system' EMULATED_OPTICAL_ROADM = 'emu-optical-roadm' EMULATED_OPTICAL_TRANSPONDER = 'emu-optical-transponder' EMULATED_OPEN_ROADM = 'emu-optical-openroadm' EMULATED_OPTICAL_SPLITTER = 'emu-optical-splitter' # passive component required for XR Constellation EMULATED_P4_SWITCH = 'emu-p4-switch' EMULATED_PACKET_RADIO_ROUTER = 'emu-packet-radio-router' Loading
src/common/tools/context_queries/OpticalConfig.py +12 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,18 @@ def opticalconfig_get_uuid( ('name', device_name), ], extra_details=['At least one is required to produce a OpticalConfig UUID']) def opticalconfig_uuid_get_duuid( device_uuid , allow_random : bool = False ) -> str: if (len(device_uuid)>0): return get_uuid_from_string(f"{device_uuid}_opticalconfig") if allow_random: return get_uuid_random() raise InvalidArgumentsException([ ('DeviceId ', device_id), ], extra_details=['device_id is required to produce a OpticalConfig UUID']) def ob_get_uuid( ob_name:str , allow_random : bool = False Loading
src/context/service/database/OpticalConfig.py +116 −72 Original line number Diff line number Diff line Loading @@ -77,8 +77,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): if channel_namespace is None and 'channel_namespace' in config: channel_namespace=config['channel_namespace'] # if 'transceivers' in config and len(config['transceivers']['transceiver']) > 0: # transceivers = [transceiver for transceiver in config ['transceivers']['transceiver']] if 'interfaces' in config and len(config['interfaces']) > 0: for interface in config['interfaces']: interface_name=interface["name"] if "name" in interface else None Loading Loading @@ -178,7 +177,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): if 'interfaces' in config: for interface in config['interfaces']: interfaces.append({ "interface_uuid" : interface_get_uuid(interface['name']), "interface_uuid" : interface_get_uuid(interface['name'],device_uuid), 'name' : interface["name"], "type" : interface["type"], "administrative_state": interface["administrative_state"], Loading @@ -186,7 +185,27 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): "port" : interface["port"], "interface_list" : interface["interface_list"], "frequency" : interface["frequency"], "width" : interface["width"], "width" : int(float(interface["width"])) if 'width' in interface else 0, "roadm_uuid" : roadm_get_uuid(device_id), }) if 'circuits' in config: for interface in config['circuits']: ports_g='' if 'port' in interface : for p in interface['port']: if ports_g != '': ports_g +='/' ports_g= ports_g+ p['port_name'] interfaces.append({ "interface_uuid" : interface_get_uuid(interface["interface_uuid"],device_uuid), 'name' : interface["interface_list"] if 'interface_list' in interface else interface["interface_uuid"], "type" : "Null", "administrative_state": interface["administrative_state"] if 'administrative_state' in interface else "not-in-service", "circuit_pack_name" : interface["circuit_pack_name"], "port" : ports_g, "interface_list" : interface["interface_list"] if 'interface_list' in interface else "Null", "frequency" : interface["frequency"] if 'frequency' in interface else 0.0, "width" : int(float(interface["width"])) if 'width' in interface else 0, "roadm_uuid" : roadm_get_uuid(device_id), }) roadms.append({ Loading Loading @@ -300,8 +319,10 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): roadm_id = session.execute(stmt).fetchone() if len(interfaces) > 0: stmt = insert(ORInterfaceModel).values(interfaces) stmt = stmt.on_conflict_do_update( ifc_uuids=[] for ifc in interfaces : stmt = insert(ORInterfaceModel).values(**ifc) update_stmt = stmt.on_conflict_do_update( index_elements=[ORInterfaceModel.interface_uuid], set_=dict( name = stmt.excluded.name, Loading @@ -313,10 +334,11 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): interface_list = stmt.excluded.interface_list, width = stmt.excluded.width, ) ) stmt = stmt.returning(ORInterfaceModel.interface_uuid) opticalChannel_id = session.execute(stmt).fetchone() ).returning(ORInterfaceModel.interface_uuid) result = session.execute(update_stmt).fetchone() ifc_uuids.append(result) else : session.query(ORInterfaceModel).delete() opticalconfig_id = run_transaction(sessionmaker(bind=db_engine), callback) return {'opticalconfig_uuid': opticalconfig_id} Loading @@ -335,7 +357,6 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig): #is_transpondre = False opticalconfig_uuid = opticalconfig_get_uuid(device_id) is_optical_band=None LOGGER.info(f"update_opticalconfig {request}") if request.config : config = json.loads(request.config) Loading Loading @@ -618,7 +639,7 @@ def delete_opticalchannel(db_engine : Engine, messagebroker : MessageBroker, req opticalconfig_uuid = request.opticalconfig_id.opticalconfig_uuid channels = [] config_type = None logging.info(f"DeleteOpticalchannel {request.config}") if "type" in config : config_type= config["type"] if 'new_config' in config: Loading @@ -640,6 +661,23 @@ def delete_opticalchannel(db_engine : Engine, messagebroker : MessageBroker, req "target_output_power": None, "status" : "DISABLED" }) elif config_type == DeviceTypeEnum.OPEN_ROADM._value_: if 'new_config' in config and 'interfaces' in config['new_config']: for i in config['new_config']['interfaces']: channels.append({ "interface_uuid" : interface_get_uuid(i['interface_name'],device_uuid), 'name' : i["interface_name"], "type" :'Null', "administrative_state": "Null", "circuit_pack_name" : 'Null', "port" : "Null", "interface_list" :'Null', "frequency" : "Null", "width" : 0, "roadm_uuid" : roadm_get_uuid(device_id), }) elif config_type == DeviceTypeEnum.OPTICAL_ROADM._value_: channel_num = flow_id Loading Loading @@ -668,7 +706,7 @@ def delete_opticalchannel(db_engine : Engine, messagebroker : MessageBroker, req channels.append(channel_get_uuid(channel_name, device_uuid)) channel_num += 1 LOGGER.info(f"channels to delete {channels}") def callback(session : Session): all_suceed = [] Loading @@ -692,6 +730,12 @@ def delete_opticalchannel(db_engine : Engine, messagebroker : MessageBroker, req stmt = stmt.returning(OpticalChannelModel.channel_uuid) opticalChannel_id = session.execute(stmt).fetchone() all_suceed.append(True) elif config_type == DeviceTypeEnum.OPEN_ROADM._value_: if len(channels) > 0: for i in channels : num_deleted = session.query(ORInterfaceModel).filter_by(interface_uuid=i['interface_uuid']).delete() all_suceed.append(num_deleted > 0) return all_suceed all_deleted = run_transaction(sessionmaker(bind=db_engine), callback) Loading