Loading proto/context.proto +27 −0 Original line number Diff line number Diff line Loading @@ -665,6 +665,8 @@ message AuthenticationResult { bool authenticated = 2; } // ---------------- Experimental ------------------------ message OpticalConfigId { string opticalconfig_uuid = 1; Loading @@ -685,6 +687,8 @@ message OpticalConfigEvent { } // ---- Optical Link ---- message OpticalEndPointId { Loading Loading @@ -719,6 +723,29 @@ message OpticalLink { } message ChannelId { Uuid channel_uuid = 1; } message OpticalBandId { Uuid opticalband_uuid = 1; } message OpticalBand { OpticalBandId opticalband_id = 1 ; ConnectionId connection_id =2 ; ChannelId channel_id = 3; ServiceId service_id =4; } message OpticalBandList { repeated OpticalBand opticalbands =1 ; } ////////////////// Config Rule Delete //////////// Loading src/common/tools/descriptor/Loader.py +1 −0 Original line number Diff line number Diff line Loading @@ -509,6 +509,7 @@ class DescriptorLoader: self._unload_normal_mode() def compose_notifications(results : TypeResults) -> TypeNotificationList: notifications = [] for entity_name, action_name, num_ok, error_list in results: entity_name_singluar,entity_name_plural = ENTITY_TO_TEXT[entity_name] Loading src/context/client/ContextClient.py +17 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,8 @@ from common.proto.context_pb2 import ( OpticalConfig, OpticalConfigId, OpticalConfigList , OpticalLink, OpticalLinkList, Service, ServiceConfigRule, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList, Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList, Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList,OpticalBand ,OpticalBandId, OpticalBandList ) from common.proto.context_pb2_grpc import ContextServiceStub from common.proto.context_policy_pb2_grpc import ContextPolicyServiceStub Loading Loading @@ -484,6 +485,21 @@ class ContextClient: LOGGER.debug('DeleteOpticalChannel result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def GetOpticalBand(self, request : Empty) -> OpticalBandList: LOGGER.debug('GetOpticalBand request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.GetOpticalBand(request) LOGGER.debug('GetOpticalBand result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def SetOpticalBand(self,request : OpticalBand) -> Empty: LOGGER.debug('SetOpticalBand request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.SetOpticalBand(request) LOGGER.debug('SetOpticalBand result: {:s}'.format(grpc_message_to_json_string(response))) return response #--------------------------- Optical Link ------------------------ def GetOpticalLinkList(self, request: Empty) -> OpticalLinkList: LOGGER.debug('ListOpticalLinks request: {:s}'.format(grpc_message_to_json_string(request))) Loading src/context/service/ContextServiceServicerImpl.py +16 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ from common.proto.context_pb2 import ( Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList, Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList, OpticalConfigList, OpticalConfigId, OpticalConfig, OpticalLink, OpticalLinkList, ServiceConfigRule ServiceConfigRule,OpticalBand,OpticalBandId,OpticalBandList ) from common.proto.policy_pb2 import PolicyRuleIdList, PolicyRuleId, PolicyRuleList, PolicyRule from common.proto.context_pb2_grpc import ContextServiceServicer Loading Loading @@ -69,6 +69,10 @@ from .database.OpticalLink import ( optical_link_delete, optical_link_get, optical_link_list_objs, optical_link_set ) from .database.ConfigRule import delete_config_rule from .database.OpticalBand import ( get_optical_band,set_optical_band ) LOGGER = logging.getLogger(__name__) METRICS_POOL = MetricsPool('Context', 'RPC') Loading Loading @@ -358,6 +362,17 @@ class ContextServiceServicerImpl(ContextServiceServicer, ContextPolicyServiceSer delete_opticalchannel(self.db_engine, self.messagebroker, request) return Empty() @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def GetOpticalBand(self, request : Empty, context : grpc.ServicerContext) -> OpticalBandList: result = get_optical_band(self.db_engine) return OpticalBandList(opticalbands=result) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def SetOpticalBand(self, request : OpticalBand, context : grpc.ServicerContext) -> Empty: result = set_optical_band(self.db_engine, request) return Empty() #--------------------- Experimental Optical Link ------------------- @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) Loading src/context/service/database/OpticalBand.py 0 → 100644 +54 −0 Original line number Diff line number Diff line # Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (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 logging from sqlalchemy.engine import Engine from sqlalchemy.orm import Session, selectinload, sessionmaker from sqlalchemy_cockroachdb import run_transaction from sqlalchemy.dialects.postgresql import insert from typing import Dict, List from common.proto.context_pb2 import OpticalBand,OpticalBandId,OpticalBandList from .models.OpticalConfig.OpticalBandModel import OpticalBandModel LOGGER = logging.getLogger(__name__) def get_optical_band(db_engine : Engine): def callback(session:Session): results = session.query(OpticalBandModel).all() return {"opticalbands":[obj.dump_id() for obj in results]} obj = run_transaction(sessionmaker(bind=db_engine), callback) return obj def set_optical_band(db_engine : Engine, ob_data ): def callback(session : Session) -> List[Dict]: if len(ob_data) > 0: stmt = insert(OpticalBandModel).values(ob_data) stmt = stmt.on_conflict_do_update( index_elements=[OpticalBandModel.ob_uuid], set_=dict( connection_uuid = stmt.excluded.connection_uuid ) ) stmt = stmt.returning(OpticalBandModel.ob_uuid) ob_id = session.execute(stmt).fetchone() ob_id = run_transaction(sessionmaker(bind=db_engine), callback) return {'ob_id': ob_id} Loading
proto/context.proto +27 −0 Original line number Diff line number Diff line Loading @@ -665,6 +665,8 @@ message AuthenticationResult { bool authenticated = 2; } // ---------------- Experimental ------------------------ message OpticalConfigId { string opticalconfig_uuid = 1; Loading @@ -685,6 +687,8 @@ message OpticalConfigEvent { } // ---- Optical Link ---- message OpticalEndPointId { Loading Loading @@ -719,6 +723,29 @@ message OpticalLink { } message ChannelId { Uuid channel_uuid = 1; } message OpticalBandId { Uuid opticalband_uuid = 1; } message OpticalBand { OpticalBandId opticalband_id = 1 ; ConnectionId connection_id =2 ; ChannelId channel_id = 3; ServiceId service_id =4; } message OpticalBandList { repeated OpticalBand opticalbands =1 ; } ////////////////// Config Rule Delete //////////// Loading
src/common/tools/descriptor/Loader.py +1 −0 Original line number Diff line number Diff line Loading @@ -509,6 +509,7 @@ class DescriptorLoader: self._unload_normal_mode() def compose_notifications(results : TypeResults) -> TypeNotificationList: notifications = [] for entity_name, action_name, num_ok, error_list in results: entity_name_singluar,entity_name_plural = ENTITY_TO_TEXT[entity_name] Loading
src/context/client/ContextClient.py +17 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,8 @@ from common.proto.context_pb2 import ( OpticalConfig, OpticalConfigId, OpticalConfigList , OpticalLink, OpticalLinkList, Service, ServiceConfigRule, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList, Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList, Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList,OpticalBand ,OpticalBandId, OpticalBandList ) from common.proto.context_pb2_grpc import ContextServiceStub from common.proto.context_policy_pb2_grpc import ContextPolicyServiceStub Loading Loading @@ -484,6 +485,21 @@ class ContextClient: LOGGER.debug('DeleteOpticalChannel result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def GetOpticalBand(self, request : Empty) -> OpticalBandList: LOGGER.debug('GetOpticalBand request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.GetOpticalBand(request) LOGGER.debug('GetOpticalBand result: {:s}'.format(grpc_message_to_json_string(response))) return response @RETRY_DECORATOR def SetOpticalBand(self,request : OpticalBand) -> Empty: LOGGER.debug('SetOpticalBand request: {:s}'.format(grpc_message_to_json_string(request))) response = self.stub.SetOpticalBand(request) LOGGER.debug('SetOpticalBand result: {:s}'.format(grpc_message_to_json_string(response))) return response #--------------------------- Optical Link ------------------------ def GetOpticalLinkList(self, request: Empty) -> OpticalLinkList: LOGGER.debug('ListOpticalLinks request: {:s}'.format(grpc_message_to_json_string(request))) Loading
src/context/service/ContextServiceServicerImpl.py +16 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ from common.proto.context_pb2 import ( Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList, Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList, OpticalConfigList, OpticalConfigId, OpticalConfig, OpticalLink, OpticalLinkList, ServiceConfigRule ServiceConfigRule,OpticalBand,OpticalBandId,OpticalBandList ) from common.proto.policy_pb2 import PolicyRuleIdList, PolicyRuleId, PolicyRuleList, PolicyRule from common.proto.context_pb2_grpc import ContextServiceServicer Loading Loading @@ -69,6 +69,10 @@ from .database.OpticalLink import ( optical_link_delete, optical_link_get, optical_link_list_objs, optical_link_set ) from .database.ConfigRule import delete_config_rule from .database.OpticalBand import ( get_optical_band,set_optical_band ) LOGGER = logging.getLogger(__name__) METRICS_POOL = MetricsPool('Context', 'RPC') Loading Loading @@ -358,6 +362,17 @@ class ContextServiceServicerImpl(ContextServiceServicer, ContextPolicyServiceSer delete_opticalchannel(self.db_engine, self.messagebroker, request) return Empty() @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def GetOpticalBand(self, request : Empty, context : grpc.ServicerContext) -> OpticalBandList: result = get_optical_band(self.db_engine) return OpticalBandList(opticalbands=result) @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def SetOpticalBand(self, request : OpticalBand, context : grpc.ServicerContext) -> Empty: result = set_optical_band(self.db_engine, request) return Empty() #--------------------- Experimental Optical Link ------------------- @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) Loading
src/context/service/database/OpticalBand.py 0 → 100644 +54 −0 Original line number Diff line number Diff line # Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (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 logging from sqlalchemy.engine import Engine from sqlalchemy.orm import Session, selectinload, sessionmaker from sqlalchemy_cockroachdb import run_transaction from sqlalchemy.dialects.postgresql import insert from typing import Dict, List from common.proto.context_pb2 import OpticalBand,OpticalBandId,OpticalBandList from .models.OpticalConfig.OpticalBandModel import OpticalBandModel LOGGER = logging.getLogger(__name__) def get_optical_band(db_engine : Engine): def callback(session:Session): results = session.query(OpticalBandModel).all() return {"opticalbands":[obj.dump_id() for obj in results]} obj = run_transaction(sessionmaker(bind=db_engine), callback) return obj def set_optical_band(db_engine : Engine, ob_data ): def callback(session : Session) -> List[Dict]: if len(ob_data) > 0: stmt = insert(OpticalBandModel).values(ob_data) stmt = stmt.on_conflict_do_update( index_elements=[OpticalBandModel.ob_uuid], set_=dict( connection_uuid = stmt.excluded.connection_uuid ) ) stmt = stmt.returning(OpticalBandModel.ob_uuid) ob_id = session.execute(stmt).fetchone() ob_id = run_transaction(sessionmaker(bind=db_engine), callback) return {'ob_id': ob_id}