Commit bfdbe913 authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

Fix bugs on deconfigurations Roadms

parent 704eddbb
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -79,8 +79,10 @@ service ContextService {
  // ------------------------------ Experimental -----------------------------
  rpc GetOpticalConfig   (Empty             )    returns    (     OpticalConfigList  ) {}
  rpc SetOpticalConfig   (OpticalConfig     )    returns    (     OpticalConfigId    ) {}
  rpc UpdateOpticalConfig   (OpticalConfig  )    returns    (     OpticalConfigId    ) {}
  rpc SelectOpticalConfig(OpticalConfigId   )    returns    (     OpticalConfig      ) {}
  rpc DeleteOpticalConfig(OpticalConfigId   )    returns    (     Empty              ) {}
  rpc DeleteOpticalChannel(OpticalConfig    )    returns    (     Empty              ) {}

  rpc SetOpticalLink     (OpticalLink       )    returns (        Empty               ) {}
  rpc GetOpticalLink     (LinkId            )    returns (        OpticalLink         ) {}
+16 −0
Original line number Diff line number Diff line
@@ -448,6 +448,14 @@ class ContextClient:
        LOGGER.debug('SetOpticalConfig result: {:s}'.format(grpc_message_to_json_string(response)))
        return response
    
    @RETRY_DECORATOR
    def UpdateOpticalConfig(self, request : OpticalConfig) -> OpticalConfigId:
        LOGGER.debug('SetOpticalConfig request: {:s}'.format(grpc_message_to_json_string(request)))
        response_future = self.stub.UpdateOpticalConfig.future(request)
        response = response_future.result()
        LOGGER.debug('SetOpticalConfig result: {:s}'.format(grpc_message_to_json_string(response)))
        return response

    @RETRY_DECORATOR
    def GetOpticalConfig(self, request : Empty) -> OpticalConfigList:
        LOGGER.debug('GetOpticalConfig request: {:s}'.format(grpc_message_to_json_string(request)))
@@ -461,6 +469,7 @@ class ContextClient:
        response = self.stub.SelectOpticalConfig(request)
        LOGGER.debug('SelectOpticalConfig result: {:s}'.format(grpc_message_to_json_string(response)))
        return response
    
    @RETRY_DECORATOR
    def DeleteOpticalConfig(self,request : OpticalConfigId) -> Empty:
        LOGGER.debug('DeleteOpticalConfig request: {:s}'.format(grpc_message_to_json_string(request)))
@@ -468,6 +477,13 @@ class ContextClient:
        LOGGER.debug('DeleteOpticalConfig result: {:s}'.format(grpc_message_to_json_string(response)))
        return response
    
    @RETRY_DECORATOR
    def DeleteOpticalChannel(self,request : OpticalConfig) -> Empty:
        LOGGER.debug('DeleteOpticalChannel request: {:s}'.format(grpc_message_to_json_string(request)))
        response = self.stub.DeleteOpticalChannel(request)
        LOGGER.debug('DeleteOpticalChannel 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)))
+14 −3
Original line number Diff line number Diff line
@@ -45,8 +45,9 @@ from .database.Slice import (
    slice_delete, slice_get, slice_list_ids, slice_list_objs, slice_select, slice_set, slice_unset)
from .database.Topology import (
    topology_delete, topology_get, topology_get_details, topology_list_ids, topology_list_objs, topology_set)
from .database.OpticalConfig import set_opticalconfig, select_opticalconfig, get_opticalconfig ,delete_opticalconfig

from .database.OpticalConfig import (set_opticalconfig, select_opticalconfig, get_opticalconfig 
                                     ,delete_opticalconfig ,update_opticalconfig ,delete_opticalchannel
)
from .database.OpticalLink import optical_link_delete,optical_link_get,optical_link_list_objs,optical_link_set
LOGGER = logging.getLogger(__name__)

@@ -313,6 +314,11 @@ class ContextServiceServicerImpl(ContextServiceServicer, ContextPolicyServiceSer
        result = set_opticalconfig(self.db_engine, request)
        return OpticalConfigId(**result)
    
    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def UpdateOpticalConfig(self, request : OpticalConfig, context : grpc.ServicerContext) -> OpticalConfigId:
        result = update_opticalconfig(self.db_engine, request)
        return OpticalConfigId(**result)

    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def SelectOpticalConfig(self, request : OpticalConfigId, context : grpc.ServicerContext) -> OpticalConfig:
        result = select_opticalconfig(self.db_engine, request)
@@ -327,6 +333,11 @@ class ContextServiceServicerImpl(ContextServiceServicer, ContextPolicyServiceSer
        delete_opticalconfig(self.db_engine,self.messagebroker, request)
       
        return Empty()
    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def DeleteOpticalChannel (self, request : OpticalConfig, context : grpc.ServicerContext) -> Empty:
        delete_opticalchannel(self.db_engine,self.messagebroker, request)
       
        return Empty()
    

    #--------------------- Experimental Optical Link -------------------
+452 −10

File changed.

Preview size limit exceeded, changes collapsed.

+74 −0
Original line number Diff line number Diff line
# 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 context.service.database.models._Base import _Base
from .RoadmModel import RoadmTypeModel

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")
    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,
            "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['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
            
        if self.type =="optical-roadm" :
            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
                
                        
            logging.info(f"optical_config_model {obj}")
        return obj
        
Loading