From 80171a38a04cd3ba74cbfea52097f7bdd0a8be3c Mon Sep 17 00:00:00 2001 From: Lior Avramov <73036155+liorghub@users.noreply.github.com> Date: Mon, 5 Apr 2021 09:17:00 +0300 Subject: [PATCH] [SNMP] Update description of entPhysicalDescr mib in case interface is not configured. (#205) The ideas of this MIB is to reflect the physical entities and should not be affected by the config_db.json interface configuration. In the case where the interface does not exist (not configured at all or as a result of user removing the interface from the config_db.json due to port breakout limitation on some platforms), entPhysicalDescr OID should return the transceiver type only and without the interface alias and the extra 'for ' text. Signed-off-by: liora liora@nvidia.com - What I did In the case interface not configured but transceiver exist, the transceiver description is only the transceiver type without the extra 'for xxx' text. - How I did it Verify if interface is configured. If yes, add to the transceiver type the interface alias. Else, only the transceiver type. - How to verify it snmpwalk -v 2c -c public 10.210.24.85 1.3.6.1.2.1.47.1.1.1.1.2 | grep SFP Signed-off-by: liora --- src/sonic_ax_impl/mibs/ietf/rfc2737.py | 7 +++++-- tests/mock_tables/state_db.json | 8 ++++++++ tests/test_sn.py | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/sonic_ax_impl/mibs/ietf/rfc2737.py b/src/sonic_ax_impl/mibs/ietf/rfc2737.py index dc63f4c9a7bf..db5b86579d34 100644 --- a/src/sonic_ax_impl/mibs/ietf/rfc2737.py +++ b/src/sonic_ax_impl/mibs/ietf/rfc2737.py @@ -157,9 +157,12 @@ def get_transceiver_description(sfp_type, if_alias): :param if_alias: Port alias name :return: Transceiver decsription """ + if not if_alias: + description = "{}".format(sfp_type) + else: + description = "{} for {}".format(sfp_type, if_alias) - return "{} for {}".format(sfp_type, if_alias) - + return description def get_transceiver_sensor_description(name, lane_number, if_alias): """ diff --git a/tests/mock_tables/state_db.json b/tests/mock_tables/state_db.json index 6b186c16b07e..20066305d46b 100644 --- a/tests/mock_tables/state_db.json +++ b/tests/mock_tables/state_db.json @@ -40,6 +40,14 @@ "model": "MODEL_NAME", "is_replaceable": "True" }, + "TRANSCEIVER_INFO|Ethernet1": { + "type": "QSFP-DD", + "hardware_rev": "A1", + "serial": "SERIAL_NUM", + "manufacturer": "VENDOR_NAME", + "model": "MODEL_NAME", + "is_replaceable": "True" + }, "TRANSCEIVER_DOM_SENSOR|Ethernet0": { "temperature": 25.39, "voltage": 3.37, diff --git a/tests/test_sn.py b/tests/test_sn.py index 057b66d5ca6b..403ee7e5b127 100644 --- a/tests/test_sn.py +++ b/tests/test_sn.py @@ -204,6 +204,26 @@ def test_getpdu_xcvr_info(self): self._check_getpdu(sub_id, expected_mib) + def test_getpdu_xcvr_info_port_disable(self): + sub_id = get_transceiver_sub_id(2)[0] + + expected_mib = { + 2: (ValueType.OCTET_STRING, "QSFP-DD"), + 4: (ValueType.INTEGER, CHASSIS_SUB_ID), + 5: (ValueType.INTEGER, PhysicalClass.PORT), + 6: (ValueType.INTEGER, -1), + 7: (ValueType.OCTET_STRING, "Ethernet1"), + 8: (ValueType.OCTET_STRING, "A1"), + 9: (ValueType.OCTET_STRING, ""), # skip + 10: (ValueType.OCTET_STRING, ""), # skip + 11: (ValueType.OCTET_STRING, "SERIAL_NUM"), + 12: (ValueType.OCTET_STRING, "VENDOR_NAME"), + 13: (ValueType.OCTET_STRING, "MODEL_NAME"), + 16: (ValueType.INTEGER, 1) + } + + self._check_getpdu(sub_id, expected_mib) + def test_getpdu_xcvr_dom(self): expected_mib = { get_transceiver_sensor_sub_id(1, SENSOR_TYPE_TEMP)[0]: "DOM Temperature Sensor for etp1",