@@ -521,15 +521,74 @@ def clean_channels(self, owner: str, channels: List[CFChannel]):
521521 for cf_channel in channels or []:
522522 new_channels .append (cf_channel .name )
523523 _log .info ("Cleaning %s channels." , len (new_channels ))
524- _log .debug (
525- 'Update "pvStatus" property to "Inactive" for %s channels' , len (new_channels )
526- )
524+ _log .debug ('Update "pvStatus" property to "Inactive" for %s channels' , len (new_channels ))
527525 self .client .update (
528526 property = CFProperty .inactive (owner ).as_dict (),
529527 channelNames = new_channels ,
530528 )
531529
532530
531+ def handle_channel_is_old (
532+ channel_ioc_ids : Dict [str , List [str ]],
533+ cf_channel : CFChannel ,
534+ iocs : Dict [str , IocInfo ],
535+ ioc_info : IocInfo ,
536+ recceiverid : str ,
537+ processor : CFProcessor ,
538+ cf_config : CFConfig ,
539+ channels : List [CFChannel ],
540+ recordInfoByName : Dict [str , RecordInfo ],
541+ ):
542+ last_ioc_id = channel_ioc_ids [cf_channel .name ][- 1 ]
543+ cf_channel .owner = iocs [last_ioc_id ].owner
544+ cf_channel .properties = __merge_property_lists (
545+ create_default_properties (ioc_info , recceiverid , channel_ioc_ids , iocs , cf_channel ),
546+ cf_channel ,
547+ processor .managed_properties ,
548+ )
549+ if cf_config .record_type_enabled :
550+ cf_channel .properties = __merge_property_lists (
551+ cf_channel .properties .append (CFProperty .recordType (ioc_info .owner , iocs [last_ioc_id ]["recordType" ])),
552+ cf_channel ,
553+ processor .managed_properties ,
554+ )
555+ channels .append (cf_channel )
556+ _log .debug ("Add existing channel %s to previous IOC %s" , cf_channel , last_ioc_id )
557+ """In case alias exist, also delete them"""
558+ if cf_config .alias_enabled :
559+ if cf_channel .name in recordInfoByName :
560+ for alias_name in recordInfoByName [cf_channel .name ].aliases :
561+ # TODO Remove? This code couldn't have been working....
562+ alias_channel = CFChannel (alias_name , "" , [])
563+ if alias_name in channel_ioc_ids :
564+ last_alias_ioc_id = channel_ioc_ids [alias_name ][- 1 ]
565+ alias_channel .owner = iocs [last_alias_ioc_id ].owner
566+ alias_channel .properties = __merge_property_lists (
567+ create_default_properties (
568+ ioc_info ,
569+ recceiverid ,
570+ channel_ioc_ids ,
571+ iocs ,
572+ cf_channel ,
573+ ),
574+ alias_channel ,
575+ processor .managed_properties ,
576+ )
577+ if cf_config .record_type_enabled :
578+ cf_channel .properties = __merge_property_lists (
579+ cf_channel .properties .append (
580+ CFProperty .recordType (
581+ ioc_info .owner ,
582+ iocs [last_alias_ioc_id ]["recordType" ],
583+ )
584+ ),
585+ cf_channel ,
586+ processor .managed_properties ,
587+ )
588+ channels .append (alias_channel )
589+ _log .debug ("Add existing alias %s to previous IOC: %s" , alias_channel , last_alias_ioc_id )
590+
591+
533592def __updateCF__ (processor : CFProcessor , recordInfoByName : Dict [str , RecordInfo ], records_to_delete , ioc_info : IocInfo ):
534593 _log .info ("CF Update IOC: %s" , ioc_info )
535594 _log .debug ("CF Update IOC: %s recordInfoByName %s" , ioc_info , recordInfoByName )
@@ -566,59 +625,17 @@ def __updateCF__(processor: CFProcessor, recordInfoByName: Dict[str, RecordInfo]
566625 ): # case: empty commit/del, remove all reference to ioc
567626 _log .debug ("Channel %s exists in Channelfinder not in new_channels" , cf_channel )
568627 if cf_channel .name in channel_ioc_ids :
569- last_ioc_id = channel_ioc_ids [cf_channel .name ][- 1 ]
570- cf_channel .owner = iocs [last_ioc_id ].owner
571- cf_channel .properties = __merge_property_lists (
572- create_default_properties (ioc_info , recceiverid , channel_ioc_ids , iocs , cf_channel ),
628+ handle_channel_is_old (
629+ channel_ioc_ids ,
573630 cf_channel ,
574- processor .managed_properties ,
631+ iocs ,
632+ ioc_info ,
633+ recceiverid ,
634+ processor ,
635+ cf_config ,
636+ channels ,
637+ recordInfoByName ,
575638 )
576- if cf_config .record_type_enabled :
577- cf_channel .properties = __merge_property_lists (
578- cf_channel .properties .append (
579- CFProperty .recordType (ioc_info .owner , iocs [last_ioc_id ]["recordType" ])
580- ),
581- cf_channel ,
582- processor .managed_properties ,
583- )
584- channels .append (cf_channel )
585- _log .debug ("Add existing channel %s to previous IOC %s" , cf_channel , last_ioc_id )
586- """In case alias exist, also delete them"""
587- if cf_config .alias_enabled :
588- if cf_channel .name in recordInfoByName :
589- for alias_name in recordInfoByName [cf_channel .name ].aliases :
590- # TODO Remove? This code couldn't have been working....
591- alias_channel = CFChannel (alias_name , "" , [])
592- if alias_name in channel_ioc_ids :
593- last_alias_ioc_id = channel_ioc_ids [alias_name ][- 1 ]
594- alias_channel .owner = iocs [last_alias_ioc_id ].owner
595- alias_channel .properties = __merge_property_lists (
596- create_default_properties (
597- ioc_info ,
598- recceiverid ,
599- channel_ioc_ids ,
600- iocs ,
601- cf_channel ,
602- ),
603- alias_channel ,
604- processor .managed_properties ,
605- )
606- if cf_config .record_type_enabled :
607- cf_channel .properties = __merge_property_lists (
608- cf_channel .properties .append (
609- CFProperty .recordType (
610- ioc_info .owner ,
611- iocs [last_alias_ioc_id ]["recordType" ],
612- )
613- ),
614- cf_channel ,
615- processor .managed_properties ,
616- )
617- channels .append (alias_channel )
618- _log .debug (
619- "Add existing alias %s to previous IOC: %s" , alias_channel , last_alias_ioc_id
620- )
621-
622639 else :
623640 """Orphan the channel : mark as inactive, keep the old hostName and iocName"""
624641 cf_channel .properties = __merge_property_lists (
0 commit comments