Skip to content

Commit 6efecaa

Browse files
committed
pull out update_existing_channel_diff_iocid
1 parent ec65e3f commit 6efecaa

File tree

1 file changed

+48
-28
lines changed

1 file changed

+48
-28
lines changed

server/recceiver/cfstore.py

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,45 @@ def handle_old_channels(
773773
return cf_channel
774774

775775

776+
def update_existing_channel_diff_iocid(
777+
existingChannels: Dict[str, CFChannel],
778+
channel_name: str,
779+
newProps: List[CFProperty],
780+
processor: CFProcessor,
781+
channels: List[CFChannel],
782+
cf_config: CFConfig,
783+
recordInfoByName: Dict[str, RecordInfo],
784+
ioc_info: IocInfo,
785+
iocid: str,
786+
):
787+
existingChannel = existingChannels[channel_name]
788+
existingChannel.properties = __merge_property_lists(
789+
newProps,
790+
existingChannel,
791+
processor.managed_properties,
792+
)
793+
channels.append(existingChannel)
794+
_log.debug("Add existing channel with different IOC: %s", existingChannel)
795+
"""in case, alias exists, update their properties too"""
796+
if cf_config.alias_enabled:
797+
if channel_name in recordInfoByName:
798+
alProps = [CFProperty.alias(ioc_info.owner, channel_name)]
799+
for p in newProps:
800+
alProps.append(p)
801+
for alias_name in recordInfoByName[channel_name].aliases:
802+
if alias_name in existingChannels:
803+
ach = existingChannels[alias_name]
804+
ach.properties = __merge_property_lists(
805+
alProps,
806+
ach,
807+
processor.managed_properties,
808+
)
809+
channels.append(ach)
810+
else:
811+
channels.append(CFChannel(alias_name, ioc_info.owner, alProps))
812+
_log.debug("Add existing alias %s of %s with different IOC from %s", alias_name, channel_name, iocid)
813+
814+
776815
def __updateCF__(processor: CFProcessor, recordInfoByName: Dict[str, RecordInfo], records_to_delete, ioc_info: IocInfo):
777816
_log.info("CF Update IOC: %s", ioc_info)
778817
_log.debug("CF Update IOC: %s recordInfoByName %s", ioc_info, recordInfoByName)
@@ -841,36 +880,17 @@ def __updateCF__(processor: CFProcessor, recordInfoByName: Dict[str, RecordInfo]
841880

842881
if channel_name in existingChannels:
843882
_log.debug("update existing channel %s: exists but with a different iocid from %s", channel_name, iocid)
844-
845-
existingChannel = existingChannels[channel_name]
846-
existingChannel.properties = __merge_property_lists(
883+
update_existing_channel_diff_iocid(
884+
existingChannels,
885+
channel_name,
847886
newProps,
848-
existingChannel,
849-
processor.managed_properties,
887+
processor,
888+
channels,
889+
cf_config,
890+
recordInfoByName,
891+
ioc_info,
892+
iocid,
850893
)
851-
channels.append(existingChannel)
852-
_log.debug("Add existing channel with different IOC: %s", existingChannel)
853-
"""in case, alias exists, update their properties too"""
854-
if cf_config.alias_enabled:
855-
if channel_name in recordInfoByName:
856-
alProps = [CFProperty.alias(ioc_info.owner, channel_name)]
857-
for p in newProps:
858-
alProps.append(p)
859-
for alias_name in recordInfoByName[channel_name].aliases:
860-
if alias_name in existingChannels:
861-
ach = existingChannels[alias_name]
862-
ach.properties = __merge_property_lists(
863-
alProps,
864-
ach,
865-
processor.managed_properties,
866-
)
867-
channels.append(ach)
868-
else:
869-
channels.append(CFChannel(alias_name, ioc_info.owner, alProps))
870-
_log.debug(
871-
"Add existing alias %s of %s with different IOC from %s", alias_name, channel_name, iocid
872-
)
873-
874894
else:
875895
"""New channel"""
876896
channels.append(CFChannel(channel_name, ioc_info.owner, newProps))

0 commit comments

Comments
 (0)