Skip to content
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

Updating SNMP implementation to handle change of PSU Keys #312

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from enum import Enum, unique
from sonic_ax_impl import mibs
from ax_interface import MIBMeta, ValueType, SubtreeMIBEntry
from natsort import natsorted

CHASSIS_INFO_KEY_TEMPLATE = 'chassis {}'
PSU_INFO_KEY_TEMPLATE = 'PSU {}'
Expand Down Expand Up @@ -70,7 +71,8 @@ def _get_psu_presence(self, psu_index):
Get PSU presence
:return: the presence of particular PSU
"""
psu_name = PSU_INFO_KEY_TEMPLATE.format(psu_index)
psu_keys = natsorted(self.statedb.keys(self.statedb.STATE_DB, "PSU_INFO|*"))
psu_name = psu_keys[psu_index-1].removeprefix("PSU_INFO|")
psu_info = self.statedb.get_all(self.statedb.STATE_DB, mibs.psu_info_table(psu_name))
presence, status = get_psu_data(psu_info)

Expand All @@ -81,7 +83,8 @@ def _get_psu_status(self, psu_index):
Get PSU status
:return: the status of particular PSU
"""
psu_name = PSU_INFO_KEY_TEMPLATE.format(psu_index)
psu_keys = natsorted(self.statedb.keys(self.statedb.STATE_DB, "PSU_INFO|*"))
psu_name = psu_keys[psu_index-1].removeprefix("PSU_INFO|")
psu_info = self.statedb.get_all(self.statedb.STATE_DB, mibs.psu_info_table(psu_name))
presence, status = get_psu_data(psu_info)

Expand Down
Loading