Skip to content

Commit

Permalink
[show] Fix int status when portchannel is in the system (sonic-net#1376)
Browse files Browse the repository at this point in the history
* Fixed int stat with portchannel
* Replace N/A with None

Fixed crash of "show int status" command when there are portchannels in system.

Traceback (most recent call last):
  File "/usr/local/bin/intfutil", line 521, in <module>
    main()
  File "/usr/local/bin/intfutil", line 513, in main
    interface_stat.display_intf_status()
  File "/usr/local/bin/intfutil", line 354, in display_intf_status
    self.get_intf_status()
  File "/usr/local/lib/python3.7/dist-packages/utilities_common/multi_asic.py", line 137, in wrapped_run_on_all_asics
    func(self,  *args, **kwargs)
  File "/usr/local/bin/intfutil", line 435, in get_intf_status
    self.portchannel_speed_dict = po_speed_dict(self.po_int_dict, self.db)
  File "/usr/local/bin/intfutil", line 249, in po_speed_dict
    interface_speed = '{}G'.format(interface_speed[:-3])
TypeError: 'NoneType' object is not subscriptable

Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
  • Loading branch information
d-dashkov authored Feb 5, 2021
1 parent 9e0a4fa commit 5cff775
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/intfutil
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,12 @@ def po_speed_dict(po_int_dict, appl_db):
po_list.append(key)
if len(value) == 1:
interface_speed = appl_db.get(appl_db.APPL_DB, "PORT_TABLE:" + value[0], "speed")
interface_speed = '{}G'.format(interface_speed[:-3])
po_list.append(interface_speed)
if interface_speed is None:
# If no speed was returned, append None without format
po_list.append(None)
else:
interface_speed = '{}G'.format(interface_speed[:-3])
po_list.append(interface_speed)
elif len(value) > 1:
for intf in value:
temp_speed = appl_db.get(appl_db.APPL_DB, "PORT_TABLE:" + intf, "speed")
Expand All @@ -272,6 +276,8 @@ def appl_db_portchannel_status_get(appl_db, config_db, po_name, status_type, por
#print(full_table_id)
if status_type == "speed":
status = portchannel_speed_dict[po_name]
if status is None:
return "N/A"
return status
if status_type == "vlan":
if combined_int_to_vlan_po_dict and po_name in combined_int_to_vlan_po_dict.keys():
Expand Down

0 comments on commit 5cff775

Please sign in to comment.