-
Notifications
You must be signed in to change notification settings - Fork 130
[sonic-snmpagent] SONiC physical entity mib extension #168
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9640bc1
SONiC MIB Extension feature first commit
Junchao-Mellanox 625f492
Add unit test cases and fix found issues
Junchao-Mellanox 1228c97
Add more comments
Junchao-Mellanox be0e817
fix issue found in manual tests
Junchao-Mellanox caf96dc
Fix issue found in manual test
Junchao-Mellanox 10569b6
Fix issue: PSU fan is not in entity mib
Junchao-Mellanox b89cde1
Add chassis name and description
Junchao-Mellanox e160479
Change physical index generating rule
Junchao-Mellanox da2adb2
Merge branch 'master' into phy-mibs
Junchao-Mellanox ce9e952
Merge branch 'master' into phy-mibs
Junchao-Mellanox 96d4897
Fix review comment
Junchao-Mellanox 94957eb
Change all bytearray to str
Junchao-Mellanox aa727d5
Move physical_entity_sub_oid_generator to src/sonic_ax_impl/mibs/ietf
Junchao-Mellanox 9f8723b
Fix review comment
Junchao-Mellanox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ | |
| from ax_interface.util import oid2tuple | ||
| from sonic_ax_impl import logger | ||
|
|
||
| from .physical_entity_sub_oid_generator import * | ||
|
||
|
|
||
| COUNTERS_PORT_NAME_MAP = 'COUNTERS_PORT_NAME_MAP' | ||
| COUNTERS_QUEUE_NAME_MAP = 'COUNTERS_QUEUE_NAME_MAP' | ||
| LAG_TABLE = 'LAG_TABLE' | ||
|
|
@@ -25,27 +27,6 @@ | |
| TABLE_NAME_SEPARATOR_COLON = ':' | ||
| TABLE_NAME_SEPARATOR_VBAR = '|' | ||
|
|
||
| # This is used in both rfc2737 and rfc3433 | ||
| SENSOR_PART_ID_MAP = { | ||
| "temperature": 1, | ||
| "voltage": 2, | ||
| "rx1power": 11, | ||
| "rx2power": 21, | ||
| "rx3power": 31, | ||
| "rx4power": 41, | ||
| "tx1bias": 12, | ||
| "tx2bias": 22, | ||
| "tx3bias": 32, | ||
| "tx4bias": 42, | ||
| "tx1power": 13, | ||
| "tx2power": 23, | ||
| "tx3power": 33, | ||
| "tx4power": 43, | ||
| } | ||
|
|
||
| # IfIndex to OID multiplier for transceiver | ||
| IFINDEX_SUB_ID_MULTIPLIER = 1000 | ||
|
|
||
| redis_kwargs = {'unix_socket_path': '/var/run/redis/redis.sock'} | ||
|
|
||
|
|
||
|
|
@@ -65,6 +46,22 @@ def chassis_info_table(chassis_name): | |
|
|
||
| return "CHASSIS_INFO" + TABLE_NAME_SEPARATOR_VBAR + chassis_name | ||
|
|
||
| def fan_info_table(fan_name): | ||
| """ | ||
| :param: fan_name: fan name | ||
| :return: fan info entry for this fan | ||
| """ | ||
| return 'FAN_INFO' + TABLE_NAME_SEPARATOR_VBAR + fan_name | ||
|
|
||
|
|
||
| def fan_drawer_info_table(drawer_name): | ||
| """ | ||
| :param: drawer_name: fan drawer name | ||
| :return: fan drawer info entry for this fan | ||
| """ | ||
| return 'FAN_DRAWER_INFO' + TABLE_NAME_SEPARATOR_VBAR + drawer_name | ||
|
|
||
|
|
||
| def psu_info_table(psu_name): | ||
| """ | ||
| :param: psu_name: psu name | ||
|
|
@@ -73,6 +70,15 @@ def psu_info_table(psu_name): | |
|
|
||
| return "PSU_INFO" + TABLE_NAME_SEPARATOR_VBAR + psu_name | ||
|
|
||
|
|
||
| def physical_entity_info_table(name): | ||
| """ | ||
| :param: name: object name | ||
| :return: entity info entry for this object | ||
| """ | ||
| return 'PHYSICAL_ENTITY_INFO' + TABLE_NAME_SEPARATOR_VBAR + name | ||
|
|
||
|
|
||
| def counter_table(sai_id): | ||
| """ | ||
| :param if_name: given sai_id to cast. | ||
|
|
@@ -106,6 +112,14 @@ def transceiver_dom_table(port_name): | |
|
|
||
| return "TRANSCEIVER_DOM_SENSOR" + TABLE_NAME_SEPARATOR_VBAR + port_name | ||
|
|
||
| def thermal_info_table(thermal_name): | ||
| """ | ||
| :param: port_name: port name | ||
| :return: transceiver dom entry for this port | ||
| """ | ||
|
|
||
| return "TEMPERATURE_INFO" + TABLE_NAME_SEPARATOR_VBAR + thermal_name | ||
|
|
||
| def lldp_entry_table(if_name): | ||
| """ | ||
| :param if_name: given interface to cast. | ||
|
|
@@ -386,40 +400,6 @@ def get_device_metadata(db_conn): | |
| device_metadata = db_conn.get_all(db_conn.STATE_DB, DEVICE_METADATA) | ||
| return device_metadata | ||
|
|
||
| def get_transceiver_sub_id(ifindex): | ||
| """ | ||
| Returns sub OID for transceiver. Sub OID is calculated as folows: | ||
| +------------+------------+ | ||
| |Interface |Index | | ||
| +------------+------------+ | ||
| |Ethernet[X] |X * 1000 | | ||
| +------------+------------+ | ||
| () | ||
| :param ifindex: interface index | ||
| :return: sub OID of a port calculated as sub OID = {{index}} * 1000 | ||
| """ | ||
|
|
||
| return (ifindex * IFINDEX_SUB_ID_MULTIPLIER, ) | ||
|
|
||
| def get_transceiver_sensor_sub_id(ifindex, sensor): | ||
| """ | ||
| Returns sub OID for transceiver sensor. Sub OID is calculated as folows: | ||
| +-------------------------------------+------------------------------+ | ||
| |Sensor |Index | | ||
| +-------------------------------------+------------------------------+ | ||
| |RX Power for Ethernet[X]/[LANEID] |X * 1000 + LANEID * 10 + 1 | | ||
| |TX Bias for Ethernet[X]/[LANEID] |X * 1000 + LANEID * 10 + 2 | | ||
| |Temperature for Ethernet[X] |X * 1000 + 1 | | ||
| |Voltage for Ethernet[X]/[LANEID] |X * 1000 + 2 | | ||
| +-------------------------------------+------------------------------+ | ||
| () | ||
| :param ifindex: interface index | ||
| :param sensor: sensor key | ||
| :return: sub OID = {{index}} * 1000 + {{lane}} * 10 + sensor id | ||
| """ | ||
|
|
||
| transceiver_oid, = get_transceiver_sub_id(ifindex) | ||
| return (transceiver_oid + SENSOR_PART_ID_MAP[sensor], ) | ||
|
|
||
| def get_redis_pubsub(db_conn, db_name, pattern): | ||
| redis_client = db_conn.get_redis_client(db_name) | ||
|
|
@@ -428,6 +408,7 @@ def get_redis_pubsub(db_conn, db_name, pattern): | |
| pubsub.psubscribe("__keyspace@{}__:{}".format(db, pattern)) | ||
| return pubsub | ||
|
|
||
|
|
||
| class RedisOidTreeUpdater(MIBUpdater): | ||
| def __init__(self, prefix_str): | ||
| super().__init__() | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't import wildcard in production code. #Closed