Enhancement of 'show' commands and addition of 'debug', and 'undebug'…#113
Enhancement of 'show' commands and addition of 'debug', and 'undebug'…#113jleveque merged 3 commits intosonic-net:masterfrom
Conversation
… hierarchy in CLI utilities
> added script to get interface status.
> added few subcommands under "show interfaces" command.
> enhanced "show process" to get all processes sorted by CPU & memory.
> added "show services" command to get all the running process from all the dockers.
> added "show vlan" command.
> enhanced multiple subcommands under
> added debug', and 'undebug' CLI utilities.
debug/main.py
Outdated
|
|
||
|
|
||
| # Add 'bgp' group to both the root 'cli' group and the 'ip' subgroup | ||
| cli.add_command(bgp) |
There was a problem hiding this comment.
This is unnecessary, as bgp is added to the cli group only, and this is done via the decorator on line 110.
show/main.py
Outdated
| # 'summary' subcommand ("show interfaces summary") | ||
| @interfaces.command() | ||
| # 'summary' subcommand ("show interfaces summary") -- called if no subcommands are passed | ||
| @interfaces.command(default=True) |
There was a problem hiding this comment.
I am not a fan of the DefaultGroup we have implemented using Click, because when a group has a default command, it does not allow for using Tab to show available subcommands.
We either need to eliminate default commands for groups altogether, or try to fix our DefaultGroup to allow the Tab functionality to work.
There was a problem hiding this comment.
For the time being, will get rid of this 'default' behavior. Agree that 'tabs' is a nice-to-have feature.
scripts/interface_stat
Outdated
| a = self.db.keys(self.db.APPL_DB) | ||
| #print(a) | ||
| tables = self.db.keys(self.db.APPL_DB, "PORT_TABLE:*") | ||
| i={} |
There was a problem hiding this comment.
Add spaces around = for consistent style.
debug/main.py
Outdated
|
|
||
|
|
||
| # Add 'bgp' group to both the root 'cli' group and the 'ip' subgroup | ||
| cli.add_command(bgp) |
There was a problem hiding this comment.
This line is unnecessary, as bgp is only added to the cli group, and this is already done via the decorator on line 110.
debug/main.py
Outdated
|
|
||
| @click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) | ||
| def cli(): | ||
| """SONiC command line - 'debug' command""" |
There was a problem hiding this comment.
Replace tabs with spaces everywhere they occur within the file for consistent style
There was a problem hiding this comment.
yes, just noticed the entire file was lacking indentation consistency.
show/main.py
Outdated
| command="free -m" | ||
| run_command(command) | ||
|
|
||
| @click.group(cls=AliasedGroup, default_if_no_args=False) |
There was a problem hiding this comment.
Change to @cli.group(cls=AliasedGroup, default_if_no_args=False) and remove cli.add_command(vlan) on line 678.
show/main.py
Outdated
| @click.argument('interfacename', required=False) | ||
| def default(interfacename): | ||
| if interfacename is not None: | ||
| command = "sudo sfputil -p {}".format(interfacename) |
There was a problem hiding this comment.
sfputil syntax changed recently. Please update all sfputil calls here and below to new syntax.
undebug/main.py
Outdated
|
|
||
| @click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) | ||
| def cli(): | ||
| """SONiC command line - 'undebug' command""" |
There was a problem hiding this comment.
Replace tabs with spaces everywhere they occur within the file for consistent style
undebug/main.py
Outdated
|
|
||
|
|
||
| # Add 'bgp' group to both the root 'cli' group and the 'ip' subgroup | ||
| cli.add_command(bgp) |
There was a problem hiding this comment.
This line is unnecessary, as bgp is only added to the cli group, and this is already done via the decorator on line 108.
b540049 to
7398670
Compare
undebug/main.py
Outdated
| run_command(command) | ||
|
|
||
| if __name__ == '__main__': | ||
| cli() |
* msft_github/master: Enhancement of 'show' commands and addition of 'debug', and 'undebug'… (sonic-net#113) CLI support for Layer 2 MAC/FDB show (sonic-net#106) [show]: Add 'show interfaces alias' command to display port name/alias mapping (sonic-net#107) Add 'ipv6' group along with 'bgp' and 'route' subcommands; Remove duplicate commands ('bgp,' 'route') from under root group (sonic-net#102) [generate_dump]: Skip the sparse file /var/log/lastlog (sonic-net#104) Added syncd SAI dump to sysdump script (sonic-net#89) Adapt to new minigraph_parser schema (sonic-net#103) [core dump] remove number of parameter assumption from script coredump-compress [FastReboot]: Update FR to make it working with 1.0.3 (sonic-net#95)
sonic-net#113) ```<br>* 99a0a1ec - (HEAD -> 202412) Merge branch '202411' of https://github.com/sonic-net/sonic-utilities into 202412 (2025-02-11) [Sonic Automation] * 8ceba38 - (origin/202411) [QOS] Skip showing unnecessary warning message (sonic-net#3762) (2025-02-11) [mssonicbld] * 04b60e2 - Fix call for spanning-tree commands in dump script (sonic-net#3752) (2025-02-07) [mssonicbld] * bbe29ae - [show][interface] Add changes for show interface errors command (sonic-net#3749) (2025-02-04) [mssonicbld]<br>```
… hierarchy in CLI utilities