Skip to content
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

[sflow][implement][polling interval]return code use ctx.fail replace click.echo, when exec command it should return true or false #2811

Closed
wants to merge 6 commits into from

Conversation

651477787
Copy link

update ctx.fail in sflow

What I did

fix sflow part
when add sflow, interval is out of range, it will return fail and give info of range

How I did it

use ctx.fail replace the click.echo

How to verify it

verifty it in product

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

admin@sonic:$ sudo config feature state sflow enabled
admin@sonic:
$ sudo config sflow enable
admin@sonic:$ sudo config sflow polling-interval 4
Polling interval must be between 5-300 (0 to disable)
admin@sonic:
$ $?
-bash: 0: command not found

admin@sonic:~$ show sflow

sFlow Global Information:
sFlow Admin State: up
sFlow Polling Interval: 60
sFlow AgentID: Loopback1

2 Collectors configured:
Name: 1 IP addr: 10.17.0.2 UDP port: 65535 VRF: mgmt
Name: 2 IP addr: 2003::200 UDP port: 6343 VRF: default
admin@sonic:~$

admin@sonic:$ sudo config sflow interface sample-rate Ethernet240 255
Error: Sample rate must be between 256 and 8388608
admin@sonic:
$ $?
-bash: 0: command not found
admin@sonic:~$

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

**admin@sonic:~$ sudo config sflow polling-interval 4
Usage: config sflow polling-interval [OPTIONS] <polling_interval>
Try "config sflow polling-interval -h" for help.

Error: Polling interval must be between 5-300 (0 to disable)
admin@sonic:$ $?
-bash: 2: command not found**
admin@sonic:
$ show sflow

sFlow Global Information:
sFlow Admin State: up
sFlow Polling Interval: 60
sFlow AgentID: Loopback1

2 Collectors configured:
Name: 1 IP addr: 10.17.0.2 UDP port: 65535 VRF: mgmt
Name: 2 IP addr: 2003::200 UDP port: 6343 VRF: default
admin@sonic:~$

**admin@sonic:~$ sudo config sflow interface sample-rate Ethernet240 255
Usage: config sflow interface sample-rate [OPTIONS] <interface_name>
<sample_rate>
Try "config sflow interface sample-rate -h" for help.

Error: Sample rate must be between 256 and 8388608
admin@sonic:$ $?
-bash: 2: command not found**
admin@sonic:
$

update ctx.fail in sflow
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 28, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@651477787
Copy link
Author

update ctx.fail in sflow

What I did
fix sflow part
when add sflow, interval is out of range, it will return fail and give info of range

How I did it
use ctx.fail replace the click.echo

How to verify it
verifty it in product

Previous command output (if the output of a command-line utility has changed)
admin@sonic:$ sudo config feature state sflow enabled
admin@sonic:$ sudo config sflow enable
admin@sonic:$ sudo config sflow polling-interval 4
Polling interval must be between 5-300 (0 to disable)
admin@sonic:$ $?
-bash: 0: command not found

admin@sonic:~$ show sflow

sFlow Global Information:
sFlow Admin State: up
sFlow Polling Interval: 60
sFlow AgentID: Loopback1

2 Collectors configured:
Name: 1 IP addr: 10.17.0.2 UDP port: 65535 VRF: mgmt
Name: 2 IP addr: 2003::200 UDP port: 6343 VRF: default
admin@sonic:~$

admin@sonic:$ sudo config sflow interface sample-rate Ethernet240 255
Error: Sample rate must be between 256 and 8388608
admin@sonic:$ $?
-bash: 0: command not found
admin@sonic:~$

New command output (if the output of a command-line utility has changed)
**admin@sonic:~$ sudo config sflow polling-interval 4
Usage: config sflow polling-interval [OPTIONS] <polling_interval>
Try "config sflow polling-interval -h" for help.

Error: Polling interval must be between 5-300 (0 to disable)
admin@sonic:$ $?
-bash: 2: command not found**
admin@sonic:$ show sflow

sFlow Global Information:
sFlow Admin State: up
sFlow Polling Interval: 60
sFlow AgentID: Loopback1

2 Collectors configured:
Name: 1 IP addr: 10.17.0.2 UDP port: 65535 VRF: mgmt
Name: 2 IP addr: 2003::200 UDP port: 6343 VRF: default
admin@sonic:~$

**admin@sonic:~$ sudo config sflow interface sample-rate Ethernet240 255
Usage: config sflow interface sample-rate [OPTIONS] <interface_name>
<sample_rate>
Try "config sflow interface sample-rate -h" for help.

Error: Sample rate must be between 256 and 8388608
admin@sonic:$ $?
-bash: 2: command not found**
admin@sonic:$

@651477787 651477787 changed the title Update main.py [sflow] use ctx.fail replace click.echo, when exec command it should return true or false May 4, 2023
@651477787 651477787 changed the title [sflow] use ctx.fail replace click.echo, when exec command it should return true or false [sflow][implement return code] use ctx.fail replace click.echo, when exec command it should return true or false May 4, 2023
@651477787 651477787 changed the title [sflow][implement return code] use ctx.fail replace click.echo, when exec command it should return true or false [sflow][implement][polling interval][sample rate]return code use ctx.fail replace click.echo, when exec command it should return true or false May 5, 2023
@651477787 651477787 changed the title [sflow][implement][polling interval][sample rate]return code use ctx.fail replace click.echo, when exec command it should return true or false [sflow][implement][polling interval]return code use ctx.fail replace click.echo, when exec command it should return true or false May 5, 2023
@651477787
Copy link
Author

update ctx.fail in sflow

What I did
fix sflow part
when add sflow, interval is out of range, it will return fail and give info of range

How I did it
use ctx.fail replace the click.echo

How to verify it
verifty it in product

Previous command output (if the output of a command-line utility has changed)
admin@sonic:$ sudo config feature state sflow enabled
admin@sonic:$ sudo config sflow enable
admin@sonic:$ sudo config sflow polling-interval 4
Polling interval must be between 5-300 (0 to disable)
admin@sonic:$ $?
-bash: 0: command not found

admin@sonic:~$ show sflow

sFlow Global Information:
sFlow Admin State: up
sFlow Polling Interval: 60
sFlow AgentID: Loopback1

2 Collectors configured:
Name: 1 IP addr: 10.17.0.2 UDP port: 65535 VRF: mgmt
Name: 2 IP addr: 2003::200 UDP port: 6343 VRF: default
admin@sonic:~$

admin@sonic:$ sudo config sflow interface sample-rate Ethernet240 255
Error: Sample rate must be between 256 and 8388608
admin@sonic:$ $?
-bash: 0: command not found
admin@sonic:~$

New command output (if the output of a command-line utility has changed)
**admin@sonic:~$ sudo config sflow polling-interval 4
Usage: config sflow polling-interval [OPTIONS] <polling_interval>
Try "config sflow polling-interval -h" for help.

Error: Polling interval must be between 5-300 (0 to disable)
admin@sonic:$ $?
-bash: 2: command not found**
admin@sonic:$ show sflow

@651477787
Copy link
Author

Can this be reviewed?

@651477787
Copy link
Author

Can anyone help review, thx.

@maipbui
Copy link
Contributor

maipbui commented Jun 29, 2023

@651477787 Please merge latest master code to trigger Semgrep.

@651477787
Copy link
Author

help me , review it. thanks

@maipbui
Copy link
Contributor

maipbui commented Jul 5, 2023

help me , review it. thanks

looks like it is fixed in #2847?

@maipbui maipbui closed this Jul 11, 2023
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