1212to take care of that made changes in the testcase
1313'''
1414
15- def get_lag_facts (dut , lag_facts , switch_arptable , mg_facts , ignore_lags , key = 'src' ):
15+ def get_lag_facts (dut , lag_facts , switch_arptable , mg_facts , ignore_lags , enum_frontend_asic_index , key = 'src' ):
1616 if not mg_facts ['minigraph_portchannels' ]:
1717 pytest .fail ("minigraph_portchannels is not defined" )
1818
@@ -21,6 +21,9 @@ def get_lag_facts(dut, lag_facts, switch_arptable, mg_facts, ignore_lags, key='s
2121 up_lag = None
2222 for a_lag_name , a_lag_data in lag_facts ['lags' ].items ():
2323 if a_lag_data ['po_intf_stat' ] == 'Up' and a_lag_name not in ignore_lags :
24+ if enum_frontend_asic_index is not None and \
25+ int (lag_facts ['lags' ][a_lag_name ]['po_namespace_id' ]) != enum_frontend_asic_index :
26+ continue
2427 # We found a portchannel that is up.
2528 up_lag = a_lag_name
2629 selected_lag_facts [key + '_port_ids' ] = [mg_facts ['minigraph_ptf_indices' ][intf ] for intf in a_lag_data ['po_config' ]['ports' ]]
@@ -68,36 +71,40 @@ def get_port_facts(dut, mg_facts, port_status, switch_arptable, ignore_intfs, ke
6871 return up_port , selected_port_facts
6972
7073@pytest .fixture (scope = 'function' )
71- def gather_facts (tbinfo , duthosts , enum_rand_one_per_hwsku_frontend_hostname ):
74+ def gather_facts (tbinfo , duthosts , enum_rand_one_per_hwsku_frontend_hostname , enum_frontend_asic_index ):
7275 duthost = duthosts [enum_rand_one_per_hwsku_frontend_hostname ]
76+ asichost = duthost .asic_instance (enum_frontend_asic_index )
7377 facts = {}
7478
7579 logger .info ("Gathering facts on DUT ..." )
76- mg_facts = duthost .get_extended_minigraph_facts (tbinfo )
80+ mg_facts = asichost .get_extended_minigraph_facts (tbinfo )
7781
7882 # Use the arp table to get the mac address of the host (VM's) instead of lldp_facts as that is was is used
7983 # by the DUT to forward traffic - regardless of lag or port.
80- switch_arptable = duthost .switch_arptable ()['ansible_facts' ]
84+ switch_arptable = asichost .switch_arptable ()['ansible_facts' ]
8185 used_intfs = set ()
8286 src = None # Name of lag or interface that is is up
8387 dst = None # Name of lag or interface that is is up
8488
8589 # if minigraph_portchannel_interfaces is not empty - topology with lag - check if we have 2 lags that are 'Up'
8690 if mg_facts ['minigraph_portchannel_interfaces' ]:
8791 # Get lag facts from the DUT to check which ag is up
88- lag_facts = duthost .lag_facts (host = duthost .hostname )['ansible_facts' ]['lag_facts' ]
89- src , src_lag_facts = get_lag_facts (duthost , lag_facts , switch_arptable , mg_facts , used_intfs , key = 'src' )
92+ lag_facts = duthost .lag_facts (host = duthost .hostname )[
93+ 'ansible_facts' ]['lag_facts' ]
94+ src , src_lag_facts = get_lag_facts (
95+ duthost , lag_facts , switch_arptable , mg_facts , used_intfs , enum_frontend_asic_index , key = 'src' )
9096 used_intfs .add (src )
9197 if src :
9298 facts .update (src_lag_facts )
9399 # We found a src lag, let see if we can find a dst lag
94- dst , dst_lag_facts = get_lag_facts (duthost , lag_facts , switch_arptable , mg_facts , used_intfs , key = 'dst' )
100+ dst , dst_lag_facts = get_lag_facts (
101+ duthost , lag_facts , switch_arptable , mg_facts , used_intfs , enum_frontend_asic_index , key = 'dst' )
95102 used_intfs .add (dst )
96103 facts .update (dst_lag_facts )
97104
98105 if src is None or dst is None :
99106 # We didn't find 2 lags, lets check up interfaces
100- port_status = duthost .show_interface (command = 'status' )['ansible_facts' ]
107+ port_status = asichost .show_interface (command = 'status' )['ansible_facts' ]
101108 if src is None :
102109 src , src_port_facts = get_port_facts (duthost , mg_facts , port_status , switch_arptable , used_intfs , key = 'src' )
103110 used_intfs .add (src )
0 commit comments