-
Notifications
You must be signed in to change notification settings - Fork 740
Added json support intfutil #3906
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
Added json support intfutil #3906
Conversation
Added json support for intfutil
@qiluo-msft can you please help to review? Thanks. |
There was a problem hiding this 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 adds JSON output support to the intfutil
script for multiple commands (status
, description
, autoneg
, tpid
, link_training
, fec
).
- Introduces
--json
(-j
) CLI flag and importstable_as_json
- Updates each
Intf*
class constructor to acceptuse_json
and conditionally print JSON - Propagates the new flag through
main()
when instantiating and displaying results
Comments suppressed due to low confidence (3)
doc/Command-Reference.md:1
- Update the Command Line Reference Guide to document the new
-j/--json
flag forintfutil
.
<Add section for `intfutil -j`>
scripts/intfutil:900
- Add or update unit tests in the
tests/
directory to cover the new JSON output path (--json
flag) and validate the structure returned bytable_as_json
.
parser.add_argument('-j', '--json', action='store_true', help='Display in JSON format')
scripts/intfutil:455
- [nitpick] The repeated
if self.use_json: print(table_as_json(...)) else: print(tabulate(...))
pattern appears in multiple methods; consider extracting a helper function to reduce duplication and improve maintainability.
def display_intf_status(self):
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Cherry-pick PR to msft-202412: Azure/sonic-utilities.msft#220 |
Cherry-pick PR to 202505: #4023 |
What I did
Added json output supoort for
How I did it
How to verify it
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)