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

[config] Add 'feature' subcommand #746

Merged
merged 9 commits into from
Nov 27, 2019
24 changes: 24 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,30 @@ def delete(ctx):
sflow_tbl['global'].pop('agent_id')
config_db.set_entry('SFLOW', 'global', sflow_tbl['global'])

#
# 'feature_status' command ('config feature name state')
#
@config.command('feature')
@click.pass_context
pra-moh marked this conversation as resolved.
Show resolved Hide resolved
@click.argument('name', metavar='<feature-name>', required=True)
@click.argument('state', metavar='<enabled/disabled>', default='disabled', required=True, type=click.Choice(["enabled", "disabled"]))
jleveque marked this conversation as resolved.
Show resolved Hide resolved
def feature_status(ctx,name,state):
""" Configure status of feature"""
config_db = ConfigDBConnector()
config_db.connect()
status_data = config_db.get_entry('FEATURE', name)

if not name:
jleveque marked this conversation as resolved.
Show resolved Hide resolved
click.echo("Invalid feature name")
return
if not status_data:
pra-moh marked this conversation as resolved.
Show resolved Hide resolved
click.echo("{} feature doesnt exist".format(name))
pra-moh marked this conversation as resolved.
Show resolved Hide resolved
return
if not state:
jleveque marked this conversation as resolved.
Show resolved Hide resolved
click.echo("Empty state value")
pra-moh marked this conversation as resolved.
Show resolved Hide resolved
return

config_db.mod_entry('FEATURE', name,{'status': state})
jleveque marked this conversation as resolved.
Show resolved Hide resolved

if __name__ == '__main__':
config()