@@ -691,6 +691,38 @@ def handle_channel_old_and_new(
691691 _log .debug ("Add existing alias with same IOC: %s" , cf_channel )
692692
693693
694+ def get_existing_channels (
695+ new_channels : Set [str ], client : ChannelFinderClient , cf_config : CFConfig , processor : CFProcessor
696+ ) -> Dict [str , CFChannel ]:
697+ """A dictionary representing the current channelfinder information associated with the pvNames"""
698+ existingChannels : Dict [str , CFChannel ] = {}
699+
700+ """
701+ The list of pv's is searched keeping in mind the limitations on the URL length
702+ The search is split into groups to ensure that the size does not exceed 600 characters
703+ """
704+ searchStrings = []
705+ searchString = ""
706+ for channel_name in new_channels :
707+ if not searchString :
708+ searchString = channel_name
709+ elif len (searchString ) + len (channel_name ) < 600 :
710+ searchString = searchString + "|" + channel_name
711+ else :
712+ searchStrings .append (searchString )
713+ searchString = channel_name
714+ if searchString :
715+ searchStrings .append (searchString )
716+
717+ for eachSearchString in searchStrings :
718+ _log .debug ("Find existing channels by name: %s" , eachSearchString )
719+ for found_channel in client .findByArgs (prepareFindArgs (cf_config , [("~name" , eachSearchString )])):
720+ existingChannels [found_channel ["name" ]] = CFChannel .from_channelfinder_dict (found_channel )
721+ if processor .cancelled :
722+ raise defer .CancelledError ()
723+ return existingChannels
724+
725+
694726def __updateCF__ (processor : CFProcessor , recordInfoByName : Dict [str , RecordInfo ], records_to_delete , ioc_info : IocInfo ):
695727 _log .info ("CF Update IOC: %s" , ioc_info )
696728 _log .debug ("CF Update IOC: %s recordInfoByName %s" , ioc_info , recordInfoByName )
@@ -755,32 +787,7 @@ def __updateCF__(processor: CFProcessor, recordInfoByName: Dict[str, RecordInfo]
755787 old_channels ,
756788 )
757789 # now pvNames contains a list of pv's new on this host/ioc
758- """A dictionary representing the current channelfinder information associated with the pvNames"""
759- existingChannels : Dict [str , CFChannel ] = {}
760-
761- """
762- The list of pv's is searched keeping in mind the limitations on the URL length
763- The search is split into groups to ensure that the size does not exceed 600 characters
764- """
765- searchStrings = []
766- searchString = ""
767- for channel_name in new_channels :
768- if not searchString :
769- searchString = channel_name
770- elif len (searchString ) + len (channel_name ) < 600 :
771- searchString = searchString + "|" + channel_name
772- else :
773- searchStrings .append (searchString )
774- searchString = channel_name
775- if searchString :
776- searchStrings .append (searchString )
777-
778- for eachSearchString in searchStrings :
779- _log .debug ("Find existing channels by name: %s" , eachSearchString )
780- for found_channel in client .findByArgs (prepareFindArgs (cf_config , [("~name" , eachSearchString )])):
781- existingChannels [found_channel ["name" ]] = CFChannel .from_channelfinder_dict (found_channel )
782- if processor .cancelled :
783- raise defer .CancelledError ()
790+ existingChannels = get_existing_channels (new_channels , client , cf_config , processor )
784791
785792 for channel_name in new_channels :
786793 newProps = create_properties (
0 commit comments