From 790172446ecb036a3783485629f0f2d597d556ff Mon Sep 17 00:00:00 2001 From: kuanyu_chen Date: Mon, 13 Jul 2020 17:03:14 +0800 Subject: [PATCH 1/2] [sfpshow] Add dom_capability to transceiver eeprom * Basic dom capability info can be retrieved by "show interfaces transceiver eeprom" --- scripts/sfpshow | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/sfpshow b/scripts/sfpshow index a4a5e78c02..966cfbd74e 100755 --- a/scripts/sfpshow +++ b/scripts/sfpshow @@ -39,7 +39,8 @@ qsfp_data_map = {'model': 'Vendor PN', 'specification_compliance': 'Specification compliance', 'encoding': 'Encoding', 'connector': 'Connector', - 'application_advertisement': 'Application Advertisement' + 'application_advertisement': 'Application Advertisement', + 'dom_capability': 'DOM Capability' } sfp_dom_channel_monitor_map = {'rx1power': 'RXPower', @@ -270,6 +271,12 @@ class SFPShow(object): 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' + elif key1 == 'dom_capability': + dom_capability_dict = eval(sfp_info_dict['dom_capability']) + sorted_dom_capability_key_table = natsorted(dom_capability_dict) + out_put = out_put + ident + qsfp_data_map['dom_capability'] + ': ' + '\n' + for dom_capability_key in sorted_dom_capability_key_table: + out_put = out_put + ident + ident + dom_capability_key + ': ' + dom_capability_dict[dom_capability_key] + '\n' else: out_put = out_put + ident + qsfp_data_map[key1] + ': ' + sfp_info_dict[key1] + '\n' @@ -281,7 +288,7 @@ class SFPShow(object): sfp_info_dict = state_db.get_all(state_db.STATE_DB, 'TRANSCEIVER_INFO|{}'.format(interface_name)) out_put = interface_name + ': ' + 'SFP EEPROM detected' + '\n' sfp_info_output = self.convert_sfp_info_to_output_string(sfp_info_dict) - out_put = out_put + sfp_info_output + out_put = out_put + sfp_info_output.decode('utf-8', errors='ignore') if dump_dom: sfp_type = sfp_info_dict['type'] From e392728edc482f071c7042328e8da86b0b83edb9 Mon Sep 17 00:00:00 2001 From: kuanyu_chen Date: Mon, 27 Jul 2020 16:28:15 +0800 Subject: [PATCH 2/2] [sfp_test.py] Fix missing entry in the mock_tables * Add dom_capability entry into state_db.json * Modify expected output of the sfp_test.py --- sonic-utilities-tests/mock_tables/state_db.json | 1 + sonic-utilities-tests/sfp_test.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/sonic-utilities-tests/mock_tables/state_db.json b/sonic-utilities-tests/mock_tables/state_db.json index ccc9f83eb8..75eb2e045a 100644 --- a/sonic-utilities-tests/mock_tables/state_db.json +++ b/sonic-utilities-tests/mock_tables/state_db.json @@ -10,6 +10,7 @@ "connector": "No separable connector", "encoding": "64B66B", "ext_identifier": "Power Class 3(2.5W max), CDR present in Rx Tx", + "dom_capability": "{'sff8472_dom_support': 'yes'}", "ext_rateselect_compliance": "QSFP+ Rate Select Version 1", "cable_type": "Length Cable Assembly(m)", "cable_length": "3", diff --git a/sonic-utilities-tests/sfp_test.py b/sonic-utilities-tests/sfp_test.py index c9f5784f3f..fa606e1a00 100644 --- a/sonic-utilities-tests/sfp_test.py +++ b/sonic-utilities-tests/sfp_test.py @@ -39,6 +39,8 @@ def test_sfp_eeprom_with_dom(self): expected = """Ethernet0: SFP EEPROM detected Application Advertisement: N/A Connector: No separable connector + DOM Capability: + sff8472_dom_support: yes Encoding: 64B66B Extended Identifier: Power Class 3(2.5W max), CDR present in Rx Tx Extended RateSelect Compliance: QSFP+ Rate Select Version 1 @@ -93,6 +95,8 @@ def test_sfp_eeprom(self): expected = """Ethernet0: SFP EEPROM detected Application Advertisement: N/A Connector: No separable connector + DOM Capability: + sff8472_dom_support: yes Encoding: 64B66B Extended Identifier: Power Class 3(2.5W max), CDR present in Rx Tx Extended RateSelect Compliance: QSFP+ Rate Select Version 1