Skip to content

[pfcwd] Configuring to 'stop' ports #1350

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,12 +1567,17 @@ def start(action, restoration_time, ports, detection_time, verbose):

@pfcwd.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def stop(verbose):
""" Stop PFC watchdog """
@click.argument('ports', nargs=-1)
def stop(verbose, ports):
""" Stop PFC watchdog """

cmd = "pfcwd stop"

cmd = "pfcwd stop"
if ports:
ports = set(ports)
cmd += " {}".format(' '.join(ports))

clicommon.run_command(cmd, display_cmd=verbose)
clicommon.run_command(cmd, display_cmd=verbose)

@pfcwd.command()
@click.option('--verbose', is_flag=True, help="Enable verbose output")
Expand Down
3 changes: 2 additions & 1 deletion doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5325,7 +5325,8 @@ This command stops PFC Watchdog

- Usage:
```
config pfcwd stop
config pfcwd stop Ethernet0
config pfcwd stop all
```

**config pfcwd interval \<interval_in_ms\>**
Expand Down
8 changes: 5 additions & 3 deletions pfcwd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ def __init__(
):
self.db = None
self.config_db = None
self.multi_asic = multi_asic_util.MultiAsic(
display, namespace, db
)
self.multi_asic = multi_asic_util.MultiAsic(display, namespace, db)
self.table = []
self.all_ports = []

Expand Down Expand Up @@ -339,6 +337,10 @@ def stop(self, ports):
)

if len(ports) == 0:
click.echo("Ports not selected")
return

if 'all' in ports:
Copy link
Collaborator

Choose a reason for hiding this comment

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

should use 'all' == ports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Such logic with the "in" statement should handle the case: "config pfcwd stop Ethernet0 Ethernet1 all" and remove all ports despite the first two arguments

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to support this kind of command: "config pfcwd stop Ethernet0 Ethernet1 all" seems strange to me.

ports = all_ports

for port in ports:
Expand Down