Skip to content

Commit 5cff775

Browse files
authored
[show] Fix int status when portchannel is in the system (sonic-net#1376)
* 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>
1 parent 9e0a4fa commit 5cff775

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/intfutil

+8-2
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,12 @@ def po_speed_dict(po_int_dict, appl_db):
246246
po_list.append(key)
247247
if len(value) == 1:
248248
interface_speed = appl_db.get(appl_db.APPL_DB, "PORT_TABLE:" + value[0], "speed")
249-
interface_speed = '{}G'.format(interface_speed[:-3])
250-
po_list.append(interface_speed)
249+
if interface_speed is None:
250+
# If no speed was returned, append None without format
251+
po_list.append(None)
252+
else:
253+
interface_speed = '{}G'.format(interface_speed[:-3])
254+
po_list.append(interface_speed)
251255
elif len(value) > 1:
252256
for intf in value:
253257
temp_speed = appl_db.get(appl_db.APPL_DB, "PORT_TABLE:" + intf, "speed")
@@ -272,6 +276,8 @@ def appl_db_portchannel_status_get(appl_db, config_db, po_name, status_type, por
272276
#print(full_table_id)
273277
if status_type == "speed":
274278
status = portchannel_speed_dict[po_name]
279+
if status is None:
280+
return "N/A"
275281
return status
276282
if status_type == "vlan":
277283
if combined_int_to_vlan_po_dict and po_name in combined_int_to_vlan_po_dict.keys():

0 commit comments

Comments
 (0)