Skip to content

Commit

Permalink
[SNMP] Update description of entPhysicalDescr mib in case interface i…
Browse files Browse the repository at this point in the history
…s not configured. (sonic-net#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 <liora@nvidia.com>
  • Loading branch information
liorghub committed Apr 5, 2021
1 parent c20bf60 commit 80171a3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/sonic_ax_impl/mibs/ietf/rfc2737.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
8 changes: 8 additions & 0 deletions tests/mock_tables/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions tests/test_sn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 80171a3

Please sign in to comment.