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

[show] Add subcommand to display the status of auto-restart feature for each container #798

Merged
merged 17 commits into from
Feb 4, 2020
Merged
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2806,5 +2806,40 @@ def features():
body.append([key, status_data[key]['status']])
click.echo(tabulate(body, header))

#
# 'container' group (show container ...)
#
@cli.group(name='container', invoke_without_command=False)
def container():
"""Show container"""
pass

#
# 'feature' group (show container feature ...)
#
@container.group(name='feature', invoke_without_command=False)
def feature():
"""Show container feature"""
pass

#
# 'autorestart' subcommand (show container feature autorestart)
#
@feature.command('autorestart', short_help="Show whether the auto-restart feature for container(s) is enabled or disabled")
@click.argument('container_name', required=False)
def autorestart(container_name):
config_db = ConfigDBConnector()
config_db.connect()
header = ['ContainerName', 'Status']
jleveque marked this conversation as resolved.
Show resolved Hide resolved
body = []
container_feature_table = config_db.get_table('CONTAINER_FEATURE')
if container_name:
if container_feature_table and container_feature_table.has_key(container-name):
body.append([container_name, container_feature_table[container_name]['auto_restart']])
else:
for name in container_feature_table.keys():
body.append([name, container_feature_table[name]['auto_restart']])
click.echo(tabulate(body, header))

if __name__ == '__main__':
cli()