Scheduled maintenance on Saturday, 27 September 2025, from 07:00 AM to 4:00 PM GMT (09:00 AM to 6:00 PM CEST) - some services may be unavailable -

Skip to content
Snippets Groups Projects
Select Git revision
  • 2460257e9eb03fe2e1718f4441a3332ce1208ff5
  • master default
  • feat/320-cttc-ietf-simap-basic-support-with-kafka-yang-push
  • feat/314-tid-new-service-for-ipowdm-configuration-fron-orchestrator-to-ipowdm-controller
  • feat/327-tid-new-service-to-ipowdm-controller-to-manage-transceivers-configuration-on-external-agent
  • feat/292-cttc-implement-integration-test-for-ryu-openflow
  • cnit_tapi
  • cnit-p2mp-premerge
  • feat/325-tid-nbi-e2e-to-manage-e2e-path-computation
  • feat/307-update-python-version-service
  • feat/326-tid-external-management-of-devices-telemetry-nbi
  • openroadm-flex-grid
  • feat/310-cttc-implement-nbi-connector-to-interface-with-osm-client
  • develop protected
  • feat/324-tid-nbi-ietf_l3vpn-deploy-fail
  • feat/321-add-support-for-gnmi-configuration-via-proto
  • feat/322-add-read-support-for-ipinfusion-devices-via-netconf
  • feat/323-add-support-for-restconf-protocol-in-devices
  • feat/policy-refactor
  • feat/192-cttc-implement-telemetry-backend-collector-gnmi-openconfig
  • feat/307-update-python-version
  • feat/telemetry-collector-int
  • v5.0.0 protected
  • v4.0.0 protected
  • demo-dpiab-eucnc2024
  • v3.0.0 protected
  • v2.1.0 protected
  • v2.0.0 protected
  • v1.0.0 protected
29 results

PolicyRule.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    OpticalConfigModel.py 4.94 KiB
    # Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #      http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # 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
    from sqlalchemy.dialects.postgresql import ARRAY
    from sqlalchemy.orm import relationship
    from ._Base import _Base
    
    class OpticalConfigModel(_Base):
        __tablename__ = 'optical_config'
        opticalconfig_uuid = Column(String, primary_key=True)
        channel_namespace  = Column(String, nullable=True)
        endpoints          = Column(ARRAY(String), nullable=True)
        type               = Column(String,nullable=False)
        
        # transcievers       = Column(ARRAY(String), nullable=True)
        # interfaces         = Column(String, nullable=True)
      
       
        #channels           = relationship("OpticalChannelModel")
        transponders=relationship("TransponderTypeModel")
        
        
        device_uuid = Column(ForeignKey("device.device_uuid",ondelete="CASCADE"),index=True ,nullable=False)
        device= relationship("DeviceModel",  back_populates='optical_config')
        
    
        
        def dump_id (self ):
            return {
                "opticalconfig_uuid":self.opticalconfig_uuid,
                "device_uuid" :self.device_uuid
            }
    
        def dump(self):
            obj={
                # "channels"          : [channel.dump() for channel in self.channels],
                # "transceivers"      : {"transceiver": [transciever for transciever in self.transcievers]},
                # "interfaces"        : {"interface":json.loads(self.interfaces) if self.interfaces else ''},
                "channel_namespace" : self.channel_namespace,
                "endpoints"         : [json.loads(endpoint) for endpoint in self.endpoints if endpoint],
                "device_name"       : self.device.device_name,
                "type"              : self.type
            }
            if self.type =="optical-transponder" :
                channels= [transponer.dump() for transponer in self.transponders ][0]
                obj['transponder']=channels
                logging.info(f"optical_config_model {obj}")
            return obj
            
    
    class TransponderTypeModel (_Base):
        
        __tablename__             = 'transponder_type'
        transponder_uuid          = Column(String, primary_key=True)
               
        transcievers              = Column(ARRAY(String), nullable=True)
        interfaces                = Column(String, nullable=True)
        channels                  = relationship("OpticalChannelModel")
        
        opticalconfig_uuid        = Column(ForeignKey('optical_config.opticalconfig_uuid',  ondelete='CASCADE' ),index=True ,nullable=False)
        opticalconfig             = relationship('OpticalConfigModel',     back_populates='transponders')
        
        def dump_id (self): 
            return {
                "transponder_uuid":self.transponder_uuid
            }
        
        def dump (self):
            return {
                "channels"          : [channel.dump() for channel in self.channels],
                "transceivers"      : {"transceiver": [transciever for transciever in self.transcievers]},
                "interfaces"        : {"interface":json.loads(self.interfaces) if self.interfaces else ''},
                "trasponder_uuid"   : self.dump_id()
            }
    
    class OpticalChannelModel(_Base):
        __tablename__         =      'optical_channel'
        channel_uuid          =       Column(String, primary_key=True)
        
        channel_name          =       Column (String,nullable=True)
        frequency             =       Column(Integer, nullable=True)
        operational_mode      =       Column(Integer, nullable=True)
        status                =       Column(String , nullable=True)
        target_output_power   =       Column(String, nullable=True)
        
        transponder_uuid      =       Column(ForeignKey('transponder_type.transponder_uuid', ondelete='CASCADE' ),nullable=False)
        transponder           =       relationship('TransponderTypeModel',back_populates='channels')
        # opticalconfig_uuid        = Column(ForeignKey('optical_config.opticalconfig_uuid',         ondelete='CASCADE' ), primary_key=True)
        # opticalconfig             = relationship('OpticalConfigModel',     back_populates='channels')
        def dump_id (self ):
            return {
                "channel_uuid":self.channel_uuid
            }
    
        def dump(self):
            return {
                "name"      :{'index':self.channel_name},
                "frequency"         : self.frequency,
                "target-output-power"      : self.target_output_power,
                "operational-mode"  : self.operational_mode,
                "status":self.status
            }