From f1237740c178b94668d93272ba888e410f94c2ff Mon Sep 17 00:00:00 2001 From: Shlomi Bitton Date: Wed, 1 Jul 2020 18:35:59 +0300 Subject: [PATCH 1/2] Add support for QSFP-DD cables on 'show' command Signed-off-by: Shlomi Bitton --- scripts/sfpshow | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/sfpshow b/scripts/sfpshow index bf0b90408a..a4a5e78c02 100755 --- a/scripts/sfpshow +++ b/scripts/sfpshow @@ -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', @@ -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' From 9296de7d05a0e9721ebebd6c50436d9174e4e7b7 Mon Sep 17 00:00:00 2001 From: Shlomi Bitton Date: Tue, 14 Jul 2020 16:30:56 +0300 Subject: [PATCH 2/2] Fix unit sfp_test with new field added along for QSFP-DD cable types (Application Advertisement) --- sonic-utilities-tests/mock_tables/state_db.json | 3 ++- sonic-utilities-tests/sfp_test.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sonic-utilities-tests/mock_tables/state_db.json b/sonic-utilities-tests/mock_tables/state_db.json index b44b60df9f..ccc9f83eb8 100644 --- a/sonic-utilities-tests/mock_tables/state_db.json +++ b/sonic-utilities-tests/mock_tables/state_db.json @@ -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", diff --git a/sonic-utilities-tests/sfp_test.py b/sonic-utilities-tests/sfp_test.py index 695258d60b..c9f5784f3f 100644 --- a/sonic-utilities-tests/sfp_test.py +++ b/sonic-utilities-tests/sfp_test.py @@ -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) @@ -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 @@ -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