Skip to content

Commit

Permalink
[psushow] Add a column to display LED color to show platform psustatu…
Browse files Browse the repository at this point in the history
…s output (#886)
  • Loading branch information
Junchao-Mellanox authored Apr 30, 2020
1 parent e747456 commit 6fba8db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions scripts/psushow
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def psu_status_show(index):
else:
psu_ids = [index]

header = ['PSU', 'Status']
header = ['PSU', 'Status', 'LED']
status_table = []

for psu in psu_ids:
Expand All @@ -51,7 +51,8 @@ def psu_status_show(index):
msg = 'OK' if oper_status == 'true' else "NOT OK"
else:
msg = 'NOT PRESENT'
status_table.append([psu_name, msg])
led_status = db.get(db.STATE_DB, 'PSU_INFO|{}'.format(psu_name), 'led_status')
status_table.append([psu_name, msg, led_status])

if status_table:
print tabulate(status_table, header, tablefmt="simple")
Expand Down
6 changes: 4 additions & 2 deletions sonic-utilities-tests/mock_tables/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@
},
"PSU_INFO|PSU 1": {
"presence": "true",
"status": "true"
"status": "true",
"led_status": "green"
},
"PSU_INFO|PSU 2": {
"presence": "true",
"status": "true"
"status": "true",
"led_status": "green"
},
"SWITCH_CAPABILITY|switch": {
"MIRROR": "true",
Expand Down
6 changes: 3 additions & 3 deletions sonic-utilities-tests/psu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def test_verbose(self):
def test_single_psu(self):
runner = CliRunner()
result = runner.invoke(show.cli.commands["platform"].commands["psustatus"], ["--index=1"])
expected = """PSU Status
----- --------
PSU 1 OK
expected = """PSU Status LED
----- -------- -----
PSU 1 OK green
"""
assert result.output == expected

Expand Down

0 comments on commit 6fba8db

Please sign in to comment.