Loading .context.log.swn 0 → 100644 +24 KiB File added.No diff preview for this file type. View file my_deploy.sh +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/" # Set the list of components, separated by spaces, you want to build images for, and deploy. export TFS_COMPONENTS="context device pathcomp opticalcontroller service slice webui nbi " export TFS_COMPONENTS="context device pathcomp opticalcontroller qkd_app service slice webui nbi " # Uncomment to activate Monitoring (old) #export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring" Loading src/context/service/database/OpticalConfig.py +60 −3 Original line number Diff line number Diff line Loading @@ -22,9 +22,10 @@ from sqlalchemy_cockroachdb import run_transaction from common.proto.context_pb2 import OpticalConfig, OpticalConfigId , Empty , EventTypeEnum from .models.OpticalConfig.OpticalConfigModel import OpticalConfigModel from .models.OpticalConfig.TransponderModel import TransponderTypeModel ,OpticalChannelModel from .models.OpticalConfig.RoadmModel import RoadmTypeModel, ChannelModel from .models.OpticalConfig.RoadmModel import RoadmTypeModel, ChannelModel , ORInterfaceModel from context.service.database.uuids.OpticalConfig import ( channel_get_uuid , opticalconfig_get_uuid ,transponder_get_uuid,roadm_get_uuid channel_get_uuid , opticalconfig_get_uuid ,transponder_get_uuid,roadm_get_uuid, interface_get_uuid ) from .Events import notify_event_opticalconfig Loading Loading @@ -55,6 +56,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): device_id = request.device_id device_uuid = request.device_id.device_uuid.uuid channels = [] interfaces=[] transponder=[] roadms=[] Loading Loading @@ -165,7 +167,29 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): "roadm_uuid":roadm_get_uuid(device_id), "opticalconfig_uuid":opticalconfig_uuid, }) if config_type == DeviceTypeEnum.OPEN_ROADM._value_: if 'interfaces' in config : for interface in config['interfaces']: interfaces.append({ "interface_uuid" :interface_get_uuid(interface['name']), 'name' : interface["name"], "type" : interface["type"], "administrative_state": interface["administrative_state"], "circuit_pack_name" : interface["circuit_pack_name"], "port" : interface["port"], "interface_list" : interface["interface_list"], "frequency" : interface["frequency"], "width" : interface["width"], "roadm_uuid" : roadm_get_uuid(device_id), } ) roadms.append({ "roadm_uuid":roadm_get_uuid(device_id), "opticalconfig_uuid":opticalconfig_uuid, }) LOGGER.info(f"open_roadm") Loading Loading @@ -259,12 +283,45 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): channel_index=stmt.excluded.channel_index, optical_band_parent = stmt.excluded.optical_band_parent ) ) stmt = stmt.returning(ChannelModel.channel_uuid) opticalChannel_id = session.execute(stmt).fetchone() if config_type == DeviceTypeEnum.OPEN_ROADM._value_: if (len(roadms)>0): stmt = insert(RoadmTypeModel).values(roadms) stmt = stmt.on_conflict_do_update( index_elements=[RoadmTypeModel.roadm_uuid], set_=dict( interfaces=stmt.excluded.interfaces ) ) stmt = stmt.returning(RoadmTypeModel.roadm_uuid) roadm_id = session.execute(stmt).fetchone() if len(interface) >0 : stmt = insert(ORInterfaceModel).values(interface) stmt = stmt.on_conflict_do_update( index_elements=[ORInterfaceModel.interface_uuid ], set_=dict( name= stmt.excluded.name , frequency = stmt.excluded.frequency, administrative_state = stmt.excluded.administrative_state, type=stmt.excluded.type, circuit_pack_name=stmt.excluded.circuit_pack_name, port=stmt.excluded.port, interface_list=stmt.excluded.interface_list, width=stmt.excluded.width, ) ) stmt = stmt.returning(ORInterfaceModel.interface_uuid) opticalChannel_id = session.execute(stmt).fetchone() opticalconfig_id = run_transaction(sessionmaker(bind=db_engine), callback) Loading src/context/service/database/models/OpticalConfig/RoadmModel.py +38 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ class RoadmTypeModel (_Base): roadm_uuid = Column(String, primary_key=True) channels = relationship("ChannelModel") circuits = Column (String,nullable=True) interfaces = relationship ("ORInterfaceModel") opticalconfig_uuid = Column(ForeignKey('optical_config.opticalconfig_uuid', ondelete='CASCADE' ),index=True ,nullable=False) opticalconfig = relationship('OpticalConfigModel', back_populates='roadms') Loading @@ -41,7 +41,8 @@ class RoadmTypeModel (_Base): def dump (self): return { "channels" : [channel.dump() for channel in self.channels], "roadm_uuid" : self.dump_id() "roadm_uuid" : self.dump_id(), "interfaces" :[] } class ChannelModel(_Base): Loading Loading @@ -81,3 +82,38 @@ class ChannelModel(_Base): "channel_index":self.channel_index } class ORInterfaceModel (_Base): __tablename__ = 'open_roadm_interface' interface_uuid = Column(String, primary_key=True) name = Column(String, nullable=False ,unique=True ) type = Column(String , nullable=True) administrative_state = Column(String,nullable=True) circuit_pack_name = Column(String,nullable=True) port = Column(String,nullable=True) interface_list = Column(String ,nullable=True) frequency = Column(Integer ,nullable=True) width = Column(Integer ,nullable=True) roadm_uuid = Column(ForeignKey('roadm_type.roadm_uuid', ondelete='CASCADE' ),nullable=False) roadm = relationship('RoadmTypeModel',back_populates='interfaces') def dump_id (self ): return { "interface_uuid":self.interface_uuid } def dump(self): return { "name" : self.name, "type" : self.type, "administrative_state" : self.administrative_state, "circuit_pack_name" : self.circuit_pack_name, "port" : self.port, "interface_list" : self.interface_list, "frequency" : self.frequency, "width" : self.width } No newline at end of file src/context/service/database/uuids/OpticalConfig.py +15 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,21 @@ def channel_get_uuid( ], extra_details=['Channel name is required to produce a channel UUID']) def interface_get_uuid( interface_name :str , allow_random : bool = False ) -> str: if len(interface_name) > 0: return get_uuid_from_string(interface_name) if allow_random: return get_uuid_random() raise InvalidArgumentsException([ ('interface uuid', interface_name), ], extra_details=['interface name is required to produce a interface UUID']) def transponder_get_uuid( opticalconfig_id :str , allow_random : bool = False Loading Loading
my_deploy.sh +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/" # Set the list of components, separated by spaces, you want to build images for, and deploy. export TFS_COMPONENTS="context device pathcomp opticalcontroller service slice webui nbi " export TFS_COMPONENTS="context device pathcomp opticalcontroller qkd_app service slice webui nbi " # Uncomment to activate Monitoring (old) #export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring" Loading
src/context/service/database/OpticalConfig.py +60 −3 Original line number Diff line number Diff line Loading @@ -22,9 +22,10 @@ from sqlalchemy_cockroachdb import run_transaction from common.proto.context_pb2 import OpticalConfig, OpticalConfigId , Empty , EventTypeEnum from .models.OpticalConfig.OpticalConfigModel import OpticalConfigModel from .models.OpticalConfig.TransponderModel import TransponderTypeModel ,OpticalChannelModel from .models.OpticalConfig.RoadmModel import RoadmTypeModel, ChannelModel from .models.OpticalConfig.RoadmModel import RoadmTypeModel, ChannelModel , ORInterfaceModel from context.service.database.uuids.OpticalConfig import ( channel_get_uuid , opticalconfig_get_uuid ,transponder_get_uuid,roadm_get_uuid channel_get_uuid , opticalconfig_get_uuid ,transponder_get_uuid,roadm_get_uuid, interface_get_uuid ) from .Events import notify_event_opticalconfig Loading Loading @@ -55,6 +56,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): device_id = request.device_id device_uuid = request.device_id.device_uuid.uuid channels = [] interfaces=[] transponder=[] roadms=[] Loading Loading @@ -165,7 +167,29 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): "roadm_uuid":roadm_get_uuid(device_id), "opticalconfig_uuid":opticalconfig_uuid, }) if config_type == DeviceTypeEnum.OPEN_ROADM._value_: if 'interfaces' in config : for interface in config['interfaces']: interfaces.append({ "interface_uuid" :interface_get_uuid(interface['name']), 'name' : interface["name"], "type" : interface["type"], "administrative_state": interface["administrative_state"], "circuit_pack_name" : interface["circuit_pack_name"], "port" : interface["port"], "interface_list" : interface["interface_list"], "frequency" : interface["frequency"], "width" : interface["width"], "roadm_uuid" : roadm_get_uuid(device_id), } ) roadms.append({ "roadm_uuid":roadm_get_uuid(device_id), "opticalconfig_uuid":opticalconfig_uuid, }) LOGGER.info(f"open_roadm") Loading Loading @@ -259,12 +283,45 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): channel_index=stmt.excluded.channel_index, optical_band_parent = stmt.excluded.optical_band_parent ) ) stmt = stmt.returning(ChannelModel.channel_uuid) opticalChannel_id = session.execute(stmt).fetchone() if config_type == DeviceTypeEnum.OPEN_ROADM._value_: if (len(roadms)>0): stmt = insert(RoadmTypeModel).values(roadms) stmt = stmt.on_conflict_do_update( index_elements=[RoadmTypeModel.roadm_uuid], set_=dict( interfaces=stmt.excluded.interfaces ) ) stmt = stmt.returning(RoadmTypeModel.roadm_uuid) roadm_id = session.execute(stmt).fetchone() if len(interface) >0 : stmt = insert(ORInterfaceModel).values(interface) stmt = stmt.on_conflict_do_update( index_elements=[ORInterfaceModel.interface_uuid ], set_=dict( name= stmt.excluded.name , frequency = stmt.excluded.frequency, administrative_state = stmt.excluded.administrative_state, type=stmt.excluded.type, circuit_pack_name=stmt.excluded.circuit_pack_name, port=stmt.excluded.port, interface_list=stmt.excluded.interface_list, width=stmt.excluded.width, ) ) stmt = stmt.returning(ORInterfaceModel.interface_uuid) opticalChannel_id = session.execute(stmt).fetchone() opticalconfig_id = run_transaction(sessionmaker(bind=db_engine), callback) Loading
src/context/service/database/models/OpticalConfig/RoadmModel.py +38 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ class RoadmTypeModel (_Base): roadm_uuid = Column(String, primary_key=True) channels = relationship("ChannelModel") circuits = Column (String,nullable=True) interfaces = relationship ("ORInterfaceModel") opticalconfig_uuid = Column(ForeignKey('optical_config.opticalconfig_uuid', ondelete='CASCADE' ),index=True ,nullable=False) opticalconfig = relationship('OpticalConfigModel', back_populates='roadms') Loading @@ -41,7 +41,8 @@ class RoadmTypeModel (_Base): def dump (self): return { "channels" : [channel.dump() for channel in self.channels], "roadm_uuid" : self.dump_id() "roadm_uuid" : self.dump_id(), "interfaces" :[] } class ChannelModel(_Base): Loading Loading @@ -81,3 +82,38 @@ class ChannelModel(_Base): "channel_index":self.channel_index } class ORInterfaceModel (_Base): __tablename__ = 'open_roadm_interface' interface_uuid = Column(String, primary_key=True) name = Column(String, nullable=False ,unique=True ) type = Column(String , nullable=True) administrative_state = Column(String,nullable=True) circuit_pack_name = Column(String,nullable=True) port = Column(String,nullable=True) interface_list = Column(String ,nullable=True) frequency = Column(Integer ,nullable=True) width = Column(Integer ,nullable=True) roadm_uuid = Column(ForeignKey('roadm_type.roadm_uuid', ondelete='CASCADE' ),nullable=False) roadm = relationship('RoadmTypeModel',back_populates='interfaces') def dump_id (self ): return { "interface_uuid":self.interface_uuid } def dump(self): return { "name" : self.name, "type" : self.type, "administrative_state" : self.administrative_state, "circuit_pack_name" : self.circuit_pack_name, "port" : self.port, "interface_list" : self.interface_list, "frequency" : self.frequency, "width" : self.width } No newline at end of file
src/context/service/database/uuids/OpticalConfig.py +15 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,21 @@ def channel_get_uuid( ], extra_details=['Channel name is required to produce a channel UUID']) def interface_get_uuid( interface_name :str , allow_random : bool = False ) -> str: if len(interface_name) > 0: return get_uuid_from_string(interface_name) if allow_random: return get_uuid_random() raise InvalidArgumentsException([ ('interface uuid', interface_name), ], extra_details=['interface name is required to produce a interface UUID']) def transponder_get_uuid( opticalconfig_id :str , allow_random : bool = False Loading