Skip to content

Commit

Permalink
Respond to community feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
daall committed Nov 5, 2019
1 parent 0cdda0d commit 3597154
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 113 deletions.
2 changes: 1 addition & 1 deletion clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def pfccounters():
run_command(command)

@cli.command()
def dropcounters():
def dropcounter():
"""Clear drop counters"""
command = "dropstat -c clear"
run_command(command)
Expand Down
47 changes: 33 additions & 14 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,60 +1591,79 @@ def incremental(file_name):
command = "acl-loader update incremental {}".format(file_name)
run_command(command)


#
# 'drops' group ('config drops ...')
# 'dropcounter' group ('config dropcounter ...')
#

@config.group()
def drops():
def dropcounter():
"""Drop counter related configuration tasks"""
pass


#
# 'init' subcommand ('config drops init')
# 'initialize_counter' subcommand ('config dropcounter initialize_counter')
#
@drops.command()
@dropcounter.command()
@click.argument("counter_name", type=str, required=True)
@click.argument("counter_type", type=str, required=True)
@click.argument("reasons", type=str, required=True)
@click.option("-a", "--alias", type=str, help="Alias for this counter")
@click.option("-g", "--group", type=str, help="Group for this counter")
@click.option("-d", "--desc", type=str, help="Description for this counter")
@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output")
def init(counter_name, alias, group, counter_type, desc, reasons, verbose):
def initialize_counter(counter_name, alias, group, counter_type, desc, reasons, verbose):
"""Initialize a new drop counter"""
command = "dropconfig -c install -n '{}' -t '{}' -r '{}'".format(counter_name, counter_type, reasons)
if alias: command += " -a '{}'".format(alias)
if group: command += " -g '{}'".format(group)
if desc: command += " -d '{}'".format(desc)
if alias:
command += " -a '{}'".format(alias)
if group:
command += " -g '{}'".format(group)
if desc:
command += " -d '{}'".format(desc)

run_command(command, display_cmd=verbose)

@drops.command()

#
# 'delete_counter' subcommand ('config dropcounter delete_counter')
#
@dropcounter.command()
@click.argument("counter_name", type=str, required=True)
@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output")
def delete(counter_name, verbose):
def delete_counter(counter_name, verbose):
"""Delete an existing drop counter"""
command = "dropconfig -c uninstall -n {}".format(counter_name)
run_command(command, display_cmd=verbose)

@drops.command()

#
# 'add_reason' subcommand ('config dropcounter add_reason')
#
@dropcounter.command()
@click.argument("counter_name", type=str, required=True)
@click.argument("reasons", type=str, required=True)
@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output")
def add(counter_name, reasons, verbose):
def add_reasons(counter_name, reasons, verbose):
"""Add reasons to an existing drop counter"""
command = "dropconfig -c add -n {} -r {}".format(counter_name, reasons)
run_command(command, display_cmd=verbose)

@drops.command()

#
# 'remove_reason' subcommand ('config dropcounter remove_reason')
#
@dropcounter.command()
@click.argument("counter_name", type=str, required=True)
@click.argument("reasons", type=str, required=True)
@click.option('-v', '--verbose', is_flag=True, help="Enable verbose output")
def remove(counter_name, reasons, verbose):
def remove_reasons(counter_name, reasons, verbose):
"""Remove reasons from an existing drop counter"""
command = "dropconfig -c remove -n {} -r {}".format(counter_name, reasons)
run_command(command, display_cmd=verbose)


#
# 'ecn' command ('config ecn ...')
#
Expand Down
Loading

0 comments on commit 3597154

Please sign in to comment.