Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/sonic-py-common/sonic_py_common/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
INTERNAL_PORT = 'Int'
INBAND_PORT = 'Inb'
RECIRC_PORT ='Rec'
PORT_CHANNEL_CFG_DB_TABLE = 'PORTCHANNEL'
PORT_CHANNEL_MEMBER_CFG_DB_TABLE = 'PORTCHANNEL_MEMBER'
PORT_CFG_DB_TABLE = 'PORT'
BGP_NEIGH_CFG_DB_TABLE = 'BGP_NEIGHBOR'
BGP_INTERNAL_NEIGH_CFG_DB_TABLE = 'BGP_INTERNAL_NEIGHBOR'
Expand Down Expand Up @@ -354,13 +354,12 @@ def is_port_channel_internal(port_channel, namespace=None):

for ns in ns_list:
config_db = connect_config_db_for_ns(ns)
port_channels = config_db.get_entry(PORT_CHANNEL_CFG_DB_TABLE, port_channel)
port_channel_members = config_db.get_keys(PORT_CHANNEL_MEMBER_CFG_DB_TABLE)

if port_channels:
if 'members' in port_channels:
members = port_channels['members']
if is_port_internal(members[0], namespace):
return True
for port_channel_member in port_channel_members:
if port_channel_member[0] != port_channel:
continue
return is_port_internal(port_channel_member[1], namespace)

return False

Expand All @@ -380,14 +379,14 @@ def get_back_end_interface_set(namespace=None):
ns_list = get_namespace_list(namespace)
for ns in ns_list:
config_db = connect_config_db_for_ns(ns)
port_channels = config_db.get_table(PORT_CHANNEL_CFG_DB_TABLE)
port_channel_members = config_db.get_keys(PORT_CHANNEL_MEMBER_CFG_DB_TABLE)
# a back-end LAG must be configured with all of its member from back-end interfaces.
# mixing back-end and front-end interfaces is miss configuration and not allowed.
# To determine if a LAG is back-end LAG, just need to check its first member is back-end or not
# is sufficient. Note that a user defined LAG may have empty members so the list expansion logic
# need to ensure there are members before inspecting member[0].
bk_end_intf_list.extend([port_channel for port_channel, lag_info in port_channels.items()\
if 'members' in lag_info and lag_info['members'][0] in bk_end_intf_list])
bk_end_intf_list.extend(set([port_channel_member[0] for port_channel_member in port_channel_members\
if port_channel_member[1] in bk_end_intf_list]))
a = set()
a.update(bk_end_intf_list)
return a
Expand Down