Skip to content

Commit ed96ef8

Browse files
authored
Updated add cluster ACL test for chassis-packet (#22144)
* Modify the test case for chassis-packet Signed-off-by: Anand Mehra (anamehra) <anamehra@cisco.com> * Updated functions Fixed indentations Signed-off-by: Anand Mehra (anamehra) <anamehra@cisco.com> Signed-off-by: Anand Mehra (anamehra) anamehra@cisco.com Description of PR Added support for chassis-packet T2 system. Chassis packet needs to handle the backend configuration while removing the config and adding new config for cluster add scenario. Added new functions to remove config and add patch for chassis-packet without modifying original ones for VOQ to keep the flow easy to follow and maintain. Summary: Fixes # (issue) Type of change Bug fix Testbed and Framework(new/improvement) New Test case Skipped for non-supported platforms Test case improvement Approach What is the motivation for this PR? The test cases needed improvement for chassis-packet T2 chassis How did you do it? Added chassis-packet specific handling via new functions without changing the original VOQ chassis code to keep them separate and easy to maintain without cross dependency on testing. How did you verify/test it? Run test on a chassis-packet setup Any platform specific information? chassis-packet Supported testbed topology if it's a new test case? T2 Signed-off-by: Anand Mehra (anamehra) <anamehra@cisco.com>
1 parent 3103a1e commit ed96ef8

File tree

2 files changed

+812
-25
lines changed

2 files changed

+812
-25
lines changed

tests/generic_config_updater/add_cluster/helpers.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def clear_static_route(tbinfo, duthost, ip, nhipv4='10.10.246.254'):
5858
ip_address = re.search(r'via (\d+\.\d+\.\d+\.\d+)', output)
5959
if ip_address:
6060
ip_address = ip_address.group(1)
61+
# Check if this is a direct BGP neighbor (not a recursive route)
62+
if ip_address not in config_facts_localhost['BGP_NEIGHBOR']:
63+
logger.warning(f"Next-hop {ip_address} is not a direct BGP neighbor (may be recursive route). "
64+
f"Skipping route withdrawal for {ip}")
65+
continue
6166
bgp_neigh_name = config_facts_localhost['BGP_NEIGHBOR'][ip_address]['name']
6267
exabgp_port = get_exabgp_port_for_neighbor(tbinfo, bgp_neigh_name)
6368
remove_static_route(tbinfo, ip_address, exabgp_port, ip=ip, nhipv4=nhipv4)
@@ -246,18 +251,55 @@ def get_cfg_info_from_dut(duthost, path, enum_rand_one_asic_namespace):
246251
return dict_info
247252

248253

249-
def get_active_interfaces(config_facts):
254+
def get_active_interfaces(config_facts, duthost=None):
250255
"""
251256
Finds all the active interfaces based on running configuration.
257+
For chassis-packet switches: Skips BP (backplane) interfaces and PortChannels with BP member interfaces.
258+
For other switches: Returns all active interfaces without BP filtering.
259+
260+
Args:
261+
config_facts: Configuration facts dictionary
262+
duthost: DUT host object (optional, used to check switch_type)
252263
"""
253264
active_interfaces = []
265+
266+
# Check if this is a chassis-packet switch
267+
is_chassis_packet = (duthost and
268+
duthost.facts.get('switch_type') == 'chassis-packet')
269+
270+
# Add interfaces from INTERFACE table, skip BP interfaces only for chassis-packet
254271
for key, _value in config_facts.get("INTERFACE", {}).items():
255272
if re.compile(r'^Ethernet\d{1,3}$').match(key):
273+
# Skip BP interfaces only for chassis-packet switches
274+
if is_chassis_packet and key.startswith("Ethernet-BP"):
275+
continue
256276
active_interfaces.append(key)
277+
278+
# Identify PortChannels with BP members (internal PortChannels) - only for chassis-packet
279+
internal_portchannels = set()
280+
if is_chassis_packet:
281+
for portchannel, members in config_facts.get("PORTCHANNEL_MEMBER", {}).items():
282+
for member_port in members.keys():
283+
if member_port.startswith("Ethernet-BP"):
284+
internal_portchannels.add(portchannel)
285+
break
286+
287+
# Add interfaces from PORTCHANNEL_MEMBER, skip BP interfaces and members of internal PortChannels
257288
for portchannel in config_facts.get("PORTCHANNEL_MEMBER", {}):
289+
# Skip internal PortChannels (those with BP members) - only for chassis-packet
290+
if portchannel in internal_portchannels:
291+
logger.info(f"Skipping internal PortChannel {portchannel} (has BP members)")
292+
continue
293+
258294
for key, _value in config_facts.get("PORTCHANNEL_MEMBER", {}).get(portchannel, {}).items():
295+
# Skip BP interfaces only for chassis-packet switches
296+
if is_chassis_packet and key.startswith("Ethernet-BP"):
297+
continue
259298
active_interfaces.append(key)
260-
logger.info("Active interfaces for this namespace:{}".format(active_interfaces))
299+
300+
logger.info("Active interfaces for this namespace: {}".format(active_interfaces))
301+
if internal_portchannels:
302+
logger.info("Skipped internal PortChannels (chassis-packet only): {}".format(internal_portchannels))
261303
return active_interfaces
262304

263305

0 commit comments

Comments
 (0)