From 38d38538a915fd27cbd00c654d414fd1974f50c1 Mon Sep 17 00:00:00 2001 From: Gregory Boudreau <45526465+gregoryboudreau@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:38:33 -0700 Subject: [PATCH] cisco mib update for psu key difference --- .../mibs/vendor/cisco/ciscoEntityFruControlMIB.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoEntityFruControlMIB.py b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoEntityFruControlMIB.py index 1871bd34c..4a346c556 100644 --- a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoEntityFruControlMIB.py +++ b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoEntityFruControlMIB.py @@ -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 {}' @@ -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) @@ -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)