@@ -723,6 +723,56 @@ def get_existing_channels(
723723 return existingChannels
724724
725725
726+ def handle_old_channels (
727+ old_channels : List [CFChannel ],
728+ new_channels : Set [str ],
729+ records_to_delete : List [str ],
730+ channel_ioc_ids : Dict [str , List [str ]],
731+ iocs : Dict [str , IocInfo ],
732+ ioc_info : IocInfo ,
733+ recceiverid : str ,
734+ processor : CFProcessor ,
735+ cf_config : CFConfig ,
736+ channels : List [CFChannel ],
737+ recordInfoByName : Dict [str , RecordInfo ],
738+ iocid : str ,
739+ ):
740+ for cf_channel in old_channels :
741+ if (
742+ len (new_channels ) == 0 or cf_channel .name in records_to_delete
743+ ): # case: empty commit/del, remove all reference to ioc
744+ _log .debug ("Channel %s exists in Channelfinder not in new_channels" , cf_channel )
745+ if cf_channel .name in channel_ioc_ids :
746+ handle_channel_is_old (
747+ channel_ioc_ids ,
748+ cf_channel ,
749+ iocs ,
750+ ioc_info ,
751+ recceiverid ,
752+ processor ,
753+ cf_config ,
754+ channels ,
755+ recordInfoByName ,
756+ )
757+ else :
758+ """Orphan the channel : mark as inactive, keep the old hostName and iocName"""
759+ orphan_channel (cf_channel , ioc_info , channels , cf_config , recordInfoByName )
760+ else :
761+ if cf_channel .name in new_channels : # case: channel in old and new
762+ handle_channel_old_and_new (
763+ cf_channel ,
764+ iocid ,
765+ ioc_info ,
766+ processor ,
767+ channels ,
768+ new_channels ,
769+ cf_config ,
770+ recordInfoByName ,
771+ old_channels ,
772+ )
773+ return cf_channel
774+
775+
726776def __updateCF__ (processor : CFProcessor , recordInfoByName : Dict [str , RecordInfo ], records_to_delete , ioc_info : IocInfo ):
727777 _log .info ("CF Update IOC: %s" , ioc_info )
728778 _log .debug ("CF Update IOC: %s recordInfoByName %s" , ioc_info , recordInfoByName )
@@ -753,39 +803,20 @@ def __updateCF__(processor: CFProcessor, recordInfoByName: Dict[str, RecordInfo]
753803 ]
754804
755805 if old_channels is not None :
756- for cf_channel in old_channels :
757- if (
758- len (new_channels ) == 0 or cf_channel .name in records_to_delete
759- ): # case: empty commit/del, remove all reference to ioc
760- _log .debug ("Channel %s exists in Channelfinder not in new_channels" , cf_channel )
761- if cf_channel .name in channel_ioc_ids :
762- handle_channel_is_old (
763- channel_ioc_ids ,
764- cf_channel ,
765- iocs ,
766- ioc_info ,
767- recceiverid ,
768- processor ,
769- cf_config ,
770- channels ,
771- recordInfoByName ,
772- )
773- else :
774- """Orphan the channel : mark as inactive, keep the old hostName and iocName"""
775- orphan_channel (cf_channel , ioc_info , channels , cf_config , recordInfoByName )
776- else :
777- if cf_channel .name in new_channels : # case: channel in old and new
778- handle_channel_old_and_new (
779- cf_channel ,
780- iocid ,
781- ioc_info ,
782- processor ,
783- channels ,
784- new_channels ,
785- cf_config ,
786- recordInfoByName ,
787- old_channels ,
788- )
806+ handle_old_channels (
807+ old_channels ,
808+ new_channels ,
809+ records_to_delete ,
810+ channel_ioc_ids ,
811+ iocs ,
812+ ioc_info ,
813+ recceiverid ,
814+ processor ,
815+ cf_config ,
816+ channels ,
817+ recordInfoByName ,
818+ iocid ,
819+ )
789820 # now pvNames contains a list of pv's new on this host/ioc
790821 existingChannels = get_existing_channels (new_channels , client , cf_config , processor )
791822
0 commit comments