Skip to content

Add lpmode show and firmware show commands as aliases for show#4517

Open
maheeppartap-nexthop wants to merge 2 commits into
sonic-net:masterfrom
nexthop-ai:add-lpmode-show-and-firmware-show
Open

Add lpmode show and firmware show commands as aliases for show#4517
maheeppartap-nexthop wants to merge 2 commits into
sonic-net:masterfrom
nexthop-ai:add-lpmode-show-and-firmware-show

Conversation

@maheeppartap-nexthop
Copy link
Copy Markdown
Contributor

@maheeppartap-nexthop maheeppartap-nexthop commented May 5, 2026

closes #4518

What I did

To view the LPMode state of a xcvr (or all xcvrs), the user has to run "sfputil show lpmode", all while "sfputil lpmode" is already existing as a subcommand. Same for firmware. This is very unintuitive.

This PR adds a new subcommand under both lpmode and firmware to view the respective fields. Internally, it just reroutes to show lpmode/fwversion.

Note that the help commands are also updated. The sfputil show command will still be the single source of truth. If for whatever reason, a new flag/param is added to the sfputil show lpmode/fwversion command, it will be picked up automatically by sfputil lpmode/firmware show.

How I did it

I added 2 new subcommands, linking them to the objects for show fwversion and show lpmode.

How to verify it

admin@sonic:~$ sudo sfputil firmware show Ethernet4
Image A Version: 61.23.32
Image B Version: 61.24.16
Factory Image Version: 0.0.0
Running Image: B
Committed Image: B
Active Firmware: 61.24.16
Inactive Firmware: 61.23.32

and

admin@sonic:~$ sudo sfputil lpmode show
Port         Low-power Mode
-----------  ----------------
Ethernet0    Off
Ethernet4    Off
Ethernet8    Off
Ethernet12   Off
Ethernet16   Off
Ethernet20   Off
Ethernet24   Off
Ethernet28   Off

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

admin@sonic:~$ sudo sfputil firmware show Ethernet4
Usage: sfputil firmware [OPTIONS] COMMAND [ARGS]...
Try 'sfputil firmware --help' for help.

Error: No such command 'show'.

and

admin@sonic:~$ sudo sfputil lpmode show Ethernet4
Usage: sfputil lpmode [OPTIONS] COMMAND [ARGS]...
Try 'sfputil lpmode --help' for help.

Error: No such command 'show'.

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

admin@sonic:~$ sudo sfputil firmware show Ethernet4
Image A Version: 61.23.32
Image B Version: 61.24.16
Factory Image Version: 0.0.0
Running Image: B
Committed Image: B
Active Firmware: 61.24.16
Inactive Firmware: 61.23.32

and

admin@sonic:~$ sudo sfputil lpmode show
Port         Low-power Mode
-----------  ----------------
Ethernet0    Off
Ethernet4    Off
Ethernet8    Off
Ethernet12   Off
Ethernet16   Off
Ethernet20   Off
Ethernet24   Off
Ethernet28   Off

Signed-off-by: maheeppartap-nexthop <maheeppartap@nexthop.ai>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves sfputil CLI discoverability by adding show aliases under the existing mutating command groups, so users can inspect LPMode and firmware versions via sfputil lpmode show and sfputil firmware show (reusing the existing sfputil show lpmode / sfputil show fwversion implementations).

Changes:

  • Add sfputil lpmode show as an alias of sfputil show lpmode.
  • Add sfputil firmware show as an alias of sfputil show fwversion.
  • Add unit tests covering the new alias commands (including RJ45 behavior for firmware).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
sfputil/main.py Registers show aliases under lpmode and firmware Click groups by reusing existing show subcommands.
tests/sfputil_test.py Adds pytest coverage to ensure the new alias commands execute and match existing behaviors.

Comment thread sfputil/main.py
@prgeor
Copy link
Copy Markdown
Contributor

prgeor commented May 13, 2026

Signed-off-by: Maheeppartap Singh <maheeppartap@nexthop.ai>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@maheeppartap-nexthop
Copy link
Copy Markdown
Contributor Author

maheeppartap-nexthop commented May 13, 2026

@prgeor I have updated the docs.

The docs did not have any lpmode related docs (sfputil lpmode on/off, sfputil show lpmode), so I have added those as well as part of this.

@mihirpat1
Copy link
Copy Markdown
Contributor

@maheeppartap-nexthop Can you please attach the output of sfputil lpmode show --help to the PR description?

Comment thread doc/Command-Reference.md

- Usage:
```
sfputil firmware show PORT_NAME
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sfputil firmware show PORT_NAME
sfputil lpmode show [-p <port_name>]

Copy link
Copy Markdown
Contributor Author

@maheeppartap-nexthop maheeppartap-nexthop May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean sfputil firmware show [-p <port_name>]?

If so, this command is just meant to be an alias command, and meant to mirror exactly what the sfputil show firmware command's API says by design, so we don't have to change the sfputil firmware show if sfputil show fwversion changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sfputil: add lpmode show and firmware show as aliases for show lpmode / show fwversion

5 participants