Skip to content

Commit 53f8904

Browse files
authored
[config] Add subcommand to configure the status of auto-restart feature for each container (#801)
1 parent bb10686 commit 53f8904

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

config/main.py

+36
Original file line numberDiff line numberDiff line change
@@ -2468,5 +2468,41 @@ def feature_status(name, state):
24682468

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

2471+
#
2472+
# 'container' group ('config container ...')
2473+
#
2474+
@config.group(name='container', invoke_without_command=False)
2475+
def container():
2476+
"""Modify configuration of containers"""
2477+
pass
2478+
2479+
#
2480+
# 'feature' group ('config container feature ...')
2481+
#
2482+
@container.group(name='feature', invoke_without_command=False)
2483+
def feature():
2484+
"""Modify configuration of container features"""
2485+
pass
2486+
2487+
#
2488+
# 'autorestart' subcommand ('config container feature autorestart ...')
2489+
#
2490+
@feature.command(name='autorestart', short_help="Configure the status of autorestart feature for specific container")
2491+
@click.argument('container_name', metavar='<container_name>', required=True)
2492+
@click.argument('autorestart_status', metavar='<autorestart_status>', required=True, type=click.Choice(["enabled", "disabled"]))
2493+
def autorestart(container_name, autorestart_status):
2494+
config_db = ConfigDBConnector()
2495+
config_db.connect()
2496+
container_feature_table = config_db.get_table('CONTAINER_FEATURE')
2497+
if not container_feature_table:
2498+
click.echo("Unable to retrieve container feature table from Config DB.")
2499+
return
2500+
2501+
if not container_feature_table.has_key(container_name):
2502+
click.echo("Unable to retrieve features for container '{}'".format(container_name))
2503+
return
2504+
2505+
config_db.mod_entry('CONTAINER_FEATURE', container_name, {'auto_restart': autorestart_status})
2506+
24712507
if __name__ == '__main__':
24722508
config()

0 commit comments

Comments
 (0)