Skip to content

[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 14 commits into from
Nov 12, 2020

Conversation

Junchao-Mellanox
Copy link
Collaborator

- What I did

Add new physical entity fan drawer, fan, fan tachometers, PSU, PSU sensor, chassis sensors to physical entity mib.

Implement all mib objects defined in EntPhysicalEntry of RFC 2737.

- How I did it

Refactor rfc2737.py to have different mib updater for different physical entity: XcvrCacheUpdater, FanCacheUpdater, FanDrawerCacheUpdater, PsuCacheUpdater, ThermalCacheUpdater.

- How to verify it

Manual test on MSN2410

- Description for the changelog

@Junchao-Mellanox
Copy link
Collaborator Author

retest this please

Conflicts:
	src/sonic_ax_impl/mibs/ietf/rfc2737.py
REPLACEABLE = 'is_replaceable'

@unique
class ThermalInfoDB(bytes, Enum):
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bytes [](start = 20, length = 5)

str instead of bytes?
Please be aware of latest change on master:

57e54d9 2020-10-22 | Interact with Redis by str instead of bytes, migrate to SonicV2Connector with `decode_responses=True` (#171)
``` #Closed

'temperature': 'Temperature',
'power': 'Power',
'current': 'Current',
'voltage': 'Voltage'
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

align by : ? #Closed

"""
if not value or value == NOT_AVAILABLE or value == str(None):
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not value [](start = 7, length = 9)

isinstance(value, str) #Closed

"""
if not value or value == NOT_AVAILABLE or value == str(None):
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str(None) [](start = 55, length = 9)

use None ? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean why not use 'None' directly?


In reply to: 511724801 [](ancestors = 511724801)

"""
ret = []
for field in enum_type:
value = info_dict.get(field.value, "")
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"" [](start = 43, length = 2)

The default value could not be decode() as below #Closed

@@ -386,40 +505,89 @@ def get_device_metadata(db_conn):
device_metadata = db_conn.get_all(db_conn.STATE_DB, DEVICE_METADATA)
return device_metadata


def get_chassis_thermal_sub_id(position):
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_chassis_thermal_sub_id [](start = 4, length = 26)

Move non shared functions into rfc2737.py or another python file?
I think many functions and constants are related to the comment section above. Move them into a seperated file may be easier to read. #Closed

name = 'MGMT'
self.physical_description_map[chassis_mgmt_sub_id] = name
self.physical_name_map[chassis_mgmt_sub_id] = name
self.physical_fru_map[chassis_mgmt_sub_id] = self.NOT_REPLACEABLE
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see most contents are static, why we need to reinit_data() every time? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we clear all existing data before reinit_data(), see line 304~316. And in those data, we have both static/dynamic data, it is hard to tell which one is static or dynamic unless we hardcode it or add a tag for each data(which is even complicated). So I choose to reinit these static content every time. Any suggestion?

@qiluo-msft
Copy link
Contributor

qiluo-msft commented Oct 26, 2020

Could you write a design/implementation document to help understand? #Closed

@Junchao-Mellanox
Copy link
Collaborator Author

Could you write a design/implementation document to help understand?

HLD: https://github.com/Junchao-Mellanox/SONiC/blob/phy-mibs/doc/snmp/extension-to-physical-entity-mib.md

@lgtm-com
Copy link

lgtm-com bot commented Oct 27, 2020

This pull request introduces 1 alert when merging 94957eb into 57e54d9 - view on LGTM.com

new alerts:

  • 1 for 'import *' may pollute namespace

@Junchao-Mellanox
Copy link
Collaborator Author

@qiluo-msft, I have fixed/replied all comments, could you pleast review it again? Thanks!

@@ -10,6 +10,8 @@
from ax_interface.util import oid2tuple
from sonic_ax_impl import logger

from .physical_entity_sub_oid_generator import *
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import * [](start = 40, length = 8)

Don't import wildcard in production code. #Closed

@@ -10,6 +10,8 @@
from ax_interface.util import oid2tuple
from sonic_ax_impl import logger

from .physical_entity_sub_oid_generator import *
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

physical_entity_sub_oid_generator [](start = 6, length = 33)

This file is only used by rfc2737.py. You may move code to

  1. src/sonic_ax_impl/lib/
  2. or, src/sonic_ax_impl/mibs/ietf
    And only import in required file. #Closed

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@qiluo-msft qiluo-msft merged commit b8f19ee into sonic-net:master Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants