Skip to content

Commit d6244dd

Browse files
committed
pull out create_new_channel
1 parent 6efecaa commit d6244dd

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

server/recceiver/cfstore.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,26 @@ def update_existing_channel_diff_iocid(
812812
_log.debug("Add existing alias %s of %s with different IOC from %s", alias_name, channel_name, iocid)
813813

814814

815+
def create_new_channel(
816+
channels: List[CFChannel],
817+
channel_name: str,
818+
ioc_info: IocInfo,
819+
newProps: List[CFProperty],
820+
cf_config: CFConfig,
821+
recordInfoByName: Dict[str, RecordInfo],
822+
):
823+
channels.append(CFChannel(channel_name, ioc_info.owner, newProps))
824+
_log.debug("Add new channel: %s", channel_name)
825+
if cf_config.alias_enabled:
826+
if channel_name in recordInfoByName:
827+
alProps = [CFProperty.alias(ioc_info.owner, channel_name)]
828+
for p in newProps:
829+
alProps.append(p)
830+
for alias in recordInfoByName[channel_name].aliases:
831+
channels.append(CFChannel(alias, ioc_info.owner, alProps))
832+
_log.debug("Add new alias: %s from %s", alias, channel_name)
833+
834+
815835
def __updateCF__(processor: CFProcessor, recordInfoByName: Dict[str, RecordInfo], records_to_delete, ioc_info: IocInfo):
816836
_log.info("CF Update IOC: %s", ioc_info)
817837
_log.debug("CF Update IOC: %s recordInfoByName %s", ioc_info, recordInfoByName)
@@ -893,16 +913,7 @@ def __updateCF__(processor: CFProcessor, recordInfoByName: Dict[str, RecordInfo]
893913
)
894914
else:
895915
"""New channel"""
896-
channels.append(CFChannel(channel_name, ioc_info.owner, newProps))
897-
_log.debug("Add new channel: %s", channel_name)
898-
if cf_config.alias_enabled:
899-
if channel_name in recordInfoByName:
900-
alProps = [CFProperty.alias(ioc_info.owner, channel_name)]
901-
for p in newProps:
902-
alProps.append(p)
903-
for alias in recordInfoByName[channel_name].aliases:
904-
channels.append(CFChannel(alias, ioc_info.owner, alProps))
905-
_log.debug("Add new alias: %s from %s", alias, channel_name)
916+
create_new_channel(channels, channel_name, ioc_info, newProps, cf_config, recordInfoByName)
906917
_log.info("Total channels to update: %s for ioc: %s", len(channels), ioc_info)
907918

908919
if len(channels) != 0:

0 commit comments

Comments
 (0)