Commit d53fbe40 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

pre-merge code cleanup

parent cf73e215
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ def select_optical_band(db_engine : Engine, request : OpticalBandId) -> OpticalB


def set_optical_band(db_engine : Engine, ob_data : List[Dict]) -> Dict:
    LOGGER.warning('[update_opticalconfig] ob_data={:s}'.format(str(ob_data)))
    LOGGER.debug('[update_opticalconfig] ob_data={:s}'.format(str(ob_data)))

    def callback(session : Session) -> Optional[str]:
        if len(ob_data) == 0: return None
@@ -68,5 +68,5 @@ def set_optical_band(db_engine : Engine, ob_data : List[Dict]) -> Dict:
        return ob_id

    ob_id = run_transaction(sessionmaker(bind=db_engine), callback)
    LOGGER.warning('[update_opticalconfig] ob_id={:s}'.format(str(ob_id)))
    LOGGER.debug('[update_opticalconfig] ob_id={:s}'.format(str(ob_id)))
    return {'ob_id': ob_id}
+7 −7
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@ def set_opticalconfig(db_engine : Engine, request : OpticalConfig):
    return {'opticalconfig_uuid': opticalconfig_id}

def update_opticalconfig(db_engine : Engine, request : OpticalConfig):
    LOGGER.warning('[update_opticalconfig] received request: {:s}'.format(grpc_message_to_json_string(request)))
    LOGGER.debug('[update_opticalconfig] received request: {:s}'.format(grpc_message_to_json_string(request)))

    opticalconfig_id = OpticalConfigId()
    device_id = request.device_id
@@ -361,10 +361,10 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig):
    opticalconfig_uuid = opticalconfig_get_uuid(device_id)
    is_optical_band=None

    LOGGER.warning('[update_opticalconfig] request.config={:s}'.format(str(request.config)))
    LOGGER.debug('[update_opticalconfig] request.config={:s}'.format(str(request.config)))
    if request.config :
        config = json.loads(request.config)
        LOGGER.warning('[update_opticalconfig] config={:s}'.format(str(config)))
        LOGGER.debug('[update_opticalconfig] config={:s}'.format(str(config)))

        if  'new_config' in config:
            if 'type' in config:
@@ -457,14 +457,14 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig):

            if config_type == DeviceTypeEnum.OPTICAL_ROADM.value:
                MSG = '[update_opticalconfig] config_type == DeviceTypeEnum.OPTICAL_ROADM.value; config_type={:s}'
                LOGGER.warning(MSG.format(str(config_type)))
                LOGGER.debug(MSG.format(str(config_type)))

                if channel_namespace is None and  'channel_namespace' in config['new_config']:
                    channel_namespace=config['new_config']['channel_namespace']

                if 'is_opticalband' in config and not config['is_opticalband']:
                    MSG = '[update_opticalconfig] is_opticalband in config and not config[is_opticalband]; config={:s}'
                    LOGGER.warning(MSG.format(str(config)))
                    LOGGER.debug(MSG.format(str(config)))
                    is_optical_band=config['is_opticalband']
                    bidir = config['new_config']['bidir']
                    #channels = [channel['name']['index'] for channel in config['channels']]
@@ -492,7 +492,7 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig):
                            if not bidir: break
                if 'is_opticalband' in config and config['is_opticalband']:
                    MSG = '[update_opticalconfig] is_opticalband in config and config[is_opticalband]; config={:s}'
                    LOGGER.warning(MSG.format(str(config)))
                    LOGGER.debug(MSG.format(str(config)))
                    is_optical_band = config['is_opticalband']
                    #channels = [channel['name']['index'] for channel in config['channels']]
                    
@@ -619,7 +619,7 @@ def update_opticalconfig(db_engine : Engine, request : OpticalConfig):

    opticalconfig_id = run_transaction(sessionmaker(bind=db_engine), callback)

    LOGGER.warning('[update_opticalconfig] is_optical_band={:s}'.format(str(is_optical_band)))
    LOGGER.debug('[update_opticalconfig] is_optical_band={:s}'.format(str(is_optical_band)))
    if is_optical_band: set_optical_band(db_engine,optical_bands)
    return {'opticalconfig_uuid': opticalconfig_id}