Loading src/context/service/database/OpticalConfig.py +58 −59 Original line number Diff line number Diff line Loading @@ -193,7 +193,6 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): set_=dict( transcievers = stmt.excluded.transcievers, ) ) stmt = stmt.returning(TransponderTypeModel.transponder_uuid) transponder_id = session.execute(stmt).fetchone() Loading Loading @@ -236,7 +235,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): dest_port = stmt.excluded.dest_port, src_port = stmt.excluded.src_port, channel_index = stmt.excluded.channel_index, optical_band_parent = stmt.excluded.optical_band_parent optical_band_parent = stmt.excluded.optical_band_parent, ) ) stmt = stmt.returning(ChannelModel.channel_uuid) Loading src/context/service/database/models/OpticalConfig/OpticalConfigModel.py +15 −16 Original line number Diff line number Diff line Loading @@ -52,20 +52,19 @@ class OpticalConfigModel(_Base): } if self.type =="optical-transponder" : channels = [transponer.dump() for transponer in self.transponders][0] obj['channels']=channels['channels'] if 'channels' in channels else None obj['transceivers']=channels['transceivers'] if 'transceivers' in channels else None obj['interfaces']=channels['interfaces'] if 'interfaces' in channels else None obj['trasponder_uuid']=channels['trasponder_uuid'] if 'trasponder_uuid' in channels else None obj['channels' ] = channels.get('channels', None) obj['transceivers' ] = channels.get('transceivers', None) obj['interfaces' ] = channels.get('interfaces', None) obj['trasponder_uuid'] = channels.get('trasponder_uuid', None) if self.type =="optical-roadm" : dev = [roadms.dump() for roadms in self.roadms][0] obj['channels']=dev['channels'] if 'channels' in dev else None obj['roadm_uuid']=dev['roadm_uuid'] if 'roadm_uuid' in dev else None obj['channels' ] = dev.get('channels', None) obj['roadm_uuid'] = dev.get('roadm_uuid', None) if self.type =="openroadm" : dev = [roadms.dump() for roadms in self.roadms][0] obj['interfaces']=dev['interfaces'] if 'interfaces' in dev else None obj['roadm_uuid']=dev['roadm_uuid'] if 'roadm_uuid' in dev else None logging.info(f"optical_config_model {obj}") obj['interfaces'] = dev.get('interfaces', None) obj['roadm_uuid'] = dev.get('roadm_uuid', None) return obj src/context/service/database/models/OpticalConfig/RoadmModel.py +26 −33 Original line number Diff line number Diff line Loading @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import json , logging from sqlalchemy import Column, String, Integer , ForeignKey, Boolean , Float from sqlalchemy.dialects.postgresql import ARRAY import logging from sqlalchemy import Column, String, Integer, ForeignKey, Float from sqlalchemy.orm import relationship from context.service.database.models._Base import _Base Loading @@ -33,8 +32,6 @@ class RoadmTypeModel (_Base): } def dump (self): i=[interface.dump() for interface in self.interfaces] logging.info(f"roamd_type_model {i}") return { "channels" : [channel.dump() for channel in self.channels], "roadm_uuid" : self.dump_id(), Loading @@ -55,7 +52,6 @@ class ChannelModel(_Base): type = Column(String, nullable=False) optical_band_parent = Column(String, nullable=True) roadm_uuid = Column(ForeignKey('roadm_type.roadm_uuid', ondelete='CASCADE'), nullable=False) roadm = relationship('RoadmTypeModel',back_populates='channels') # opticalconfig_uuid = Column(ForeignKey('optical_config.opticalconfig_uuid', ondelete='CASCADE'), primary_key=True) Loading @@ -81,6 +77,7 @@ class ChannelModel(_Base): 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) Loading @@ -90,11 +87,9 @@ class ORInterfaceModel (_Base): interface_list = Column(String, nullable = True) frequency = Column(Float, 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 Loading @@ -108,8 +103,6 @@ class ORInterfaceModel (_Base): "circuit_pack_name" : self.circuit_pack_name, "port" : self.port, "interface_list" : self.interface_list, "frequency" : self.frequency, "width" : self.width } src/device/service/Tools.py +18 −17 Original line number Diff line number Diff line Loading @@ -497,7 +497,8 @@ def extract_resources(config : dict, device : Device) -> list[list[dict], dict]: interfaces_list.append([ circuit_pack_dic, interface_list, supporting_port]) supporting_port ]) resources.append({'resource_key':'interfaces','value':interfaces_list}) else : resources.append(is_key_existed('channel_namespace', config)) Loading Loading @@ -536,8 +537,8 @@ def extract_resources(config : dict, device : Device) -> list[list[dict], dict]: resources.append(is_key_existed('band_type', keys_dic=config['new_config'], key_name_to_use='name')) resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='optical-band-parent')) #resources.append(is_key_existed('name', keys_dic=config['new_config'], key_name_to_use='channel_name')) if not is_opticalband: if not is_opticalband: if 'frequency' in config['new_config'] and 'band' in config['new_config'] and conditions['edit_type'] == 'media-channel': if config['new_config']['frequency'] is not None and config['new_config']['band'] is not None: lower_frequency = int(int(config['new_config']['frequency']) - (int(config['new_config']['band'])/2)+1) Loading src/device/service/drivers/oc_driver/OCDriver.py +8 −9 Original line number Diff line number Diff line Loading @@ -169,7 +169,6 @@ def edit_config( elif (conditions['edit_type']=='optical-band'): #roadm optical-band str_config_messages = create_optical_band(resources) elif (conditions['edit_type']=='network-media-channel'): commit_per_rule=True #openroadm network media channel Loading Loading
src/context/service/database/OpticalConfig.py +58 −59 Original line number Diff line number Diff line Loading @@ -193,7 +193,6 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): set_=dict( transcievers = stmt.excluded.transcievers, ) ) stmt = stmt.returning(TransponderTypeModel.transponder_uuid) transponder_id = session.execute(stmt).fetchone() Loading Loading @@ -236,7 +235,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig): dest_port = stmt.excluded.dest_port, src_port = stmt.excluded.src_port, channel_index = stmt.excluded.channel_index, optical_band_parent = stmt.excluded.optical_band_parent optical_band_parent = stmt.excluded.optical_band_parent, ) ) stmt = stmt.returning(ChannelModel.channel_uuid) Loading
src/context/service/database/models/OpticalConfig/OpticalConfigModel.py +15 −16 Original line number Diff line number Diff line Loading @@ -52,20 +52,19 @@ class OpticalConfigModel(_Base): } if self.type =="optical-transponder" : channels = [transponer.dump() for transponer in self.transponders][0] obj['channels']=channels['channels'] if 'channels' in channels else None obj['transceivers']=channels['transceivers'] if 'transceivers' in channels else None obj['interfaces']=channels['interfaces'] if 'interfaces' in channels else None obj['trasponder_uuid']=channels['trasponder_uuid'] if 'trasponder_uuid' in channels else None obj['channels' ] = channels.get('channels', None) obj['transceivers' ] = channels.get('transceivers', None) obj['interfaces' ] = channels.get('interfaces', None) obj['trasponder_uuid'] = channels.get('trasponder_uuid', None) if self.type =="optical-roadm" : dev = [roadms.dump() for roadms in self.roadms][0] obj['channels']=dev['channels'] if 'channels' in dev else None obj['roadm_uuid']=dev['roadm_uuid'] if 'roadm_uuid' in dev else None obj['channels' ] = dev.get('channels', None) obj['roadm_uuid'] = dev.get('roadm_uuid', None) if self.type =="openroadm" : dev = [roadms.dump() for roadms in self.roadms][0] obj['interfaces']=dev['interfaces'] if 'interfaces' in dev else None obj['roadm_uuid']=dev['roadm_uuid'] if 'roadm_uuid' in dev else None logging.info(f"optical_config_model {obj}") obj['interfaces'] = dev.get('interfaces', None) obj['roadm_uuid'] = dev.get('roadm_uuid', None) return obj
src/context/service/database/models/OpticalConfig/RoadmModel.py +26 −33 Original line number Diff line number Diff line Loading @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import json , logging from sqlalchemy import Column, String, Integer , ForeignKey, Boolean , Float from sqlalchemy.dialects.postgresql import ARRAY import logging from sqlalchemy import Column, String, Integer, ForeignKey, Float from sqlalchemy.orm import relationship from context.service.database.models._Base import _Base Loading @@ -33,8 +32,6 @@ class RoadmTypeModel (_Base): } def dump (self): i=[interface.dump() for interface in self.interfaces] logging.info(f"roamd_type_model {i}") return { "channels" : [channel.dump() for channel in self.channels], "roadm_uuid" : self.dump_id(), Loading @@ -55,7 +52,6 @@ class ChannelModel(_Base): type = Column(String, nullable=False) optical_band_parent = Column(String, nullable=True) roadm_uuid = Column(ForeignKey('roadm_type.roadm_uuid', ondelete='CASCADE'), nullable=False) roadm = relationship('RoadmTypeModel',back_populates='channels') # opticalconfig_uuid = Column(ForeignKey('optical_config.opticalconfig_uuid', ondelete='CASCADE'), primary_key=True) Loading @@ -81,6 +77,7 @@ class ChannelModel(_Base): 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) Loading @@ -90,11 +87,9 @@ class ORInterfaceModel (_Base): interface_list = Column(String, nullable = True) frequency = Column(Float, 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 Loading @@ -108,8 +103,6 @@ class ORInterfaceModel (_Base): "circuit_pack_name" : self.circuit_pack_name, "port" : self.port, "interface_list" : self.interface_list, "frequency" : self.frequency, "width" : self.width }
src/device/service/Tools.py +18 −17 Original line number Diff line number Diff line Loading @@ -497,7 +497,8 @@ def extract_resources(config : dict, device : Device) -> list[list[dict], dict]: interfaces_list.append([ circuit_pack_dic, interface_list, supporting_port]) supporting_port ]) resources.append({'resource_key':'interfaces','value':interfaces_list}) else : resources.append(is_key_existed('channel_namespace', config)) Loading Loading @@ -536,8 +537,8 @@ def extract_resources(config : dict, device : Device) -> list[list[dict], dict]: resources.append(is_key_existed('band_type', keys_dic=config['new_config'], key_name_to_use='name')) resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='optical-band-parent')) #resources.append(is_key_existed('name', keys_dic=config['new_config'], key_name_to_use='channel_name')) if not is_opticalband: if not is_opticalband: if 'frequency' in config['new_config'] and 'band' in config['new_config'] and conditions['edit_type'] == 'media-channel': if config['new_config']['frequency'] is not None and config['new_config']['band'] is not None: lower_frequency = int(int(config['new_config']['frequency']) - (int(config['new_config']['band'])/2)+1) Loading
src/device/service/drivers/oc_driver/OCDriver.py +8 −9 Original line number Diff line number Diff line Loading @@ -169,7 +169,6 @@ def edit_config( elif (conditions['edit_type']=='optical-band'): #roadm optical-band str_config_messages = create_optical_band(resources) elif (conditions['edit_type']=='network-media-channel'): commit_per_rule=True #openroadm network media channel Loading