vantage6 5.0.0a7__py3-none-any.whl → 5.0.0a14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vantage6 might be problematic. Click here for more details.
- tests_cli/test_node_cli.py +4 -21
- tests_cli/test_server_cli.py +33 -12
- vantage6/cli/__build__ +1 -1
- vantage6/cli/algostore/attach.py +6 -42
- vantage6/cli/algostore/list.py +1 -1
- vantage6/cli/algostore/start.py +2 -2
- vantage6/cli/algostore/stop.py +1 -1
- vantage6/cli/cli.py +4 -11
- vantage6/cli/common/utils.py +25 -3
- vantage6/cli/configuration_manager.py +1 -0
- vantage6/cli/context/algorithm_store.py +1 -1
- vantage6/cli/context/node.py +1 -1
- vantage6/cli/node/attach.py +5 -66
- vantage6/cli/node/common/__init__.py +1 -1
- vantage6/cli/node/start.py +2 -2
- vantage6/cli/server/attach.py +5 -55
- vantage6/cli/server/import_.py +4 -1
- vantage6/cli/server/list.py +2 -1
- vantage6/cli/server/shell.py +1 -1
- vantage6/cli/server/start.py +5 -2
- vantage6/cli/server/stop.py +2 -2
- vantage6/cli/server/version.py +2 -2
- vantage6/cli/template/algo_store_config.j2 +1 -1
- vantage6/cli/template/node_config.j2 +1 -0
- vantage6/cli/template/server_config.j2 +1 -1
- vantage6/cli/test/common/diagnostic_runner.py +2 -4
- vantage6/cli/test/integration_test.py +113 -113
- {vantage6-5.0.0a7.dist-info → vantage6-5.0.0a14.dist-info}/METADATA +4 -4
- {vantage6-5.0.0a7.dist-info → vantage6-5.0.0a14.dist-info}/RECORD +32 -37
- vantage6/cli/dev/create.py +0 -633
- vantage6/cli/dev/remove.py +0 -94
- vantage6/cli/dev/start.py +0 -123
- vantage6/cli/dev/stop.py +0 -47
- vantage6/cli/dev/utils.py +0 -24
- {vantage6-5.0.0a7.dist-info → vantage6-5.0.0a14.dist-info}/WHEEL +0 -0
- {vantage6-5.0.0a7.dist-info → vantage6-5.0.0a14.dist-info}/entry_points.txt +0 -0
- {vantage6-5.0.0a7.dist-info → vantage6-5.0.0a14.dist-info}/top_level.txt +0 -0
tests_cli/test_node_cli.py
CHANGED
|
@@ -295,29 +295,12 @@ class NodeCLITest(unittest.TestCase):
|
|
|
295
295
|
result = runner.invoke(cli_node_restart, ["--name", "iknl"])
|
|
296
296
|
self.assertEqual(result.exit_code, 0)
|
|
297
297
|
|
|
298
|
-
@patch("vantage6.cli.node.attach.
|
|
299
|
-
|
|
300
|
-
@patch("docker.DockerClient.containers")
|
|
301
|
-
@patch("vantage6.cli.node.attach.check_docker_running", return_value=True)
|
|
302
|
-
def test_attach(self, check_docker, containers, log_worker, time_):
|
|
298
|
+
@patch("vantage6.cli.node.attach.attach_logs")
|
|
299
|
+
def test_attach(self, attach_logs):
|
|
303
300
|
"""Attach docker logs without errors."""
|
|
304
|
-
container1 = MagicMock()
|
|
305
|
-
container1.name = f"{APPNAME}-iknl-user"
|
|
306
|
-
containers.list.return_value = [container1]
|
|
307
|
-
|
|
308
|
-
log_worker.return_value = ""
|
|
309
|
-
time_.sleep.side_effect = KeyboardInterrupt()
|
|
310
|
-
|
|
311
301
|
runner = CliRunner()
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
self.assertEqual(
|
|
315
|
-
result.output,
|
|
316
|
-
"[info ] - Closing log file. Keyboard Interrupt.\n"
|
|
317
|
-
"[info ] - Note that your node is still running! Shut it down "
|
|
318
|
-
"with 'v6 node stop'\n",
|
|
319
|
-
)
|
|
320
|
-
self.assertEqual(result.exit_code, 0)
|
|
302
|
+
runner.invoke(cli_node_attach)
|
|
303
|
+
attach_logs.assert_called_once_with("app=node")
|
|
321
304
|
|
|
322
305
|
@patch("vantage6.cli.node.clean.q")
|
|
323
306
|
@patch("docker.DockerClient.volumes")
|
tests_cli/test_server_cli.py
CHANGED
|
@@ -5,6 +5,7 @@ from pathlib import Path
|
|
|
5
5
|
from click.testing import CliRunner
|
|
6
6
|
|
|
7
7
|
from vantage6.common.globals import APPNAME, InstanceType
|
|
8
|
+
from vantage6.cli.common.utils import attach_logs
|
|
8
9
|
from vantage6.cli.server.start import cli_server_start
|
|
9
10
|
from vantage6.cli.server.list import cli_server_configuration_list
|
|
10
11
|
from vantage6.cli.server.files import cli_server_files
|
|
@@ -132,7 +133,7 @@ class ServerCLITest(unittest.TestCase):
|
|
|
132
133
|
"""Stop server without errors."""
|
|
133
134
|
|
|
134
135
|
container1 = MagicMock()
|
|
135
|
-
container1.name = f"{APPNAME}-iknl-system-{InstanceType.SERVER}"
|
|
136
|
+
container1.name = f"{APPNAME}-iknl-system-{InstanceType.SERVER.value}"
|
|
136
137
|
containers.containers.list.return_value = [container1]
|
|
137
138
|
|
|
138
139
|
runner = CliRunner()
|
|
@@ -141,18 +142,38 @@ class ServerCLITest(unittest.TestCase):
|
|
|
141
142
|
self.assertIsNone(result.exception)
|
|
142
143
|
self.assertEqual(result.exit_code, 0)
|
|
143
144
|
|
|
144
|
-
@patch("vantage6.cli.server.attach.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"""Attach log to the console without errors."""
|
|
148
|
-
container1 = MagicMock()
|
|
149
|
-
container1.name = f"{APPNAME}-iknl-system-{InstanceType.SERVER}"
|
|
150
|
-
containers.list.return_value = [container1]
|
|
151
|
-
|
|
152
|
-
sleep.side_effect = KeyboardInterrupt("Boom!")
|
|
153
|
-
|
|
145
|
+
@patch("vantage6.cli.server.attach.attach_logs")
|
|
146
|
+
def test_attach(self, attach_logs):
|
|
147
|
+
"""Attach logs to the console without errors."""
|
|
154
148
|
runner = CliRunner()
|
|
155
|
-
result = runner.invoke(cli_server_attach
|
|
149
|
+
result = runner.invoke(cli_server_attach)
|
|
156
150
|
|
|
157
151
|
self.assertIsNone(result.exception)
|
|
158
152
|
self.assertEqual(result.exit_code, 0)
|
|
153
|
+
attach_logs.assert_called_once_with(
|
|
154
|
+
"app=vantage6-server", "component=vantage6-server"
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
@patch("vantage6.cli.common.utils.Popen")
|
|
158
|
+
def test_attach_logs(self, mock_popen):
|
|
159
|
+
# Mock the Popen instance and its methods
|
|
160
|
+
mock_process = mock_popen.return_value
|
|
161
|
+
mock_process.wait.return_value = None
|
|
162
|
+
|
|
163
|
+
# Call the function with a sample label
|
|
164
|
+
attach_logs("app=node", "env=dev")
|
|
165
|
+
|
|
166
|
+
# Construct the expected command
|
|
167
|
+
expected_command = [
|
|
168
|
+
"devspace",
|
|
169
|
+
"logs",
|
|
170
|
+
"--follow",
|
|
171
|
+
"--label-selector",
|
|
172
|
+
"app=node,env=dev",
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
# Verify that Popen was called with the expected command
|
|
176
|
+
mock_popen.assert_called_once_with(expected_command, stdout=None, stderr=None)
|
|
177
|
+
|
|
178
|
+
# Verify that wait was called on the process
|
|
179
|
+
mock_process.wait.assert_called_once()
|
vantage6/cli/__build__
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
14
|
vantage6/cli/algostore/attach.py
CHANGED
|
@@ -1,49 +1,13 @@
|
|
|
1
1
|
import click
|
|
2
|
-
import docker
|
|
3
|
-
import questionary as q
|
|
4
2
|
|
|
5
|
-
from
|
|
6
|
-
|
|
7
|
-
from vantage6.common import error
|
|
8
|
-
from vantage6.common.docker.addons import check_docker_running
|
|
9
|
-
from vantage6.common.globals import APPNAME, InstanceType
|
|
10
|
-
from vantage6.cli.common.start import attach_logs
|
|
11
|
-
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
3
|
+
from vantage6.common import info
|
|
4
|
+
from vantage6.cli.common.utils import attach_logs
|
|
12
5
|
|
|
13
6
|
|
|
14
7
|
@click.command()
|
|
15
|
-
|
|
16
|
-
@click.option("--system", "system_folders", flag_value=True)
|
|
17
|
-
@click.option(
|
|
18
|
-
"--user", "system_folders", flag_value=False, default=DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
19
|
-
)
|
|
20
|
-
def cli_algo_store_attach(name: str, system_folders: bool) -> None:
|
|
8
|
+
def cli_algo_store_attach() -> None:
|
|
21
9
|
"""
|
|
22
|
-
Show the
|
|
10
|
+
Show the store logs in the current console.
|
|
23
11
|
"""
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
running_servers = client.containers.list(
|
|
28
|
-
filters={"label": f"{APPNAME}-type={InstanceType.ALGORITHM_STORE}"}
|
|
29
|
-
)
|
|
30
|
-
running_server_names = [container.name for container in running_servers]
|
|
31
|
-
|
|
32
|
-
if not name:
|
|
33
|
-
try:
|
|
34
|
-
name = q.select(
|
|
35
|
-
"Select the algorithm store you wish to attach:",
|
|
36
|
-
choices=running_server_names,
|
|
37
|
-
).unsafe_ask()
|
|
38
|
-
except KeyboardInterrupt:
|
|
39
|
-
error("Aborted by user!")
|
|
40
|
-
return
|
|
41
|
-
else:
|
|
42
|
-
post_fix = "system" if system_folders else "user"
|
|
43
|
-
name = f"{APPNAME}-{name}-{post_fix}-{InstanceType.ALGORITHM_STORE}"
|
|
44
|
-
|
|
45
|
-
if name in running_server_names:
|
|
46
|
-
container = client.containers.get(name)
|
|
47
|
-
attach_logs(container, InstanceType.ALGORITHM_STORE)
|
|
48
|
-
else:
|
|
49
|
-
error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running!")
|
|
12
|
+
info("Attaching to store logs...")
|
|
13
|
+
attach_logs("app=store", "component=store-server")
|
vantage6/cli/algostore/list.py
CHANGED
vantage6/cli/algostore/start.py
CHANGED
|
@@ -54,7 +54,7 @@ def cli_algo_store_start(
|
|
|
54
54
|
Start the algorithm store server.
|
|
55
55
|
"""
|
|
56
56
|
info("Starting algorithm store...")
|
|
57
|
-
docker_client = check_for_start(ctx, InstanceType.ALGORITHM_STORE)
|
|
57
|
+
docker_client = check_for_start(ctx, InstanceType.ALGORITHM_STORE.value)
|
|
58
58
|
|
|
59
59
|
image = get_image(image, ctx, "algorithm-store", DEFAULT_ALGO_STORE_IMAGE)
|
|
60
60
|
|
|
@@ -91,7 +91,7 @@ def cli_algo_store_start(
|
|
|
91
91
|
mounts=mounts,
|
|
92
92
|
detach=True,
|
|
93
93
|
labels={
|
|
94
|
-
f"{APPNAME}-type": InstanceType.ALGORITHM_STORE,
|
|
94
|
+
f"{APPNAME}-type": InstanceType.ALGORITHM_STORE.value,
|
|
95
95
|
"name": ctx.config_file_name,
|
|
96
96
|
},
|
|
97
97
|
environment=environment_vars,
|
vantage6/cli/algostore/stop.py
CHANGED
|
@@ -23,7 +23,7 @@ def cli_algo_store_stop(ctx: AlgorithmStoreContext, all_stores: bool):
|
|
|
23
23
|
client = docker.from_env()
|
|
24
24
|
|
|
25
25
|
running_stores = client.containers.list(
|
|
26
|
-
filters={"label": f"{APPNAME}-type={InstanceType.ALGORITHM_STORE}"}
|
|
26
|
+
filters={"label": f"{APPNAME}-type={InstanceType.ALGORITHM_STORE.value}"}
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
if not running_stores:
|
vantage6/cli/cli.py
CHANGED
|
@@ -22,14 +22,11 @@ from vantage6.cli.node.set_api_key import cli_node_set_api_key
|
|
|
22
22
|
from vantage6.cli.node.start import cli_node_start
|
|
23
23
|
from vantage6.cli.node.stop import cli_node_stop
|
|
24
24
|
from vantage6.cli.node.version import cli_node_version
|
|
25
|
-
from vantage6.cli.dev.create import create_demo_network
|
|
26
|
-
from vantage6.cli.dev.remove import remove_demo_network
|
|
27
|
-
from vantage6.cli.dev.start import start_demo_network
|
|
28
|
-
from vantage6.cli.dev.stop import stop_demo_network
|
|
29
25
|
from vantage6.cli.algorithm.create import cli_algorithm_create
|
|
30
26
|
from vantage6.cli.algorithm.update import cli_algorithm_update
|
|
31
27
|
from vantage6.cli.test.feature_tester import cli_test_features
|
|
32
|
-
|
|
28
|
+
|
|
29
|
+
# from vantage6.cli.test.integration_test import cli_test_integration
|
|
33
30
|
from vantage6.cli.algostore.attach import cli_algo_store_attach
|
|
34
31
|
from vantage6.cli.algostore.new import cli_algo_store_new
|
|
35
32
|
from vantage6.cli.algostore.start import cli_algo_store_start
|
|
@@ -93,11 +90,7 @@ def cli_dev() -> None:
|
|
|
93
90
|
"""
|
|
94
91
|
|
|
95
92
|
|
|
96
|
-
#
|
|
97
|
-
cli_dev.add_command(create_demo_network, name="create-demo-network")
|
|
98
|
-
cli_dev.add_command(remove_demo_network, name="remove-demo-network")
|
|
99
|
-
cli_dev.add_command(start_demo_network, name="start-demo-network")
|
|
100
|
-
cli_dev.add_command(stop_demo_network, name="stop-demo-network")
|
|
93
|
+
# TODO add commands for the dev group
|
|
101
94
|
|
|
102
95
|
|
|
103
96
|
# Define the algorithm group
|
|
@@ -123,7 +116,7 @@ def cli_test() -> None:
|
|
|
123
116
|
|
|
124
117
|
# Define the commands for the test group
|
|
125
118
|
cli_test.add_command(cli_test_features, name="feature-test")
|
|
126
|
-
cli_test.add_command(cli_test_integration, name="integration-test")
|
|
119
|
+
# cli_test.add_command(cli_test_integration, name="integration-test")
|
|
127
120
|
|
|
128
121
|
|
|
129
122
|
# Define the algorithm-store group
|
vantage6/cli/common/utils.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import enum
|
|
1
2
|
import questionary as q
|
|
2
3
|
from colorama import Fore, Style
|
|
3
4
|
import click
|
|
4
5
|
from typing import Iterable
|
|
5
6
|
import docker
|
|
7
|
+
from subprocess import Popen
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
from vantage6.common import warning, error
|
|
@@ -87,7 +89,11 @@ def get_server_configuration_list(instance_type: InstanceType.SERVER) -> None:
|
|
|
87
89
|
client = docker.from_env()
|
|
88
90
|
ctx_class = select_context_class(instance_type)
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
instance_type_value = (
|
|
93
|
+
instance_type.value if isinstance(instance_type, enum.Enum) else instance_type
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
running_server_names = get_running_servers(client, instance_type_value)
|
|
91
97
|
header = "\nName" + (21 * " ") + "Status" + (10 * " ") + "System/User"
|
|
92
98
|
|
|
93
99
|
click.echo(header)
|
|
@@ -101,7 +107,8 @@ def get_server_configuration_list(instance_type: InstanceType.SERVER) -> None:
|
|
|
101
107
|
for config in configs:
|
|
102
108
|
status = (
|
|
103
109
|
running
|
|
104
|
-
if f"{APPNAME}-{config.name}-system-{
|
|
110
|
+
if f"{APPNAME}-{config.name}-system-{instance_type_value}"
|
|
111
|
+
in running_server_names
|
|
105
112
|
else stopped
|
|
106
113
|
)
|
|
107
114
|
click.echo(f"{config.name:25}" f"{status:25} System ")
|
|
@@ -111,7 +118,8 @@ def get_server_configuration_list(instance_type: InstanceType.SERVER) -> None:
|
|
|
111
118
|
for config in configs:
|
|
112
119
|
status = (
|
|
113
120
|
running
|
|
114
|
-
if f"{APPNAME}-{config.name}-user-{
|
|
121
|
+
if f"{APPNAME}-{config.name}-user-{instance_type_value}"
|
|
122
|
+
in running_server_names
|
|
115
123
|
else stopped
|
|
116
124
|
)
|
|
117
125
|
click.echo(f"{config.name:25}" f"{status:25} User ")
|
|
@@ -158,3 +166,17 @@ def get_name_from_container_name(container_name: str) -> str:
|
|
|
158
166
|
# Container name is structured as: f"{APPNAME}-{name}-{post_fix}"
|
|
159
167
|
# Take into account that name can contain '-'
|
|
160
168
|
return "-".join(container_name.split("-")[1:-1])
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def attach_logs(*labels: list[str]) -> None:
|
|
172
|
+
"""
|
|
173
|
+
Attach to the logs of the given labels.
|
|
174
|
+
|
|
175
|
+
Parameters
|
|
176
|
+
----------
|
|
177
|
+
labels : list[str]
|
|
178
|
+
The labels to attach to
|
|
179
|
+
"""
|
|
180
|
+
command = ["devspace", "logs", "--follow", "--label-selector", ",".join(labels)]
|
|
181
|
+
process = Popen(command, stdout=None, stderr=None)
|
|
182
|
+
process.wait()
|
|
@@ -53,7 +53,7 @@ class AlgorithmStoreContext(BaseServerContext):
|
|
|
53
53
|
str
|
|
54
54
|
Server's docker container name
|
|
55
55
|
"""
|
|
56
|
-
return f"{APPNAME}-{self.name}-{self.scope}-{ServerType.ALGORITHM_STORE}"
|
|
56
|
+
return f"{APPNAME}-{self.name}-{self.scope}-{ServerType.ALGORITHM_STORE.value}"
|
|
57
57
|
|
|
58
58
|
@classmethod
|
|
59
59
|
def from_external_config_file(
|
vantage6/cli/context/node.py
CHANGED
|
@@ -136,7 +136,7 @@ class NodeContext(AppContext):
|
|
|
136
136
|
Path
|
|
137
137
|
Path to the data folder
|
|
138
138
|
"""
|
|
139
|
-
return AppContext.type_data_folder(InstanceType.NODE, system_folders)
|
|
139
|
+
return AppContext.type_data_folder(InstanceType.NODE.value, system_folders)
|
|
140
140
|
|
|
141
141
|
@property
|
|
142
142
|
def databases(self) -> dict:
|
vantage6/cli/node/attach.py
CHANGED
|
@@ -1,74 +1,13 @@
|
|
|
1
|
-
import time
|
|
2
|
-
from threading import Thread
|
|
3
1
|
import click
|
|
4
|
-
import questionary as q
|
|
5
|
-
import docker
|
|
6
2
|
|
|
7
|
-
from
|
|
8
|
-
|
|
9
|
-
from vantage6.common import warning, error, info
|
|
10
|
-
from vantage6.common.globals import APPNAME
|
|
11
|
-
from vantage6.common.docker.addons import check_docker_running
|
|
12
|
-
|
|
13
|
-
from vantage6.cli.common.utils import print_log_worker
|
|
14
|
-
from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
|
|
15
|
-
from vantage6.cli.node.common import find_running_node_names
|
|
3
|
+
from vantage6.common import info
|
|
4
|
+
from vantage6.cli.common.utils import attach_logs
|
|
16
5
|
|
|
17
6
|
|
|
18
7
|
@click.command()
|
|
19
|
-
|
|
20
|
-
@click.option(
|
|
21
|
-
"--system",
|
|
22
|
-
"system_folders",
|
|
23
|
-
flag_value=True,
|
|
24
|
-
help="Search for configuration in system folders rather than " "user folders",
|
|
25
|
-
)
|
|
26
|
-
@click.option(
|
|
27
|
-
"--user",
|
|
28
|
-
"system_folders",
|
|
29
|
-
flag_value=False,
|
|
30
|
-
default=N_FOL,
|
|
31
|
-
help="Search for configuration in user folders rather than "
|
|
32
|
-
"system folders. This is the default",
|
|
33
|
-
)
|
|
34
|
-
def cli_node_attach(name: str, system_folders: bool) -> None:
|
|
8
|
+
def cli_node_attach() -> None:
|
|
35
9
|
"""
|
|
36
10
|
Show the node logs in the current console.
|
|
37
11
|
"""
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
running_node_names = find_running_node_names(client)
|
|
42
|
-
|
|
43
|
-
if not running_node_names:
|
|
44
|
-
warning("No nodes are currently running. Cannot show any logs!")
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
if not name:
|
|
48
|
-
try:
|
|
49
|
-
name = q.select(
|
|
50
|
-
"Select the node you wish to attach:", choices=running_node_names
|
|
51
|
-
).unsafe_ask()
|
|
52
|
-
except KeyboardInterrupt:
|
|
53
|
-
error("Aborted by user!")
|
|
54
|
-
return
|
|
55
|
-
else:
|
|
56
|
-
post_fix = "system" if system_folders else "user"
|
|
57
|
-
name = f"{APPNAME}-{name}-{post_fix}"
|
|
58
|
-
|
|
59
|
-
if name in running_node_names:
|
|
60
|
-
container = client.containers.get(name)
|
|
61
|
-
logs = container.attach(stream=True, logs=True)
|
|
62
|
-
Thread(target=print_log_worker, args=(logs,), daemon=True).start()
|
|
63
|
-
while True:
|
|
64
|
-
try:
|
|
65
|
-
time.sleep(1)
|
|
66
|
-
except KeyboardInterrupt:
|
|
67
|
-
info("Closing log file. Keyboard Interrupt.")
|
|
68
|
-
info(
|
|
69
|
-
"Note that your node is still running! Shut it down with "
|
|
70
|
-
f"'{Fore.RED}v6 node stop{Style.RESET_ALL}'"
|
|
71
|
-
)
|
|
72
|
-
exit(0)
|
|
73
|
-
else:
|
|
74
|
-
error(f"{Fore.RED}{name}{Style.RESET_ALL} was not running!?")
|
|
12
|
+
info("Attaching to node logs...")
|
|
13
|
+
attach_logs("app=node")
|
|
@@ -130,6 +130,6 @@ def find_running_node_names(client: docker.DockerClient) -> list[str]:
|
|
|
130
130
|
List of names of running nodes
|
|
131
131
|
"""
|
|
132
132
|
running_nodes = client.containers.list(
|
|
133
|
-
filters={"label": f"{APPNAME}-type={InstanceType.NODE}"}
|
|
133
|
+
filters={"label": f"{APPNAME}-type={InstanceType.NODE.value}"}
|
|
134
134
|
)
|
|
135
135
|
return [node.name for node in running_nodes]
|
vantage6/cli/node/start.py
CHANGED
|
@@ -78,7 +78,7 @@ def cli_node_start(
|
|
|
78
78
|
|
|
79
79
|
# check that this node is not already running
|
|
80
80
|
running_nodes = docker_client.containers.list(
|
|
81
|
-
filters={"label": f"{APPNAME}-type={InstanceType.NODE}"}
|
|
81
|
+
filters={"label": f"{APPNAME}-type={InstanceType.NODE.value}"}
|
|
82
82
|
)
|
|
83
83
|
|
|
84
84
|
suffix = "system" if system_folders else "user"
|
|
@@ -306,7 +306,7 @@ def cli_node_start(
|
|
|
306
306
|
volumes=volumes,
|
|
307
307
|
detach=True,
|
|
308
308
|
labels={
|
|
309
|
-
f"{APPNAME}-type": InstanceType.NODE,
|
|
309
|
+
f"{APPNAME}-type": InstanceType.NODE.value,
|
|
310
310
|
"system": str(system_folders),
|
|
311
311
|
"name": ctx.config_file_name,
|
|
312
312
|
},
|
vantage6/cli/server/attach.py
CHANGED
|
@@ -1,63 +1,13 @@
|
|
|
1
|
-
import time
|
|
2
|
-
from threading import Thread
|
|
3
|
-
|
|
4
1
|
import click
|
|
5
|
-
import questionary as q
|
|
6
|
-
import docker
|
|
7
|
-
|
|
8
|
-
from colorama import Fore, Style
|
|
9
|
-
|
|
10
|
-
from vantage6.common import info, error
|
|
11
|
-
from vantage6.common.docker.addons import check_docker_running
|
|
12
|
-
from vantage6.common.globals import APPNAME, InstanceType
|
|
13
2
|
|
|
14
|
-
from vantage6.
|
|
15
|
-
from vantage6.cli.common.utils import
|
|
3
|
+
from vantage6.common import info
|
|
4
|
+
from vantage6.cli.common.utils import attach_logs
|
|
16
5
|
|
|
17
6
|
|
|
18
7
|
@click.command()
|
|
19
|
-
|
|
20
|
-
@click.option("--system", "system_folders", flag_value=True)
|
|
21
|
-
@click.option(
|
|
22
|
-
"--user", "system_folders", flag_value=False, default=DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
23
|
-
)
|
|
24
|
-
def cli_server_attach(name: str, system_folders: bool) -> None:
|
|
8
|
+
def cli_server_attach() -> None:
|
|
25
9
|
"""
|
|
26
10
|
Show the server logs in the current console.
|
|
27
11
|
"""
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
running_servers = client.containers.list(
|
|
32
|
-
filters={"label": f"{APPNAME}-type={InstanceType.SERVER}"}
|
|
33
|
-
)
|
|
34
|
-
running_server_names = [node.name for node in running_servers]
|
|
35
|
-
|
|
36
|
-
if not name:
|
|
37
|
-
try:
|
|
38
|
-
name = q.select(
|
|
39
|
-
"Select the server you wish to attach:", choices=running_server_names
|
|
40
|
-
).unsafe_ask()
|
|
41
|
-
except KeyboardInterrupt:
|
|
42
|
-
error("Aborted by user!")
|
|
43
|
-
return
|
|
44
|
-
else:
|
|
45
|
-
post_fix = "system" if system_folders else "user"
|
|
46
|
-
name = f"{APPNAME}-{name}-{post_fix}-{InstanceType.SERVER}"
|
|
47
|
-
|
|
48
|
-
if name in running_server_names:
|
|
49
|
-
container = client.containers.get(name)
|
|
50
|
-
logs = container.attach(stream=True, logs=True, stdout=True)
|
|
51
|
-
Thread(target=print_log_worker, args=(logs,), daemon=True).start()
|
|
52
|
-
while True:
|
|
53
|
-
try:
|
|
54
|
-
time.sleep(1)
|
|
55
|
-
except KeyboardInterrupt:
|
|
56
|
-
info("Closing log file. Keyboard Interrupt.")
|
|
57
|
-
info(
|
|
58
|
-
"Note that your server is still running! Shut it down "
|
|
59
|
-
f"with {Fore.RED}v6 server stop{Style.RESET_ALL}"
|
|
60
|
-
)
|
|
61
|
-
exit(0)
|
|
62
|
-
else:
|
|
63
|
-
error(f"{Fore.RED}{name}{Style.RESET_ALL} was not running!?")
|
|
12
|
+
info("Attaching to server logs...")
|
|
13
|
+
attach_logs("app=vantage6-server", "component=vantage6-server")
|
vantage6/cli/server/import_.py
CHANGED
|
@@ -132,7 +132,10 @@ def cli_server_import(
|
|
|
132
132
|
command=cmd,
|
|
133
133
|
mounts=mounts,
|
|
134
134
|
detach=True,
|
|
135
|
-
labels={
|
|
135
|
+
labels={
|
|
136
|
+
f"{APPNAME}-type": InstanceType.SERVER.value,
|
|
137
|
+
"name": ctx.config_file_name,
|
|
138
|
+
},
|
|
136
139
|
environment=environment_vars,
|
|
137
140
|
auto_remove=not keep,
|
|
138
141
|
tty=True,
|
vantage6/cli/server/list.py
CHANGED
vantage6/cli/server/shell.py
CHANGED
|
@@ -28,7 +28,7 @@ def cli_server_shell(ctx: ServerContext) -> None:
|
|
|
28
28
|
docker_client = docker.from_env()
|
|
29
29
|
|
|
30
30
|
running_servers = docker_client.containers.list(
|
|
31
|
-
filters={"label": f"{APPNAME}-type={InstanceType.SERVER}"}
|
|
31
|
+
filters={"label": f"{APPNAME}-type={InstanceType.SERVER.value}"}
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
if ctx.docker_container_name not in [s.name for s in running_servers]:
|
vantage6/cli/server/start.py
CHANGED
|
@@ -83,7 +83,7 @@ def cli_server_start(
|
|
|
83
83
|
Start the server.
|
|
84
84
|
"""
|
|
85
85
|
info("Starting server...")
|
|
86
|
-
docker_client = check_for_start(ctx, InstanceType.SERVER)
|
|
86
|
+
docker_client = check_for_start(ctx, InstanceType.SERVER.value)
|
|
87
87
|
|
|
88
88
|
image = get_image(image, ctx, "server", DEFAULT_SERVER_IMAGE)
|
|
89
89
|
|
|
@@ -157,7 +157,10 @@ def cli_server_start(
|
|
|
157
157
|
command=cmd,
|
|
158
158
|
mounts=mounts,
|
|
159
159
|
detach=True,
|
|
160
|
-
labels={
|
|
160
|
+
labels={
|
|
161
|
+
f"{APPNAME}-type": InstanceType.SERVER.value,
|
|
162
|
+
"name": ctx.config_file_name,
|
|
163
|
+
},
|
|
161
164
|
environment=environment_vars,
|
|
162
165
|
ports={f"{internal_port}/tcp": (ip, port_)},
|
|
163
166
|
name=ctx.docker_container_name,
|
vantage6/cli/server/stop.py
CHANGED
|
@@ -37,7 +37,7 @@ def cli_server_stop(name: str, system_folders: bool, all_servers: bool):
|
|
|
37
37
|
client = docker.from_env()
|
|
38
38
|
|
|
39
39
|
running_servers = client.containers.list(
|
|
40
|
-
filters={"label": f"{APPNAME}-type={InstanceType.SERVER}"}
|
|
40
|
+
filters={"label": f"{APPNAME}-type={InstanceType.SERVER.value}"}
|
|
41
41
|
)
|
|
42
42
|
|
|
43
43
|
if not running_servers:
|
|
@@ -62,7 +62,7 @@ def cli_server_stop(name: str, system_folders: bool, all_servers: bool):
|
|
|
62
62
|
return
|
|
63
63
|
else:
|
|
64
64
|
post_fix = "system" if system_folders else "user"
|
|
65
|
-
container_name = f"{APPNAME}-{name}-{post_fix}-{InstanceType.SERVER}"
|
|
65
|
+
container_name = f"{APPNAME}-{name}-{post_fix}-{InstanceType.SERVER.value}"
|
|
66
66
|
|
|
67
67
|
if container_name not in running_server_names:
|
|
68
68
|
error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running!")
|
vantage6/cli/server/version.py
CHANGED
|
@@ -22,10 +22,10 @@ def cli_server_version(name: str, system_folders: bool) -> None:
|
|
|
22
22
|
check_docker_running()
|
|
23
23
|
client = docker.from_env()
|
|
24
24
|
|
|
25
|
-
running_server_names = get_running_servers(client, InstanceType.SERVER)
|
|
25
|
+
running_server_names = get_running_servers(client, InstanceType.SERVER.value)
|
|
26
26
|
|
|
27
27
|
name = get_server_name(
|
|
28
|
-
name, system_folders, running_server_names, InstanceType.SERVER
|
|
28
|
+
name, system_folders, running_server_names, InstanceType.SERVER.value
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
if name in running_server_names:
|
|
@@ -97,9 +97,7 @@ class DiagnosticRunner:
|
|
|
97
97
|
name="test",
|
|
98
98
|
description="Basic Diagnostic test",
|
|
99
99
|
image=DIAGNOSTICS_IMAGE,
|
|
100
|
-
|
|
101
|
-
"method": "base_features",
|
|
102
|
-
},
|
|
100
|
+
method="base_features",
|
|
103
101
|
organizations=self.organization_ids,
|
|
104
102
|
databases=[{"label": "default"}],
|
|
105
103
|
)
|
|
@@ -123,8 +121,8 @@ class DiagnosticRunner:
|
|
|
123
121
|
name="test",
|
|
124
122
|
description="VPN Diagnostic test",
|
|
125
123
|
image=DIAGNOSTICS_IMAGE,
|
|
124
|
+
method="vpn_features",
|
|
126
125
|
input_={
|
|
127
|
-
"method": "vpn_features",
|
|
128
126
|
"kwargs": {"other_nodes": self.organization_ids},
|
|
129
127
|
},
|
|
130
128
|
organizations=self.organization_ids,
|