Skip to content

Commit

Permalink
[config] Add 'feature' subcommand (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
pra-moh authored and jleveque committed Nov 27, 2019
1 parent 0f43c16 commit 0816948
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,23 @@ def delete(ctx):
sflow_tbl['global'].pop('agent_id')
config_db.set_entry('SFLOW', 'global', sflow_tbl['global'])

#
# 'feature' command ('config feature name state')
#
@config.command('feature')
@click.argument('name', metavar='<feature-name>', required=True)
@click.argument('state', metavar='<feature-state>', required=True, type=click.Choice(["enabled", "disabled"]))
def feature_status(name, state):
""" Configure status of feature"""
config_db = ConfigDBConnector()
config_db.connect()
status_data = config_db.get_entry('FEATURE', name)

if not status_data:
click.echo(" Feature '{}' doesn't exist".format(name))
return

config_db.mod_entry('FEATURE', name, {'status': state})

if __name__ == '__main__':
config()

0 comments on commit 0816948

Please sign in to comment.