From a680cc116255f7506759f5f71088db589898be8d Mon Sep 17 00:00:00 2001 From: visnu_r Date: Tue, 30 Jul 2019 11:46:48 +0000 Subject: [PATCH 1/2] [show] adding neighbour details to 'show interface status' command --- scripts/intfutil | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/scripts/intfutil b/scripts/intfutil index f8509db93f..ebb4d87052 100755 --- a/scripts/intfutil +++ b/scripts/intfutil @@ -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): @@ -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: @@ -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) From 186711e66f1e7e1b62fa68219b30d2bb2ec8fa0b Mon Sep 17 00:00:00 2001 From: visnu_r Date: Mon, 5 Aug 2019 04:39:09 +0000 Subject: [PATCH 2/2] adding command output --- doc/Command-Reference.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 7fbb99dceb..893ce9dedb 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -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] @@ -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 +------------- --------------- ------- ----- -------------- ------------- ------ ------- ------ ---------- ----------- ----------- + 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 ```