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

add psu input voltage and current #276

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions sonic-psud/scripts/psud
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ PSU_INFO_VOLTAGE_MIN_TH_FIELD = 'voltage_min_threshold'
PSU_INFO_CURRENT_FIELD = 'current'
PSU_INFO_POWER_FIELD = 'power'
PSU_INFO_FRU_FIELD = 'is_replaceable'
PSU_INFO_IN_VOLTAGE_FIELD = 'input_voltage'
PSU_INFO_IN_CURRENT_FIELD = 'input_current'
PSU_INFO_POWER_MAX_FIELD = 'max_power'

PHYSICAL_ENTITY_INFO_TABLE = 'PHYSICAL_ENTITY_INFO'

Expand Down Expand Up @@ -455,6 +458,9 @@ class DaemonPsud(daemon_base.DaemonBase):
current = NOT_AVAILABLE
power = NOT_AVAILABLE
is_replaceable = try_get(psu.is_replaceable, False)
in_voltage = NOT_AVAILABLE
in_current = NOT_AVAILABLE
max_power = NOT_AVAILABLE
if presence:
power_good = _wrapper_get_psu_status(index)
voltage = try_get(psu.get_voltage, NOT_AVAILABLE)
Expand All @@ -464,6 +470,9 @@ class DaemonPsud(daemon_base.DaemonBase):
temperature_threshold = try_get(psu.get_temperature_high_threshold, NOT_AVAILABLE)
current = try_get(psu.get_current, NOT_AVAILABLE)
power = try_get(psu.get_power, NOT_AVAILABLE)
in_current = try_get(psu.get_input_current, NOT_AVAILABLE)
in_voltage = try_get(psu.get_input_voltage, NOT_AVAILABLE)
max_power = try_get(psu.get_maximum_supplied_power, NOT_AVAILABLE)

if index not in self.psu_status_dict:
self.psu_status_dict[index] = PsuStatus(self, psu, index)
Expand Down Expand Up @@ -524,6 +533,9 @@ class DaemonPsud(daemon_base.DaemonBase):
(PSU_INFO_CURRENT_FIELD, str(current)),
(PSU_INFO_POWER_FIELD, str(power)),
(PSU_INFO_FRU_FIELD, str(is_replaceable)),
(PSU_INFO_IN_CURRENT_FIELD, str(in_current)),
(PSU_INFO_IN_VOLTAGE_FIELD, str(in_voltage)),
(PSU_INFO_POWER_MAX_FIELD, str(max_power)),
])
self.psu_tbl.set(name, fvs)

Expand Down
13 changes: 12 additions & 1 deletion sonic-psud/tests/mock_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ def __init__(self,
temp_high_th=50.0,
voltage_low_th=11.0,
voltage_high_th=13.0,
replaceable=True):
replaceable=True,
in_current=0.72,
in_voltage=220.25):
super(MockPsu, self).__init__()
self._name = name
self._presence = presence
Expand All @@ -301,6 +303,9 @@ def __init__(self,
self._voltage_low_th = voltage_low_th
self._voltage_high_th = voltage_high_th
self._status_led_color = self.STATUS_LED_COLOR_OFF
self._in_voltage = in_voltage
self._in_current = in_current
self._max_supplied_power = 'N/A'

def get_voltage(self):
return self._voltage
Expand Down Expand Up @@ -381,3 +386,9 @@ def get_position_in_parent(self):

def is_replaceable(self):
return self._replaceable

def get_input_current(self):
return self._in_current

def get_input_voltage(self):
return self._in_voltage
3 changes: 3 additions & 0 deletions sonic-psud/tests/test_DaemonPsud.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ def test_update_single_psu_data(self):
(psud.PSU_INFO_CURRENT_FIELD, '8.0'),
(psud.PSU_INFO_POWER_FIELD, '100.0'),
(psud.PSU_INFO_FRU_FIELD, 'True'),
(psud.PSU_INFO_IN_VOLTAGE_FIELD, '220.25'),
(psud.PSU_INFO_IN_CURRENT_FIELD, '0.72'),
(psud.PSU_INFO_POWER_MAX_FIELD, 'N/A'),
])

daemon_psud = psud.DaemonPsud(SYSLOG_IDENTIFIER)
Expand Down