Skip to content

Commit 315987c

Browse files
authored
[conn_graph] Fix the fanout connection parsing error (#2780)
Description of PR Fanout graph parsing was broken due to #2517 Following errors were seen while running pfcwd tests E RunAnsibleModuleFail: run module conn_graph_facts failed, Ansible Results => E { E "changed": false, E "failed": true, E "invocation": { E "module_args": { E "anchor": null, E "filename": "/var/nejo/Networking-acs-sonic-mgmt/tests/common/fixtures/../../../ansible/files/starlab_connection_graph.xml", E "filepath": null, E "host": "str-7260cx3-acs-fan-05", E "hosts": null E } E }, E "msg": "Did not find port for Ethernet23/1 in the ports based on hwsku 'Arista-7260CX3' for host str-7260cx3-acs-fan-05" E } How did you do it? Parsing logic added in #2517 was for SONIC duts. Retained the old logic when dev type is FanoutLeaf How did you verify/test it? Ran one of the pfcwd tests and it passed
1 parent 6fe5130 commit 315987c

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

ansible/library/conn_graph_facts.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -362,25 +362,28 @@ def main():
362362
if host_vlan:
363363
device_vlan_range.append(host_vlan["VlanRange"])
364364
device_vlan_list.append(host_vlan["VlanList"])
365-
port_vlans = lab_graph.get_host_port_vlans(hostname)
366-
device_vlan_map_list[hostname] = {}
367-
368-
port_name_list_sorted = get_port_name_list(dev['HwSku'])
369-
print_debug_msg(debug_fname,"For %s with hwsku %s, port_name_list is %s" % (hostname, dev['HwSku'], port_name_list_sorted))
370-
for a_host_vlan in host_vlan["VlanList"]:
371-
# Get the corresponding port for this vlan from the port vlan list for this hostname
372-
found_port_for_vlan = False
373-
for a_port in port_vlans:
374-
if a_host_vlan in port_vlans[a_port]['vlanlist']:
375-
if a_port in port_name_list_sorted:
376-
port_index = port_name_list_sorted.index(a_port)
377-
device_vlan_map_list[hostname][port_index] = a_host_vlan
378-
found_port_for_vlan = True
379-
break
380-
else:
381-
module.fail_json(msg="Did not find port for %s in the ports based on hwsku '%s' for host %s" % (a_port, dev['HwSku'], hostname))
382-
if not found_port_for_vlan:
383-
module.fail_json(msg="Did not find corresponding link for vlan %d in %s for host %s" % (a_host_vlan, port_vlans, hostname))
365+
if dev["Type"].lower() != "devsonic":
366+
device_vlan_map_list[hostname] = host_vlan["VlanList"]
367+
else:
368+
port_vlans = lab_graph.get_host_port_vlans(hostname)
369+
device_vlan_map_list[hostname] = {}
370+
371+
port_name_list_sorted = get_port_name_list(dev['HwSku'])
372+
print_debug_msg(debug_fname,"For %s with hwsku %s, port_name_list is %s" % (hostname, dev['HwSku'], port_name_list_sorted))
373+
for a_host_vlan in host_vlan["VlanList"]:
374+
# Get the corresponding port for this vlan from the port vlan list for this hostname
375+
found_port_for_vlan = False
376+
for a_port in port_vlans:
377+
if a_host_vlan in port_vlans[a_port]['vlanlist']:
378+
if a_port in port_name_list_sorted:
379+
port_index = port_name_list_sorted.index(a_port)
380+
device_vlan_map_list[hostname][port_index] = a_host_vlan
381+
found_port_for_vlan = True
382+
break
383+
else:
384+
module.fail_json(msg="Did not find port for %s in the ports based on hwsku '%s' for host %s" % (a_port, dev['HwSku'], hostname))
385+
if not found_port_for_vlan:
386+
module.fail_json(msg="Did not find corresponding link for vlan %d in %s for host %s" % (a_host_vlan, port_vlans, hostname))
384387
device_port_vlans.append(lab_graph.get_host_port_vlans(hostname))
385388
results = {k: v for k, v in locals().items()
386389
if (k.startswith("device_") and v)}

0 commit comments

Comments
 (0)