Skip to content

Commit c292d1b

Browse files
committed
Pull out orphan channel
1 parent 17f1cb6 commit c292d1b

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

server/recceiver/cfstore.py

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,38 @@ def handle_channel_is_old(
589589
_log.debug("Add existing alias %s to previous IOC: %s", alias_channel, last_alias_ioc_id)
590590

591591

592+
def orphan_channel(
593+
cf_channel: CFChannel,
594+
ioc_info: IocInfo,
595+
channels: List[CFChannel],
596+
cf_config: CFConfig,
597+
recordInfoByName: Dict[str, RecordInfo],
598+
):
599+
cf_channel.properties = __merge_property_lists(
600+
[
601+
CFProperty.inactive(ioc_info.owner),
602+
CFProperty.time(ioc_info.owner, ioc_info.time),
603+
],
604+
cf_channel,
605+
)
606+
channels.append(cf_channel)
607+
_log.debug("Add orphaned channel %s with no IOC: %s", cf_channel, ioc_info)
608+
"""Also orphan any alias"""
609+
if cf_config.alias_enabled:
610+
if cf_channel.name in recordInfoByName:
611+
for alias_name in recordInfoByName[cf_channel.name].aliases:
612+
alias_channel = CFChannel(alias_name, "", [])
613+
alias_channel.properties = __merge_property_lists(
614+
[
615+
CFProperty.inactive(ioc_info.owner),
616+
CFProperty.time(ioc_info.owner, ioc_info.time),
617+
],
618+
alias_channel,
619+
)
620+
channels.append(alias_channel)
621+
_log.debug("Add orphaned alias %s with no IOC: %s", alias_channel, ioc_info)
622+
623+
592624
def __updateCF__(processor: CFProcessor, recordInfoByName: Dict[str, RecordInfo], records_to_delete, ioc_info: IocInfo):
593625
_log.info("CF Update IOC: %s", ioc_info)
594626
_log.debug("CF Update IOC: %s recordInfoByName %s", ioc_info, recordInfoByName)
@@ -638,29 +670,7 @@ def __updateCF__(processor: CFProcessor, recordInfoByName: Dict[str, RecordInfo]
638670
)
639671
else:
640672
"""Orphan the channel : mark as inactive, keep the old hostName and iocName"""
641-
cf_channel.properties = __merge_property_lists(
642-
[
643-
CFProperty.inactive(ioc_info.owner),
644-
CFProperty.time(ioc_info.owner, ioc_info.time),
645-
],
646-
cf_channel,
647-
)
648-
channels.append(cf_channel)
649-
_log.debug("Add orphaned channel %s with no IOC: %s", cf_channel, ioc_info)
650-
"""Also orphan any alias"""
651-
if cf_config.alias_enabled:
652-
if cf_channel.name in recordInfoByName:
653-
for alias_name in recordInfoByName[cf_channel.name].aliases:
654-
alias_channel = CFChannel(alias_name, "", [])
655-
alias_channel.properties = __merge_property_lists(
656-
[
657-
CFProperty.inactive(ioc_info.owner),
658-
CFProperty.time(ioc_info.owner, ioc_info.time),
659-
],
660-
alias_channel,
661-
)
662-
channels.append(alias_channel)
663-
_log.debug("Add orphaned alias %s with no IOC: %s", alias_channel, ioc_info)
673+
orphan_channel(cf_channel, ioc_info, channels, cf_config, recordInfoByName)
664674
else:
665675
if cf_channel.name in new_channels: # case: channel in old and new
666676
"""

0 commit comments

Comments
 (0)