Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[show] Enhance show interface status command output #597

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ This command displays information regarding port-channel interfaces

**show interface status**

This command displays some more fields such as Lanes, Speed, MTU, Type, Asymmetric PFC status and also the operational and administrative status of the interfaces
This command displays some more fields such as Lanes, Speed, MTU, Type, Asymmetric PFC status, Neighbor device, Neighbor port and also the operational and administrative status of the interfaces

- Usage:
show interfaces status [INTERFACENAME]
Expand All @@ -1742,11 +1742,17 @@ This command displays some more fields such as Lanes, Speed, MTU, Type, Asymmetr
show interface status of all interfaces

admin@sonic:~$ show interfaces status
Interface Lanes Speed MTU Alias Oper Admin Type Asym PFC
----------- --------------- ------- ----- --------------- ------ ------- ------ ----------
Ethernet0 49,50,51,52 100G 9100 hundredGigE1/1 down up N/A off
Ethernet4 53,54,55,56 100G 9100 hundredGigE1/2 down up N/A off
Ethernet8 57,58,59,60 100G 9100 hundredGigE1/3 down down N/A off
Interface Lanes Speed MTU Alias Vlan Oper Admin Type Asym PFC Neighbour Port
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This output is not displaying properly in the rendered Markdown. Please fix.

------------- --------------- ------- ----- -------------- ------------- ------ ------- ------ ---------- ----------- -----------
Ethernet100 125,126,127,128 40G 9100 fortyGigE0/100 routed down down QSFP+ off N/A N/A
Ethernet104 85,86,87,88 40G 9100 fortyGigE0/104 routed down down QSFP+ off N/A N/A
Ethernet108 81,82,83,84 40G 9100 fortyGigE0/108 routed down down QSFP+ off N/A N/A
Ethernet112 89,90,91,92 40G 9100 fortyGigE0/112 PortChannel01 up up QSFP+ off Device1 Ethernet1/1
Ethernet116 93,94,95,96 40G 9100 fortyGigE0/116 PortChannel02 down down QSFP+ off Device2 Ethernet1/1
Ethernet120 97,98,99,100 40G 9100 fortyGigE0/120 PortChannel03 down down QSFP+ off Device3 Ethernet1/1
Ethernet124 101,102,103,104 40G 9100 fortyGigE0/124 PortChannel04 up up QSFP+ off Device4 Ethernet1/1
PortChannel01 N/A 40G 9100 N/A routed down up N/A N/A
PortChannel02 N/A 40G 9100 N/A routed down up N/A N/A
<contiues to display all the interfaces>

```
Expand Down
36 changes: 34 additions & 2 deletions scripts/intfutil
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,38 @@ def appl_db_portchannel_status_get(appl_db, config_db, po_name, status_type, por
return "N/A"
return status

def neighbour_port(config_db):
"""
Get neighbour device and connected port info from REDIS ConfigDB
"""
device_neighbour_dict = config_db.get_table('DEVICE_NEIGHBOR')
return device_neighbour_dict

def connected_device_detail(device_neighbour_dict, local_interface):
"""
Gets far end device of the given local interface
"""
far_end_device = 'N/A'
try:
far_end_device = device_neighbour_dict[local_interface]['name']
return far_end_device
except:
return far_end_device

def connected_interface_detail(device_neighbour_dict, local_interface):
"""
Gets far end device's interface of the given local interface
"""
far_end_port = 'N/A'
try:
far_end_port = device_neighbour_dict[local_interface]['port']
return far_end_port
except:
return far_end_port

# ========================== interface-status logic ==========================

header_stat = ['Interface', 'Lanes', 'Speed', 'MTU', 'Alias', 'Vlan', 'Oper', 'Admin', 'Type', 'Asym PFC']
header_stat = ['Interface', 'Lanes', 'Speed', 'MTU', 'Alias', 'Vlan', 'Oper', 'Admin', 'Type', 'Asym PFC', 'Neighbour', 'Port']

class IntfStatus(object):

Expand Down Expand Up @@ -298,7 +327,9 @@ class IntfStatus(object):
appl_db_port_status_get(self.appl_db, key, PORT_OPER_STATUS),
appl_db_port_status_get(self.appl_db, key, PORT_ADMIN_STATUS),
state_db_port_optics_get(self.state_db, key, PORT_OPTICS_TYPE),
appl_db_port_status_get(self.appl_db, key, PORT_PFC_ASYM_STATUS)))
appl_db_port_status_get(self.appl_db, key, PORT_PFC_ASYM_STATUS),
connected_device_detail(self.neighbour_connected, key),
connected_interface_detail(self.neighbour_connected, key)))
# Sorting and tabulating the result table.
for po, value in portchannel_speed_dict.iteritems():
if po:
Expand Down Expand Up @@ -344,6 +375,7 @@ class IntfStatus(object):
self.combined_int_to_vlan_po_dict = merge_dicts(self.int_to_vlan_dict, self.int_po_dict)
self.portchannel_speed_dict = po_speed_dict(self.po_int_dict, self.appl_db)
self.portchannel_keys = self.portchannel_speed_dict.keys()
self.neighbour_connected = neighbour_port(self.config_db)
if appl_db_keys is None:
return
self.display_intf_status(appl_db_keys, self.front_panel_ports_list, self.portchannel_speed_dict)
Expand Down