diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 8a247d40e38e..90dcf00597b8 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -775,10 +775,9 @@ This command displays the status of the device's power supply units - Example: ``` admin@sonic:~$ show platform psustatus - PSU Status - ----- -------- - PSU 1 OK - PSU 2 OK + PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Status LED + ----- ------------- ------------ -------- ------------- ------------- ----------- -------- ----- + PSU 1 MTEF-PSF-AC-A MT1621X15246 A3 11.97 4.56 54.56 OK green ``` **show platform fan** diff --git a/scripts/psushow b/scripts/psushow index b0e4dfc32ef2..60ebb34516e7 100755 --- a/scripts/psushow +++ b/scripts/psushow @@ -47,6 +47,7 @@ def get_psu_status_list(): psu_status['model'] = db.get(db.STATE_DB, 'PSU_INFO|{}'.format(psu_name), 'model') if presence else 'N/A' psu_status['serial'] = db.get(db.STATE_DB, 'PSU_INFO|{}'.format(psu_name), 'serial') if presence else 'N/A' + psu_status['revision'] = db.get(db.STATE_DB, 'PSU_INFO|{}'.format(psu_name), 'revision') if presence else 'N/A' psu_status['voltage'] = db.get(db.STATE_DB, 'PSU_INFO|{}'.format(psu_name), 'voltage') if presence else 'N/A' psu_status['current'] = db.get(db.STATE_DB, 'PSU_INFO|{}'.format(psu_name), 'current') if presence else 'N/A' psu_status['power'] = db.get(db.STATE_DB, 'PSU_INFO|{}'.format(psu_name), 'power') if presence else 'N/A' @@ -63,7 +64,7 @@ def psu_status_show_table(index): print('Error: Failed to get PSU status') return None - header = ['PSU', 'Model', 'Serial', 'Voltage (V)', 'Current (A)', 'Power (W)', 'Status', 'LED'] + header = ['PSU', 'Model', 'Serial', 'HW Rev', 'Voltage (V)', 'Current (A)', 'Power (W)', 'Status', 'LED'] status_table = [] if index > 0: @@ -78,6 +79,7 @@ def psu_status_show_table(index): status_table.append([psu_status['name'], psu_status['model'], psu_status['serial'], + psu_status['revision'], psu_status['voltage'], psu_status['current'], psu_status['power'], diff --git a/tests/mock_tables/state_db.json b/tests/mock_tables/state_db.json index ead7004b2799..4fb858691cc3 100644 --- a/tests/mock_tables/state_db.json +++ b/tests/mock_tables/state_db.json @@ -141,6 +141,7 @@ "status": "true", "model": "0J6J4K", "serial": "CN-0J6J4K-17972-5AF-0086-A00", + "revision": "1", "temp": "None", "temp_threshold": "None", "voltage": "12.19", @@ -156,6 +157,7 @@ "status": "true", "model": "0J6J4K", "serial": "CN-0J6J4K-17972-5AF-008M-A00", + "revision": "A", "temp": "None", "temp_threshold": "None", "voltage": "12.18", diff --git a/tests/psushow_test.py b/tests/psushow_test.py index fd40a3beb876..efbcde3d7567 100644 --- a/tests/psushow_test.py +++ b/tests/psushow_test.py @@ -34,6 +34,7 @@ def test_get_psu_status_list(self): 'led_status': 'green', 'model': '0J6J4K', 'serial': 'CN-0J6J4K-17972-5AF-0086-A00', + 'revision': '1', 'voltage': '12.19', 'current': '8.37', 'power': '102.7' @@ -46,6 +47,7 @@ def test_get_psu_status_list(self): 'led_status': 'green', 'model': '0J6J4K', 'serial': 'CN-0J6J4K-17972-5AF-008M-A00', + 'revision': 'A', 'voltage': '12.18', 'current': '10.07', 'power': '122.0' @@ -57,10 +59,10 @@ def test_get_psu_status_list(self): def test_status_table(self, capsys): expected_output = '''\ -PSU Model Serial Voltage (V) Current (A) Power (W) Status LED ------ ------- ---------------------------- ------------- ------------- ----------- -------- ----- -PSU 1 0J6J4K CN-0J6J4K-17972-5AF-0086-A00 12.19 8.37 102.70 OK green -PSU 2 0J6J4K CN-0J6J4K-17972-5AF-008M-A00 12.18 10.07 122.00 OK green +PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Status LED +----- ------- ---------------------------- -------- ------------- ------------- ----------- -------- ----- +PSU 1 0J6J4K CN-0J6J4K-17972-5AF-0086-A00 1 12.19 8.37 102.70 OK green +PSU 2 0J6J4K CN-0J6J4K-17972-5AF-008M-A00 A 12.18 10.07 122.00 OK green ''' for arg in ['-s', '--status']: with mock.patch('sys.argv', ['psushow', arg]): @@ -70,9 +72,9 @@ def test_status_table(self, capsys): assert captured.out == expected_output expected_output = '''\ -PSU Model Serial Voltage (V) Current (A) Power (W) Status LED ------ ------- ---------------------------- ------------- ------------- ----------- -------- ----- -PSU 1 0J6J4K CN-0J6J4K-17972-5AF-0086-A00 12.19 8.37 102.70 OK green +PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Status LED +----- ------- ---------------------------- -------- ------------- ------------- ----------- -------- ----- +PSU 1 0J6J4K CN-0J6J4K-17972-5AF-0086-A00 1 12.19 8.37 102.70 OK green ''' for arg in ['-s', '--status']: with mock.patch('sys.argv', ['psushow', arg, '-i', '1']): @@ -82,9 +84,9 @@ def test_status_table(self, capsys): assert captured.out == expected_output expected_output = '''\ -PSU Model Serial Voltage (V) Current (A) Power (W) Status LED ------ ------- ---------------------------- ------------- ------------- ----------- -------- ----- -PSU 2 0J6J4K CN-0J6J4K-17972-5AF-008M-A00 12.18 10.07 122.00 OK green +PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Status LED +----- ------- ---------------------------- -------- ------------- ------------- ----------- -------- ----- +PSU 2 0J6J4K CN-0J6J4K-17972-5AF-008M-A00 A 12.18 10.07 122.00 OK green ''' for arg in ['-s', '--status']: with mock.patch('sys.argv', ['psushow', arg, '-i', '2']): @@ -116,6 +118,7 @@ def test_status_json(self, capsys): "led_status": "green", "model": "0J6J4K", "serial": "CN-0J6J4K-17972-5AF-0086-A00", + "revision": "1", "voltage": "12.19", "current": "8.37", "power": "102.7" @@ -128,6 +131,7 @@ def test_status_json(self, capsys): "led_status": "green", "model": "0J6J4K", "serial": "CN-0J6J4K-17972-5AF-008M-A00", + "revision": "A", "voltage": "12.18", "current": "10.07", "power": "122.0" @@ -151,6 +155,7 @@ def test_status_json(self, capsys): "led_status": "green", "model": "0J6J4K", "serial": "CN-0J6J4K-17972-5AF-0086-A00", + "revision": "1", "voltage": "12.19", "current": "8.37", "power": "102.7" @@ -174,6 +179,7 @@ def test_status_json(self, capsys): "led_status": "green", "model": "0J6J4K", "serial": "CN-0J6J4K-17972-5AF-008M-A00", + "revision": "A", "voltage": "12.18", "current": "10.07", "power": "122.0"