Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Added option to stop all nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
frankcorneliusmartin committed Mar 26, 2020
1 parent 563f726 commit ebfbb0d
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions vantage6/cli/node.py
Expand Up @@ -396,7 +396,10 @@ def cli_node_start(name, config, environment, system_folders, develop, tag):
flag_value=False,
default=DEFAULT_NODE_SYSTEM_FOLDERS
)
def cli_node_stop(name, system_folders):
@click.option('--all', 'all_nodes',
flag_value=True
)
def cli_node_stop(name, system_folders, all_nodes):
"""Stop a running container. """

client = docker.from_env()
Expand All @@ -410,20 +413,27 @@ def cli_node_stop(name, system_folders):
return

running_node_names = [node.name for node in running_nodes]
if not name:
name = q.select("Select the node you wish to stop:",
choices=running_node_names).ask()

if all_nodes:
for name in running_node_names:
container = client.containers.get(name)
container.kill()
info(f"Stopped the {Fore.GREEN}{name}{Style.RESET_ALL} Node.")
else:
if not name:
name = q.select("Select the node you wish to stop:",
choices=running_node_names).ask()
else:

post_fix = "system" if system_folders else "user"
name = f"{APPNAME}-{name}-{post_fix}"
post_fix = "system" if system_folders else "user"
name = f"{APPNAME}-{name}-{post_fix}"

if name in running_node_names:
container = client.containers.get(name)
container.kill()
info(f"Stopped the {Fore.GREEN}{name}{Style.RESET_ALL} Node.")
else:
error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running?")
if name in running_node_names:
container = client.containers.get(name)
container.kill()
info(f"Stopped the {Fore.GREEN}{name}{Style.RESET_ALL} Node.")
else:
error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running?")


#
Expand Down

0 comments on commit ebfbb0d

Please sign in to comment.