@@ -216,10 +216,21 @@ def pick_ports(duthosts, all_cfg_facts, nbrhosts, tbinfo, port_type_a="ethernet"
216216 for a_dut in duthosts :
217217 minigraph_facts = a_dut .get_extended_minigraph_facts (tbinfo )
218218 minigraph_neighbors = minigraph_facts ['minigraph_neighbors' ]
219+ minigraph_portchannels = minigraph_facts ['minigraph_portchannels' ]
220+ portT1_neigh = defaultdict (list )
219221 for key , value in list (minigraph_neighbors .items ()):
220222 if 'T1' in value ['name' ] or 'LT2' in value ['name' ]:
221223 dutA = a_dut
222- break
224+ asic = value ['namespace' ][- 1 ]
225+ port = None
226+ for port_ch , val in list (minigraph_portchannels .items ()):
227+ if key in val ['members' ]:
228+ port = port_ch
229+ if not port :
230+ port = key
231+ if port not in portT1_neigh [asic ]:
232+ portT1_neigh [asic ].append (port )
233+
223234 if dutA :
224235 break
225236
@@ -229,10 +240,12 @@ def pick_ports(duthosts, all_cfg_facts, nbrhosts, tbinfo, port_type_a="ethernet"
229240
230241 for asic_index , asic_cfg in enumerate (all_cfg_facts [dutA .hostname ]):
231242 cfg_facts = asic_cfg ['ansible_facts' ]
232- cfgd_intfs = cfg_facts ['INTERFACE' ] if 'INTERFACE' in cfg_facts else {}
233- cfgd_pos = cfg_facts ['PORTCHANNEL_INTERFACE' ] if 'PORTCHANNEL_INTERFACE' in cfg_facts else {}
234- eths = [intf for intf in cfgd_intfs if "ethernet" in intf .lower () and cfgd_intfs [intf ] != {}]
235- pos = [intf for intf in cfgd_pos if "portchannel" in intf .lower ()]
243+ eths = []
244+ pos = []
245+ for asic , intf in portT1_neigh .items ():
246+ if int (asic ) == asic_index :
247+ eths = [n for n in intf if n .startswith ("Ethernet" )]
248+ pos = [n for n in intf if n .startswith ("PortChannel" )]
236249 if port_type_a == "ethernet" :
237250 if len (eths ) != 0 :
238251 intfs_to_test ['portA' ] = get_info_for_a_port (cfg_facts , eths , version , dutA , asic_index , nbrhosts )
@@ -278,23 +291,34 @@ def pick_ports(duthosts, all_cfg_facts, nbrhosts, tbinfo, port_type_a="ethernet"
278291 other_dut_to_use = None
279292 minigraph_facts = dut .get_extended_minigraph_facts (tbinfo )
280293 minigraph_neighbors = minigraph_facts ['minigraph_neighbors' ]
294+ minigraph_portchannels = minigraph_facts ['minigraph_portchannels' ]
295+ portT3_neigh = defaultdict (list )
281296 for key , value in list (minigraph_neighbors .items ()):
282297 if 'T3' in value ['name' ]:
283298 other_dut_to_use = dut
284- break
299+ asic = value ['namespace' ][- 1 ]
300+ port = None
301+ for port_ch , val in list (minigraph_portchannels .items ()):
302+ if key in val ['members' ]:
303+ port = port_ch
304+ if not port :
305+ port = key
306+ if port not in portT3_neigh [asic ]:
307+ portT3_neigh [asic ].append (port )
285308
286309 if other_dut_to_use is None :
287310 # This DUT is not connected to T3 VM's - ignore it
288311 continue
289312 cfg_facts = asic_cfg ['ansible_facts' ]
290- cfgd_intfs = cfg_facts ['INTERFACE' ] if 'INTERFACE' in cfg_facts else {}
291313 cfgd_dev_neighbor = cfg_facts ['DEVICE_NEIGHBOR' ] if 'DEVICE_NEIGHBOR' in cfg_facts else {}
292314 cfgd_dev_neigh_md = cfg_facts ['DEVICE_NEIGHBOR_METADATA' ] if 'DEVICE_NEIGHBOR_METADATA' in cfg_facts else {}
293- cfgd_pos = cfg_facts ['PORTCHANNEL_INTERFACE' ] if 'PORTCHANNEL_INTERFACE' in cfg_facts else {}
294315 cfgd_pc_members = cfg_facts ['PORTCHANNEL_MEMBER' ] if 'PORTCHANNEL_MEMBER' in cfg_facts else {}
295- eths_orig = [intf for intf in cfgd_intfs if "ethernet" in intf .lower () and cfgd_intfs [intf ] != {}]
296- pos = [intf for intf in cfgd_pos if "portchannel" in intf .lower ()]
297-
316+ eths_orig = []
317+ pos = []
318+ for asic , intf in portT3_neigh .items ():
319+ if int (asic ) == asic_index :
320+ eths_orig = [n for n in intf if n .startswith ("Ethernet" )]
321+ pos = [n for n in intf if n .startswith ("PortChannel" )]
298322 # Remove the interface from eths and pos if the BGP neighbor is of type RegionalHub
299323 dev_rh_neigh = [neigh for neigh in cfgd_dev_neigh_md
300324 if cfgd_dev_neigh_md [neigh ]["type" ] == "RegionalHub" ]
0 commit comments