Skip to content

Commit

Permalink
[conn_graph] Fix the fanout connection parsing error (#2780)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
neethajohn authored Jan 8, 2021
1 parent 6fe5130 commit 315987c
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions ansible/library/conn_graph_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,25 +362,28 @@ def main():
if host_vlan:
device_vlan_range.append(host_vlan["VlanRange"])
device_vlan_list.append(host_vlan["VlanList"])
port_vlans = lab_graph.get_host_port_vlans(hostname)
device_vlan_map_list[hostname] = {}

port_name_list_sorted = get_port_name_list(dev['HwSku'])
print_debug_msg(debug_fname,"For %s with hwsku %s, port_name_list is %s" % (hostname, dev['HwSku'], port_name_list_sorted))
for a_host_vlan in host_vlan["VlanList"]:
# Get the corresponding port for this vlan from the port vlan list for this hostname
found_port_for_vlan = False
for a_port in port_vlans:
if a_host_vlan in port_vlans[a_port]['vlanlist']:
if a_port in port_name_list_sorted:
port_index = port_name_list_sorted.index(a_port)
device_vlan_map_list[hostname][port_index] = a_host_vlan
found_port_for_vlan = True
break
else:
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))
if not found_port_for_vlan:
module.fail_json(msg="Did not find corresponding link for vlan %d in %s for host %s" % (a_host_vlan, port_vlans, hostname))
if dev["Type"].lower() != "devsonic":
device_vlan_map_list[hostname] = host_vlan["VlanList"]
else:
port_vlans = lab_graph.get_host_port_vlans(hostname)
device_vlan_map_list[hostname] = {}

port_name_list_sorted = get_port_name_list(dev['HwSku'])
print_debug_msg(debug_fname,"For %s with hwsku %s, port_name_list is %s" % (hostname, dev['HwSku'], port_name_list_sorted))
for a_host_vlan in host_vlan["VlanList"]:
# Get the corresponding port for this vlan from the port vlan list for this hostname
found_port_for_vlan = False
for a_port in port_vlans:
if a_host_vlan in port_vlans[a_port]['vlanlist']:
if a_port in port_name_list_sorted:
port_index = port_name_list_sorted.index(a_port)
device_vlan_map_list[hostname][port_index] = a_host_vlan
found_port_for_vlan = True
break
else:
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))
if not found_port_for_vlan:
module.fail_json(msg="Did not find corresponding link for vlan %d in %s for host %s" % (a_host_vlan, port_vlans, hostname))
device_port_vlans.append(lab_graph.get_host_port_vlans(hostname))
results = {k: v for k, v in locals().items()
if (k.startswith("device_") and v)}
Expand Down

0 comments on commit 315987c

Please sign in to comment.