[show] Add 'show p4-table' command#2773
Conversation
|
@svshah-intel can you please review this PR? |
- What I did Add 'show p4-table' command to the CLI. This is a new command to display P4RT tables used by PINS (P4 Integrated Network Stack). - How I did it Add the command in show/p4_table.py to output the P4RT table entries in the redis application database. - How to verify it Run unit tests, manually test - Previous command output (if the output of a command-line utility has changed) None - New command output (if the output of a command-line utility has changed) See command reference Signed-off-by: Roy Yi <royyi@google.com>
|
@svshah-intel all test checks are passing now after the rebase. Can you re-approve the PR? Thanks. |
|
@qiluo-msft Could you please review this PR? Thanks. |
|
@qiluo-msft Friendly reminder to review this CL, so we can get it merged. Thanks! |
|
@royyi8 Please merge latest master code to trigger Semgrep. |
show/p4_table.py
Outdated
| @click.option('--verbose', is_flag=True, help='Enable verbose output') | ||
| def p4_table(table_name, verbose): | ||
| """Display all P4RT tables""" | ||
| appDB = SonicV2Connector(host='127.0.0.1') |
There was a problem hiding this comment.
I updated the code to use unix socket.
show/p4_table.py
Outdated
| """Display all P4RT tables""" | ||
| appDB = SonicV2Connector(host='127.0.0.1') | ||
|
|
||
| if appDB is None: |
There was a problem hiding this comment.
I changed the indentation to 4 spaces.
show/p4_table.py
Outdated
| if table_name is None: | ||
| table_name = '' | ||
|
|
||
| keys = appDB.keys(db, f'P4RT_TABLE:{table_name}*') |
There was a problem hiding this comment.
: as separator is defined in database_config.json
There was a problem hiding this comment.
Are you referring to Table class in swsscommon? This class takes swsscommon.DBConnector as an argument rather than swsscommon.SonicV2Connector, so it appears that I cannot use the provided mock dbconnector in my unit test if I use this class.
Will it suffice to match on the separator defined in database_config.json?
| "BGP_PROFILE_TABLE:FROM_SDN_SLB_ROUTES": { | ||
| "community_id" : "1234:1235" | ||
| }, | ||
| "P4RT_TABLE:ACL_TABLE_DEFINITION_TABLE:ACL_ACL_PRE_INGRESS_TABLE": { |
There was a problem hiding this comment.
Could you please clarify what needs to be reformatted? I run the json file through a json beautifier and I see the same result.
There was a problem hiding this comment.
I mean the json indentation. I see tabs/spaces mixed.
There was a problem hiding this comment.
Thanks. I fixed the indentation to use spaces.
Commit 6322389 ("[show] Add 'show p4-table' command (sonic-net#2773)") added a table of contents entry for the "PINS Show commands" but the link target didn't match the generated anchor so the TOC entry didn't render correctly. Update it to use the correct link target so the TOC entry works as intended. Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
What I did
Add 'show p4-table' command to the CLI. This is a new command to display P4RT tables used by PINS (P4 Integrated Network Stack).
How I did it
Add the command in show/p4_table.py to output the P4RT table entries in the Redis application database.
How to verify it
Run unit tests, manually test
Previous command output (if the output of a command-line utility has changed)
None
New command output (if the output of a command-line utility has changed)
See command reference