Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[psushow] Add more output columns; Add option to output in JSON format #1416

Merged
merged 13 commits into from
Feb 25, 2021
Merged

[psushow] Add more output columns; Add option to output in JSON format #1416

merged 13 commits into from
Feb 25, 2021

Conversation

jleveque
Copy link
Contributor

@jleveque jleveque commented Feb 9, 2021

- What I did

  • Enhance psushow -s output, adding columns to display PSU Model, Serial, Voltage, Current and Power
  • Add -j/--json option to display output in JSON format
  • Update mock State DB PSU_INFO table to provide values which we can ensure floats are padded to two decimal places in tabular display mode
  • Add --json option to show platform psustatus which in turn adds the -j flag to the underlying psushow call
  • Add unit tests for psushow in psushow_test.py
  • Add more unit tests for show platform psustatus and move to show_platform_test.py

- How to verify it

Run psushow -s variants

- Previous command output (if the output of a command-line utility has changed)

admin@sonic:~$ psushow -s
PSU    Status    LED
-----  --------  -----
PSU 1  OK        green
PSU 2  OK        green

admin@sonic:~$ psushow -s -i 1
PSU    Status    LED
-----  --------  -----
PSU 1  OK        green

admin@sonic:~$ psushow -s -i 2
PSU    Status    LED
-----  --------  -----
PSU 2  OK        green

- New command output (if the output of a command-line utility has changed)

admin@sonic:~$ psushow -s
PSU    Model    Serial                          Voltage (V)    Current (A)    Power (W)  Status    LED
-----  -------  ----------------------------  -------------  -------------  -----------  --------  -----
PSU 1  0XNMHJ   CN-0XNMHJ-DED00-036-00M3-A00          12.19           8.37       102.10  OK        green
PSU 2  0XNMHJ   CN-0XNMHJ-DED00-036-00H0-A00          12.18          10.07       122.70  OK        green

admin@sonic:~$ psushow -s -i 1
PSU    Model    Serial                          Voltage (V)    Current (A)    Power (W)  Status    LED
-----  -------  ----------------------------  -------------  -------------  -----------  --------  -----
PSU 1  0XNMHJ   CN-0XNMHJ-DED00-036-00M3-A00          12.21           7.25        95.10  OK        green

admin@sonic:~$ psushow -s -i 2
PSU    Model    Serial                          Voltage (V)    Current (A)    Power (W)  Status    LED
-----  -------  ----------------------------  -------------  -------------  -----------  --------  -----
PSU 2  0XNMHJ   CN-0XNMHJ-DED00-036-00H0-A00          12.19           7.74        94.30  OK        green

admin@sonic:~$ psushow -s -j
[
    {
        "index": "1",
        "name": "PSU 1",
        "presence": "true",
        "status": "OK",
        "led_status": "green",
        "model": "0XNMHJ",
        "serial": "CN-0XNMHJ-DED00-036-00M3-A00",
        "voltage": "12.21",
        "current": "7.43",
        "power": "90.7"
    },
    {
        "index": "2",
        "name": "PSU 2",
        "presence": "true",
        "status": "OK",
        "led_status": "green",
        "model": "0XNMHJ",
        "serial": "CN-0XNMHJ-DED00-036-00H0-A00",
        "voltage": "12.19",
        "current": "8.35",
        "power": "97.2"
    }
]

admin@sonic:~$ psushow -s -i 1 -j
[
    {
        "index": "1",
        "name": "PSU 1",
        "presence": "true",
        "status": "OK",
        "led_status": "green",
        "model": "0XNMHJ",
        "serial": "CN-0XNMHJ-DED00-036-00M3-A00",
        "voltage": "12.19",
        "current": "7.59",
        "power": "92.6"
    }
]

admin@sonic:~$ psushow -s -i 2 -j
[
    {
        "index": "2",
        "name": "PSU 2",
        "presence": "true",
        "status": "OK",
        "led_status": "green",
        "model": "0XNMHJ",
        "serial": "CN-0XNMHJ-DED00-036-00H0-A00",
        "voltage": "12.19",
        "current": "7.78",
        "power": "94.8"
    }
]

@jleveque jleveque self-assigned this Feb 9, 2021
@lgtm-com

This comment has been minimized.

@jleveque jleveque marked this pull request as ready for review February 10, 2021 22:09
@jleveque jleveque changed the title [psushow] Add more output columns [psushow] Add more output columns; Add option to output in JSON format Feb 18, 2021
@lgtm-com

This comment has been minimized.

@lgtm-com

This comment has been minimized.

@lgtm-com
Copy link

lgtm-com bot commented Feb 20, 2021

This pull request fixes 1 alert when merging 2a37cb6 into 0eaabfd - view on LGTM.com

fixed alerts:

  • 1 for Unused import

@jleveque jleveque merged commit 1fa4b94 into sonic-net:master Feb 25, 2021
@jleveque jleveque deleted the enhance_psushow branch February 25, 2021 20:10
yxieca pushed a commit to sonic-net/sonic-mgmt that referenced this pull request Feb 26, 2021
…ded output (#3040)

Approach
What is the motivation for this PR?
Update testing of show platform psustatus to handle the new, expanded output provided by sonic-net/sonic-utilities#1416. Maintain backward-compatibility with the previous syntax in 201811 and 201911 versions.

How did you do it?
Support both output formats based on observed OS version

How did you verify/test it?
Tested against one platform with old and new output formats
anand-kumar-subramanian pushed a commit to anand-kumar-subramanian/sonic-utilities that referenced this pull request Mar 2, 2021
sonic-net#1416)

- Enhance `psushow -s` output, adding columns to display PSU Model, Serial, Voltage, Current and Power
- Add `-j/--json` option to display output in JSON format
- Update mock State DB PSU_INFO table to provide values which we can ensure floats are padded to two decimal places in tabular display mode
- Add `--json` option to `show platform psustatus` which in turn adds the `-j` flag to the underlying `psushow` call
- Add unit tests for `psushow` in psushow_test.py
- Add more unit tests for `show platform psustatus` and move to show_platform_test.py
yxieca pushed a commit that referenced this pull request Mar 3, 2021
#1416)

- Enhance `psushow -s` output, adding columns to display PSU Model, Serial, Voltage, Current and Power
- Add `-j/--json` option to display output in JSON format
- Update mock State DB PSU_INFO table to provide values which we can ensure floats are padded to two decimal places in tabular display mode
- Add `--json` option to `show platform psustatus` which in turn adds the `-j` flag to the underlying `psushow` call
- Add unit tests for `psushow` in psushow_test.py
- Add more unit tests for `show platform psustatus` and move to show_platform_test.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants