Skip to content

Commit 807b304

Browse files
authored
[psud] Add PSU Hardware Revision to Redis STATE_DB (sonic-net#179)
Added "hardware revision" field to list of platform fields to sync to STATE_DB for the PSU. Also updated relevant unit tests. Now that hardware revision exists as a platform 2.0 field for all devices, it is appropriate to synchronize this field to STATE_DB for PSUs as is done with all other fields. This will allow this field to be exposed to CLI tools through psushow in the future which reads state from STATE_DB.
1 parent d0be634 commit 807b304

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

sonic-psud/scripts/psud

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ PSU_INFO_KEY_TEMPLATE = 'PSU {}'
4848
PSU_INFO_PRESENCE_FIELD = 'presence'
4949
PSU_INFO_MODEL_FIELD = 'model'
5050
PSU_INFO_SERIAL_FIELD = 'serial'
51+
PSU_INFO_REV_FIELD = 'revision'
5152
PSU_INFO_STATUS_FIELD = 'status'
5253
PSU_INFO_TEMP_FIELD = 'temp'
5354
PSU_INFO_TEMP_TH_FIELD = 'temp_threshold'
@@ -510,6 +511,7 @@ class DaemonPsud(daemon_base.DaemonBase):
510511
fvs = swsscommon.FieldValuePairs(
511512
[(PSU_INFO_MODEL_FIELD, str(try_get(psu.get_model, NOT_AVAILABLE))),
512513
(PSU_INFO_SERIAL_FIELD, str(try_get(psu.get_serial, NOT_AVAILABLE))),
514+
(PSU_INFO_REV_FIELD, str(try_get(psu.get_revision, NOT_AVAILABLE))),
513515
(PSU_INFO_TEMP_FIELD, str(temperature)),
514516
(PSU_INFO_TEMP_TH_FIELD, str(temperature_threshold)),
515517
(PSU_INFO_VOLTAGE_FIELD, str(voltage)),

sonic-psud/tests/mock_platform.py

+5
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def __init__(self,
273273
presence=True,
274274
model='Module Model',
275275
serial='Module Serial',
276+
revision='Module Revision',
276277
status=True,
277278
voltage=12.0,
278279
current=8.0,
@@ -287,6 +288,7 @@ def __init__(self,
287288
self._presence = presence
288289
self._model = model
289290
self._serial = serial
291+
self._revision = revision
290292
self._status = status
291293
self._position_in_parent = position_in_parent
292294
self._replaceable = replaceable
@@ -365,6 +367,9 @@ def get_model(self):
365367
def get_serial(self):
366368
return self._serial
367369

370+
def get_revision(self):
371+
return self._revision
372+
368373
def get_status(self):
369374
return self._status
370375

sonic-psud/tests/test_DaemonPsud.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,14 @@ def test_update_single_psu_data(self):
148148
psud._wrapper_get_psu_presence.return_value = True
149149
psud._wrapper_get_psu_status.return_value = True
150150

151-
psu1 = MockPsu('PSU 1', 0, True, 'Fake Model', '12345678')
151+
psu1 = MockPsu('PSU 1', 0, True, 'Fake Model', '12345678', '1234')
152152
psud.platform_chassis = MockChassis()
153153
psud.platform_chassis._psu_list.append(psu1)
154154

155155
expected_fvp = psud.swsscommon.FieldValuePairs(
156156
[(psud.PSU_INFO_MODEL_FIELD, 'Fake Model'),
157157
(psud.PSU_INFO_SERIAL_FIELD, '12345678'),
158+
(psud.PSU_INFO_REV_FIELD, '1234'),
158159
(psud.PSU_INFO_TEMP_FIELD, '30.0'),
159160
(psud.PSU_INFO_TEMP_TH_FIELD, '50.0'),
160161
(psud.PSU_INFO_VOLTAGE_FIELD, '12.0'),

0 commit comments

Comments
 (0)