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] Add support for QSFP-DD cables on 'show' command #989

Merged
merged 2 commits into from
Jul 16, 2020
Merged
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
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