Loading src/context/client/ContextClient.py +2 −2 Original line number Diff line number Diff line Loading @@ -24,10 +24,10 @@ from common.proto.context_pb2 import ( Device, DeviceEvent, DeviceFilter, DeviceId, DeviceIdList, DeviceList, Empty, EndPointIdList, EndPointNameList, Link, LinkEvent, LinkId, LinkIdList, LinkList, Service, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, OpticalConfig, OpticalConfigId, OpticalConfigList , OpticalLink, OpticalLinkList, Service, ServiceConfigRule, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList, Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList, OpticalConfig, OpticalConfigId, OpticalConfigList , OpticalLink ,OpticalLinkList,ServiceConfigRule ) from common.proto.context_pb2_grpc import ContextServiceStub from common.proto.context_policy_pb2_grpc import ContextPolicyServiceStub Loading src/context/service/database/models/OpticalConfig/OpticalConfigModel.py +8 −18 Original line number Diff line number Diff line Loading @@ -12,12 +12,11 @@ # 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 import json from sqlalchemy import Column, String, ForeignKey from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.orm import relationship from context.service.database.models._Base import _Base from .RoadmModel import RoadmTypeModel class OpticalConfigModel(_Base): __tablename__ = 'optical_config' Loading @@ -28,18 +27,13 @@ class OpticalConfigModel(_Base): # transcievers = Column(ARRAY(String), nullable=True) # interfaces = Column(String, nullable=True) # channels = relationship("OpticalChannelModel") transponders = relationship("TransponderTypeModel") roadms = relationship("RoadmTypeModel") 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, Loading Loading @@ -67,8 +61,4 @@ class OpticalConfigModel(_Base): channels=[roadms.dump() for roadms in self.roadms ][0] obj['channels']=channels['channels'] if 'channels' in channels else None obj['roadm_uuid']=channels['roadm_uuid'] if 'roadm_uuid' in channels else None return obj src/context/service/database/models/OpticalConfig/RoadmModel.py +40 −49 Original line number Diff line number Diff line # Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -13,24 +12,16 @@ # 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 import Column, String, Integer , ForeignKey from sqlalchemy.orm import relationship from context.service.database.models._Base import _Base class RoadmTypeModel (_Base): __tablename__ = 'roadm_type' roadm_uuid = Column(String, primary_key=True) channels = relationship("ChannelModel") circuits = Column(String, nullable=True) opticalconfig_uuid = Column(ForeignKey('optical_config.opticalconfig_uuid', ondelete='CASCADE'), index=True, nullable=False) channels = relationship("ChannelModel") opticalconfig = relationship('OpticalConfigModel', back_populates='roadms') def dump_id (self): Loading @@ -41,11 +32,12 @@ 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(), } class ChannelModel(_Base): __tablename__ = 'channel' channel_uuid = Column(String, primary_key=True) band_name = Column(String, nullable=True) lower_frequency = Column(Integer, nullable=True) Loading @@ -54,14 +46,15 @@ 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) 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) # opticalconfig = relationship('OpticalConfigModel', back_populates='channels') def dump_id (self ): return { "channel_uuid": self.channel_uuid Loading @@ -75,9 +68,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 "channel_index" : self.channel_index, } src/context/service/database/models/OpticalConfig/TransponderModel.py +36 −42 Original line number Diff line number Diff line # Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -13,26 +12,21 @@ # 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 import json from sqlalchemy import Column, String, Integer , ForeignKey from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.orm import relationship from context.service.database.models._Base import _Base class TransponderTypeModel (_Base): __tablename__ = 'transponder_type' transponder_uuid = Column(String, primary_key=True) 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) channels = relationship("OpticalChannelModel") opticalconfig = relationship('OpticalConfigModel', back_populates='transponders') def dump_id (self): Loading @@ -50,18 +44,19 @@ class TransponderTypeModel (_Base): class OpticalChannelModel(_Base): __tablename__ = 'optical_channel' channel_uuid = Column(String, primary_key=True) 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 Loading @@ -73,6 +68,5 @@ class OpticalChannelModel(_Base): "frequency" : self.frequency, "target-output-power" : self.target_output_power, "operational-mode" : self.operational_mode, "status":self.status "status" : self.status, } src/context/service/database/models/OpticalLinkModel.py +21 −42 Original line number Diff line number Diff line Loading @@ -13,20 +13,12 @@ # limitations under the License. import operator from sqlalchemy import CheckConstraint, Column, DateTime, Float, ForeignKey, Integer, String ,Boolean from sqlalchemy import Column, DateTime, ForeignKey, Integer, String ,Boolean from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.types import PickleType , TypeDecorator ,Integer from sqlalchemy.orm import relationship import json,logging from typing import Dict from ._Base import _Base from .Slot import C_Slot ,S_Slot , L_Slot from common.tools.object_factory.OpticalLink import order_dict class OpticalLinkModel(_Base): __tablename__ = 'opticallink' Loading @@ -44,52 +36,39 @@ class OpticalLinkModel(_Base): c_slots = Column (C_Slot,nullable=True) l_slots = Column (L_Slot,nullable=True) s_slots = Column (S_Slot,nullable=True) opticallink_endpoints = relationship("OpticalLinkEndPointModel") opticallink_endpoints = relationship('OpticalLinkEndPointModel') topology_optical_links = relationship('TopologyOpticalLinkModel', back_populates='optical_link') def dump_id(self) -> Dict: return {'link_uuid': {'uuid': self.opticallink_uuid}} def dump(self) -> Dict: result = { 'link_id' : self.dump_id(), 'name' : self.name, 'optical_details' : { 'length' : self.length, "src_port" : self.src_port, "dst_port" : self.dst_port, "local_peer_port" : self.local_peer_port, "remote_peer_port" : self.remote_peer_port, "used" : self.used, "c_slots" : order_dict(self.c_slots) if self.c_slots is not None else {} , "l_slots" : order_dict(self.l_slots) if self.l_slots is not None else {}, "s_slots" : order_dict(self.s_slots) if self.s_slots is not None else {} 'src_port' : self.src_port, 'dst_port' : self.dst_port, 'local_peer_port' : self.local_peer_port, 'remote_peer_port' : self.remote_peer_port, 'used' : self.used, 'c_slots' : self.c_slots if self.c_slots is not None else {}, 'l_slots' : self.l_slots if self.l_slots is not None else {}, 's_slots' : self.s_slots if self.s_slots is not None else {}, }, "link_endpoint_ids" : [optical_endpoint.endpoint.dump_id() for optical_endpoint in self.opticallink_endpoints] 'link_endpoint_ids' : [ optical_endpoint.endpoint.dump_id() for optical_endpoint in self.opticallink_endpoints ], } return result class OpticalLinkEndPointModel(_Base): __tablename__ = 'opticallink_endpoint' link_uuid = Column(ForeignKey('opticallink.opticallink_uuid', ondelete='CASCADE' ), primary_key=True) endpoint_uuid = Column(ForeignKey('endpoint.endpoint_uuid', ondelete='RESTRICT'), primary_key=True, index=True) optical_link = relationship('OpticalLinkModel', back_populates='opticallink_endpoints') endpoint = relationship('EndPointModel', lazy='selectin') Loading
src/context/client/ContextClient.py +2 −2 Original line number Diff line number Diff line Loading @@ -24,10 +24,10 @@ from common.proto.context_pb2 import ( Device, DeviceEvent, DeviceFilter, DeviceId, DeviceIdList, DeviceList, Empty, EndPointIdList, EndPointNameList, Link, LinkEvent, LinkId, LinkIdList, LinkList, Service, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, OpticalConfig, OpticalConfigId, OpticalConfigList , OpticalLink, OpticalLinkList, Service, ServiceConfigRule, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList, Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList, OpticalConfig, OpticalConfigId, OpticalConfigList , OpticalLink ,OpticalLinkList,ServiceConfigRule ) from common.proto.context_pb2_grpc import ContextServiceStub from common.proto.context_policy_pb2_grpc import ContextPolicyServiceStub Loading
src/context/service/database/models/OpticalConfig/OpticalConfigModel.py +8 −18 Original line number Diff line number Diff line Loading @@ -12,12 +12,11 @@ # 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 import json from sqlalchemy import Column, String, ForeignKey from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.orm import relationship from context.service.database.models._Base import _Base from .RoadmModel import RoadmTypeModel class OpticalConfigModel(_Base): __tablename__ = 'optical_config' Loading @@ -28,18 +27,13 @@ class OpticalConfigModel(_Base): # transcievers = Column(ARRAY(String), nullable=True) # interfaces = Column(String, nullable=True) # channels = relationship("OpticalChannelModel") transponders = relationship("TransponderTypeModel") roadms = relationship("RoadmTypeModel") 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, Loading Loading @@ -67,8 +61,4 @@ class OpticalConfigModel(_Base): channels=[roadms.dump() for roadms in self.roadms ][0] obj['channels']=channels['channels'] if 'channels' in channels else None obj['roadm_uuid']=channels['roadm_uuid'] if 'roadm_uuid' in channels else None return obj
src/context/service/database/models/OpticalConfig/RoadmModel.py +40 −49 Original line number Diff line number Diff line # Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -13,24 +12,16 @@ # 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 import Column, String, Integer , ForeignKey from sqlalchemy.orm import relationship from context.service.database.models._Base import _Base class RoadmTypeModel (_Base): __tablename__ = 'roadm_type' roadm_uuid = Column(String, primary_key=True) channels = relationship("ChannelModel") circuits = Column(String, nullable=True) opticalconfig_uuid = Column(ForeignKey('optical_config.opticalconfig_uuid', ondelete='CASCADE'), index=True, nullable=False) channels = relationship("ChannelModel") opticalconfig = relationship('OpticalConfigModel', back_populates='roadms') def dump_id (self): Loading @@ -41,11 +32,12 @@ 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(), } class ChannelModel(_Base): __tablename__ = 'channel' channel_uuid = Column(String, primary_key=True) band_name = Column(String, nullable=True) lower_frequency = Column(Integer, nullable=True) Loading @@ -54,14 +46,15 @@ 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) 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) # opticalconfig = relationship('OpticalConfigModel', back_populates='channels') def dump_id (self ): return { "channel_uuid": self.channel_uuid Loading @@ -75,9 +68,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 "channel_index" : self.channel_index, }
src/context/service/database/models/OpticalConfig/TransponderModel.py +36 −42 Original line number Diff line number Diff line # Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -13,26 +12,21 @@ # 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 import json from sqlalchemy import Column, String, Integer , ForeignKey from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.orm import relationship from context.service.database.models._Base import _Base class TransponderTypeModel (_Base): __tablename__ = 'transponder_type' transponder_uuid = Column(String, primary_key=True) 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) channels = relationship("OpticalChannelModel") opticalconfig = relationship('OpticalConfigModel', back_populates='transponders') def dump_id (self): Loading @@ -50,18 +44,19 @@ class TransponderTypeModel (_Base): class OpticalChannelModel(_Base): __tablename__ = 'optical_channel' channel_uuid = Column(String, primary_key=True) 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 Loading @@ -73,6 +68,5 @@ class OpticalChannelModel(_Base): "frequency" : self.frequency, "target-output-power" : self.target_output_power, "operational-mode" : self.operational_mode, "status":self.status "status" : self.status, }
src/context/service/database/models/OpticalLinkModel.py +21 −42 Original line number Diff line number Diff line Loading @@ -13,20 +13,12 @@ # limitations under the License. import operator from sqlalchemy import CheckConstraint, Column, DateTime, Float, ForeignKey, Integer, String ,Boolean from sqlalchemy import Column, DateTime, ForeignKey, Integer, String ,Boolean from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.types import PickleType , TypeDecorator ,Integer from sqlalchemy.orm import relationship import json,logging from typing import Dict from ._Base import _Base from .Slot import C_Slot ,S_Slot , L_Slot from common.tools.object_factory.OpticalLink import order_dict class OpticalLinkModel(_Base): __tablename__ = 'opticallink' Loading @@ -44,52 +36,39 @@ class OpticalLinkModel(_Base): c_slots = Column (C_Slot,nullable=True) l_slots = Column (L_Slot,nullable=True) s_slots = Column (S_Slot,nullable=True) opticallink_endpoints = relationship("OpticalLinkEndPointModel") opticallink_endpoints = relationship('OpticalLinkEndPointModel') topology_optical_links = relationship('TopologyOpticalLinkModel', back_populates='optical_link') def dump_id(self) -> Dict: return {'link_uuid': {'uuid': self.opticallink_uuid}} def dump(self) -> Dict: result = { 'link_id' : self.dump_id(), 'name' : self.name, 'optical_details' : { 'length' : self.length, "src_port" : self.src_port, "dst_port" : self.dst_port, "local_peer_port" : self.local_peer_port, "remote_peer_port" : self.remote_peer_port, "used" : self.used, "c_slots" : order_dict(self.c_slots) if self.c_slots is not None else {} , "l_slots" : order_dict(self.l_slots) if self.l_slots is not None else {}, "s_slots" : order_dict(self.s_slots) if self.s_slots is not None else {} 'src_port' : self.src_port, 'dst_port' : self.dst_port, 'local_peer_port' : self.local_peer_port, 'remote_peer_port' : self.remote_peer_port, 'used' : self.used, 'c_slots' : self.c_slots if self.c_slots is not None else {}, 'l_slots' : self.l_slots if self.l_slots is not None else {}, 's_slots' : self.s_slots if self.s_slots is not None else {}, }, "link_endpoint_ids" : [optical_endpoint.endpoint.dump_id() for optical_endpoint in self.opticallink_endpoints] 'link_endpoint_ids' : [ optical_endpoint.endpoint.dump_id() for optical_endpoint in self.opticallink_endpoints ], } return result class OpticalLinkEndPointModel(_Base): __tablename__ = 'opticallink_endpoint' link_uuid = Column(ForeignKey('opticallink.opticallink_uuid', ondelete='CASCADE' ), primary_key=True) endpoint_uuid = Column(ForeignKey('endpoint.endpoint_uuid', ondelete='RESTRICT'), primary_key=True, index=True) optical_link = relationship('OpticalLinkModel', back_populates='opticallink_endpoints') endpoint = relationship('EndPointModel', lazy='selectin')