Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
update ctx.fail in sflow
  • Loading branch information
651477787 authored Apr 28, 2023
1 parent 7e24463 commit 9dd32cc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6476,7 +6476,7 @@ def polling_int(ctx, interval):
"""Set polling-interval for counter-sampling (0 to disable)"""
if ADHOC_VALIDATION:
if interval not in range(5, 301) and interval != 0:
click.echo("Polling interval must be between 5-300 (0 to disable)")
ctx.fail("Polling interval must be between 5-300 (0 to disable)")

config_db = ValidatedConfigDBConnector(ctx.obj['db'])
sflow_tbl = config_db.get_table('SFLOW')
Expand Down Expand Up @@ -6513,8 +6513,7 @@ def enable(ctx, ifname):
config_db = ValidatedConfigDBConnector(ctx.obj['db'])
if ADHOC_VALIDATION:
if not interface_name_is_valid(config_db, ifname) and ifname != 'all':
click.echo("Invalid interface name")
return
ctx.fail("Invalid interface name")

intf_dict = config_db.get_table('SFLOW_SESSION')

Expand All @@ -6540,8 +6539,7 @@ def disable(ctx, ifname):
config_db = ValidatedConfigDBConnector(ctx.obj['db'])
if ADHOC_VALIDATION:
if not interface_name_is_valid(config_db, ifname) and ifname != 'all':
click.echo("Invalid interface name")
return
ctx.fail("Invalid interface name")

intf_dict = config_db.get_table('SFLOW_SESSION')

Expand Down Expand Up @@ -6569,11 +6567,9 @@ def sample_rate(ctx, ifname, rate):
config_db = ValidatedConfigDBConnector(ctx.obj['db'])
if ADHOC_VALIDATION:
if not interface_name_is_valid(config_db, ifname) and ifname != 'all':
click.echo('Invalid interface name')
return
ctx.fail('Invalid interface name')
if not is_valid_sample_rate(rate) and rate != 'default':
click.echo('Error: Sample rate must be between 256 and 8388608 or default')
return
ctx.fail('Sample rate must be between 256 and 8388608 or default')

sess_dict = config_db.get_table('SFLOW_SESSION')

Expand Down

0 comments on commit 9dd32cc

Please sign in to comment.