Skip to content

Commit

Permalink
Move the run-time psu sensors updating support impl to platform api
Browse files Browse the repository at this point in the history
Signed-off-by: Yuanzhe, Liu <[email protected]>
  • Loading branch information
yuazhe committed May 17, 2024
1 parent c2c1c74 commit bc0d01f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion platform/mellanox/mlnx-platform-api/sonic_platform/psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, psu_index):
super(FixedPsu, self).__init__()
self.index = psu_index + 1
self._name = "PSU {}".format(self.index)
self.model = 'N/A'
self.psu_oper_status = os.path.join(PSU_PATH, "thermal/psu{}_pwr_status".format(self.index))
self._led = None

Expand Down Expand Up @@ -256,6 +257,9 @@ def __init__(self, psu_index):
from .thermal import initialize_psu_thermal
self._thermal_list = initialize_psu_thermal(psu_index, self.get_power_available_status)

# initialize psu model
self.model = self.vpd_parser.get_model()

@property
def psu_voltage(self):
if not self._psu_voltage:
Expand Down Expand Up @@ -304,7 +308,14 @@ def get_model(self):
Returns:
string: Model/part number of device
"""
return self.vpd_parser.get_model()
current_model = self.vpd_parser.get_model()
if current_model != self.model and os.path.exists('/usr/share/sonic/platform/psu_sensors_conf_updater'):
utils.run_command(['cp', '-f', '/etc/sensors.d/sensors.conf', '/tmp/sensors.conf.orig'])
utils.run_command(['bash', '-c','source /usr/share/sonic/platform/psu_sensors_conf_updater && update_psu_sensors_configuration /tmp/sensors.conf.orig'])
utils.run_command(['cp', '-f', '/tmp/sensors.conf', '/etc/sensors.d/'])
utils.run_command(['service', 'sensord', 'restart'])
self.model = current_model
return current_model

def get_serial(self):
"""
Expand Down

0 comments on commit bc0d01f

Please sign in to comment.