Skip to content

Commit

Permalink
[show] Add support for QSFP-DD cables on 'show' command (sonic-net#989)
Browse files Browse the repository at this point in the history
- What I did
Add support for QSFP-DD cables on 'sfpshow' script
Adapt sfp_test to new eeprom output.

- How I did it
Added a new label "application_advertisement" to print from DB.
Exclude "specification compliance" print from QSFP-DD cables.

Signed-off-by: Shlomi Bitton <shlomibi@mellanox.com>
  • Loading branch information
shlomibitton committed Jul 16, 2020
1 parent a23479e commit 527860d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
16 changes: 10 additions & 6 deletions scripts/sfpshow
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ qsfp_data_map = {'model': 'Vendor PN',
'nominal_bit_rate': 'Nominal Bit Rate(100Mbs)',
'specification_compliance': 'Specification compliance',
'encoding': 'Encoding',
'connector': 'Connector'
'connector': 'Connector',
'application_advertisement': 'Application Advertisement'
}

sfp_dom_channel_monitor_map = {'rx1power': 'RXPower',
Expand Down Expand Up @@ -261,11 +262,14 @@ class SFPShow(object):
elif key1 == 'cable_length':
pass
elif key1 == 'specification_compliance':
spefic_compliance_dict = eval(sfp_info_dict['specification_compliance'])
sorted_compliance_key_table = natsorted(spefic_compliance_dict)
out_put = out_put + ident + qsfp_data_map['specification_compliance'] + ': ' + '\n'
for compliance_key in sorted_compliance_key_table:
out_put = out_put + ident + ident + compliance_key + ': ' + spefic_compliance_dict[compliance_key] + '\n'
if sfp_info_dict['type'] == "QSFP-DD Double Density 8X Pluggable Transceiver":
out_put = out_put + ident + qsfp_data_map[key1] + ': ' + sfp_info_dict[key1] + '\n'
else:
out_put = out_put + ident + qsfp_data_map['specification_compliance'] + ': ' + '\n'
spefic_compliance_dict = eval(sfp_info_dict['specification_compliance'])
sorted_compliance_key_table = natsorted(spefic_compliance_dict)
for compliance_key in sorted_compliance_key_table:
out_put = out_put + ident + ident + compliance_key + ': ' + spefic_compliance_dict[compliance_key] + '\n'
else:
out_put = out_put + ident + qsfp_data_map[key1] + ': ' + sfp_info_dict[key1] + '\n'

Expand Down
3 changes: 2 additions & 1 deletion sonic-utilities-tests/mock_tables/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"cable_type": "Length Cable Assembly(m)",
"cable_length": "3",
"specification_compliance": "{'10/40G Ethernet Compliance Code': '40G Active Cable (XLPPI)'}",
"nominal_bit_rate": "255"
"nominal_bit_rate": "255",
"application_advertisement": "N/A"
},
"TRANSCEIVER_DOM_SENSOR|Ethernet0": {
"temperature": "30.9258",
Expand Down
3 changes: 3 additions & 0 deletions sonic-utilities-tests/sfp_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import os
from click.testing import CliRunner
import mock_tables.dbconnector

test_path = os.path.dirname(os.path.abspath(__file__))
modules_path = os.path.dirname(test_path)
Expand Down Expand Up @@ -36,6 +37,7 @@ def test_sfp_eeprom_with_dom(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["eeprom"], ["Ethernet0 -d"])
expected = """Ethernet0: SFP EEPROM detected
Application Advertisement: N/A
Connector: No separable connector
Encoding: 64B66B
Extended Identifier: Power Class 3(2.5W max), CDR present in Rx Tx
Expand Down Expand Up @@ -89,6 +91,7 @@ def test_sfp_eeprom(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["eeprom"], ["Ethernet0"])
expected = """Ethernet0: SFP EEPROM detected
Application Advertisement: N/A
Connector: No separable connector
Encoding: 64B66B
Extended Identifier: Power Class 3(2.5W max), CDR present in Rx Tx
Expand Down

0 comments on commit 527860d

Please sign in to comment.