Skip to content

Conversation

@Gnanapriya27
Copy link

Summary
Fixed show storm-control interface command failure with error message "missing 2 required positional arguments: 'namespace' and 'display'".

Type of change
Bug fix - Corrected parameter handling in Click command structure

Approach
The "interface" subcommand function expected "namespace" parameter in its signature, but these were defined as options on the parent "storm_control" group. Click doesn't automatically pass parent group options to subcommands.

Solution:
How did you do it?
Used Click's context system to access parent parameters: Added @click.pass_context decorator
Modified function to accept ctx as parameter

What is the motivation for this PR?
Users couldn't execute show storm-control interface <interface_name> command due to TypeError, blocking storm control troubleshooting functionality.

How to verify it

Added a new UT case for verifying storm control show per interface

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

root@sonic:/home/admin# show storm-control interface Ethernet184
Traceback (most recent call last):
File "/usr/local/bin/show", line 8, in
sys.exit(cli())
^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: interface() missing 2 required positional arguments: 'namespace' and 'display'
root@sonic:/home/admin#

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

admin@str-marvell-tl10-01:~$ show storm-control interface Ethernet0
+------------------+--------------+---------------+
| Interface Name | Storm Type | Rate (kbps) |
+==================+==============+===============+
| Ethernet0 | broadcast | 24000 |
+------------------+--------------+---------------+

Any platform specific information:
NA

Summary
Fixed show storm-control interface command failure with error message "missing 2 required positional arguments: 'namespace' and 'display'".

Type of change
Bug fix - Corrected parameter handling in Click command structure

Approach
The "interface" subcommand function expected "namespace" parameter in its signature, but these were defined as options on the parent "storm_control" group. Click doesn't automatically pass parent group options to subcommands.

Solution:
How did you do it?
Used Click's context system to access parent parameters:
Added @click.pass_context decorator
Modified function to accept ctx as parameter

What is the motivation for this PR?
Users couldn't execute show storm-control interface <interface_name> command due to TypeError, blocking storm control troubleshooting functionality.

Any platform specific information:
NA

Signed-off-by: Gnanapriya Sethuramarajan <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants