Skip to content

Commit 5f5fefd

Browse files
authored
add psu input voltage and current (#276)
Add PSU input voltage, input current and max power to the PSU table in the STATE DB - Description psud would collect input voltage, input current and max power (capacity) of the PSU. till now, it collect the output voltage and current. - Motivation and Context more information about the PSU. - How Has This Been Tested? unit tests, manual testing. Signed-off-by: orfar1994 <[email protected]>
1 parent c7cbbb8 commit 5f5fefd

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

sonic-psud/scripts/psud

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ PSU_INFO_VOLTAGE_MIN_TH_FIELD = 'voltage_min_threshold'
5858
PSU_INFO_CURRENT_FIELD = 'current'
5959
PSU_INFO_POWER_FIELD = 'power'
6060
PSU_INFO_FRU_FIELD = 'is_replaceable'
61+
PSU_INFO_IN_VOLTAGE_FIELD = 'input_voltage'
62+
PSU_INFO_IN_CURRENT_FIELD = 'input_current'
63+
PSU_INFO_POWER_MAX_FIELD = 'max_power'
6164

6265
PHYSICAL_ENTITY_INFO_TABLE = 'PHYSICAL_ENTITY_INFO'
6366

@@ -455,6 +458,9 @@ class DaemonPsud(daemon_base.DaemonBase):
455458
current = NOT_AVAILABLE
456459
power = NOT_AVAILABLE
457460
is_replaceable = try_get(psu.is_replaceable, False)
461+
in_voltage = NOT_AVAILABLE
462+
in_current = NOT_AVAILABLE
463+
max_power = NOT_AVAILABLE
458464
if presence:
459465
power_good = _wrapper_get_psu_status(index)
460466
voltage = try_get(psu.get_voltage, NOT_AVAILABLE)
@@ -464,6 +470,9 @@ class DaemonPsud(daemon_base.DaemonBase):
464470
temperature_threshold = try_get(psu.get_temperature_high_threshold, NOT_AVAILABLE)
465471
current = try_get(psu.get_current, NOT_AVAILABLE)
466472
power = try_get(psu.get_power, NOT_AVAILABLE)
473+
in_current = try_get(psu.get_input_current, NOT_AVAILABLE)
474+
in_voltage = try_get(psu.get_input_voltage, NOT_AVAILABLE)
475+
max_power = try_get(psu.get_maximum_supplied_power, NOT_AVAILABLE)
467476

468477
if index not in self.psu_status_dict:
469478
self.psu_status_dict[index] = PsuStatus(self, psu, index)
@@ -524,6 +533,9 @@ class DaemonPsud(daemon_base.DaemonBase):
524533
(PSU_INFO_CURRENT_FIELD, str(current)),
525534
(PSU_INFO_POWER_FIELD, str(power)),
526535
(PSU_INFO_FRU_FIELD, str(is_replaceable)),
536+
(PSU_INFO_IN_CURRENT_FIELD, str(in_current)),
537+
(PSU_INFO_IN_VOLTAGE_FIELD, str(in_voltage)),
538+
(PSU_INFO_POWER_MAX_FIELD, str(max_power)),
527539
])
528540
self.psu_tbl.set(name, fvs)
529541

sonic-psud/tests/mock_platform.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ def __init__(self,
282282
temp_high_th=50.0,
283283
voltage_low_th=11.0,
284284
voltage_high_th=13.0,
285-
replaceable=True):
285+
replaceable=True,
286+
in_current=0.72,
287+
in_voltage=220.25):
286288
super(MockPsu, self).__init__()
287289
self._name = name
288290
self._presence = presence
@@ -301,6 +303,9 @@ def __init__(self,
301303
self._voltage_low_th = voltage_low_th
302304
self._voltage_high_th = voltage_high_th
303305
self._status_led_color = self.STATUS_LED_COLOR_OFF
306+
self._in_voltage = in_voltage
307+
self._in_current = in_current
308+
self._max_supplied_power = 'N/A'
304309

305310
def get_voltage(self):
306311
return self._voltage
@@ -381,3 +386,9 @@ def get_position_in_parent(self):
381386

382387
def is_replaceable(self):
383388
return self._replaceable
389+
390+
def get_input_current(self):
391+
return self._in_current
392+
393+
def get_input_voltage(self):
394+
return self._in_voltage

sonic-psud/tests/test_DaemonPsud.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ def test_update_single_psu_data(self):
165165
(psud.PSU_INFO_CURRENT_FIELD, '8.0'),
166166
(psud.PSU_INFO_POWER_FIELD, '100.0'),
167167
(psud.PSU_INFO_FRU_FIELD, 'True'),
168+
(psud.PSU_INFO_IN_VOLTAGE_FIELD, '220.25'),
169+
(psud.PSU_INFO_IN_CURRENT_FIELD, '0.72'),
170+
(psud.PSU_INFO_POWER_MAX_FIELD, 'N/A'),
168171
])
169172

170173
daemon_psud = psud.DaemonPsud(SYSLOG_IDENTIFIER)

0 commit comments

Comments
 (0)