Skip to content

Commit

Permalink
Fix review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Sun <stephens@nvidia.com>
  • Loading branch information
stephenxs committed Nov 19, 2022
1 parent 193c66e commit 7b5de1f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ This command displays the status of the device's power supply units
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
PSU 2 MTEF-PSF-AC-A MT1621X15247 A3 11.97 4.56 54.56 WARNING green
```

**show platform fan**
Expand Down
12 changes: 6 additions & 6 deletions psuutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def numpsus():
@click.option('-i', '--index', default=-1, type=int, help='Index of the PSU')
def status(index):
"""Display PSU status"""
header = ['PSU', 'Model', 'Serial', 'HW Rev', 'Voltage (V)', 'Current (A)', 'Power (W)', 'Power Warn Thres (W)', 'Power Crit Thres (W)', 'Status', 'LED']
header = ['PSU', 'Model', 'Serial', 'HW Rev', 'Voltage (V)', 'Current (A)', 'Power (W)', 'Power Warn-supp Thres (W)', 'Power Crit Thres (W)', 'Status', 'LED']
status_table = []

psu_list = platform_chassis.get_all_psus()
Expand All @@ -100,7 +100,7 @@ def status(index):
power = 'N/A'
led_color = 'N/A'
power_critical_threshold = 'N/A'
power_warning_threshold = 'N/A'
power_warning_suppress_threshold = 'N/A'

if psu.get_presence():
try:
Expand All @@ -109,13 +109,13 @@ def status(index):
power = psu.get_power()
try:
power_critical_threshold = psu.get_psu_power_critical_threshold()
power_warning_threshold = psu.get_psu_power_warning_threshold()
power_warning_suppress_threshold = psu.get_psu_power_warning_suppress_threshold()
except NotImplementedError:
pass
if power_critical_threshold is None:
power_critical_threshold = 'N/A'
if power_warning_threshold is None:
power_warning_threshold = 'N/A'
if power_warning_suppress_threshold is None:
power_warning_suppress_threshold = 'N/A'
status = 'OK'
except NotImplementedError:
status = 'UNKNOWN'
Expand Down Expand Up @@ -155,7 +155,7 @@ def status(index):
except NotImplementedError:
pass

status_table.append([psu_name, model, serial, revision, voltage, current, power, power_warning_threshold, power_critical_threshold, status, led_color])
status_table.append([psu_name, model, serial, revision, voltage, current, power, power_warning_suppress_threshold, power_critical_threshold, status, led_color])

if status_table:
click.echo(tabulate(status_table, header, tablefmt='simple', floatfmt='.2f'))
Expand Down
14 changes: 7 additions & 7 deletions tests/psuutil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
import psuutil.main as psuutil

STATUS_OUTPUT = '''\
PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Power Warn Thres (W) Power Crit Thres (W) Status LED
----- ----------- -------- -------- ------------- ------------- ----------- ---------------------- ---------------------- -------- -----
PSU 1 SampleModel S001 Rev A 12.00 10.00 120.00 90.00 100.00 OK green
PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Power Warn-supp Thres (W) Power Crit Thres (W) Status LED
----- ----------- -------- -------- ------------- ------------- ----------- --------------------------- ---------------------- -------- -----
PSU 1 SampleModel S001 Rev A 12.00 10.00 120.00 90.00 100.00 OK green
'''

STATUS_OUTPUT_NOT_IMPLEMENT = '''\
PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Power Warn Thres (W) Power Crit Thres (W) Status LED
----- ----------- -------- -------- ------------- ------------- ----------- ---------------------- ---------------------- -------- -----
PSU 1 SampleModel S001 N/A 12.00 10.00 120.00 N/A N/A OK green
PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Power Warn-supp Thres (W) Power Crit Thres (W) Status LED
----- ----------- -------- -------- ------------- ------------- ----------- --------------------------- ---------------------- -------- -----
PSU 1 SampleModel S001 N/A 12.00 10.00 120.00 N/A N/A OK green
'''

class TestPsuutil(object):
Expand All @@ -40,7 +40,7 @@ def test_psuutil_status(self, platform_chassis):
psu.get_presence = mock.MagicMock(return_value=True)
psu.get_powergood_status = mock.MagicMock(return_value=True)
psu.get_psu_power_critical_threshold = mock.MagicMock(return_value=100.0)
psu.get_psu_power_warning_threshold = mock.MagicMock(return_value=90.0)
psu.get_psu_power_warning_suppress_threshold = mock.MagicMock(return_value=90.0)
psu.get_model = mock.MagicMock(return_value='SampleModel')
psu.get_serial = mock.MagicMock(return_value='S001')
psu.get_revision = mock.MagicMock(return_value='Rev A')
Expand Down

0 comments on commit 7b5de1f

Please sign in to comment.