vantage6 4.2.1__py3-none-any.whl → 4.3.0b3__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_example.py +0 -1
- tests_cli/test_node_cli.py +74 -79
- tests_cli/test_server_cli.py +22 -22
- tests_cli/test_wizard.py +41 -29
- vantage6/cli/__build__ +1 -1
- vantage6/cli/_version.py +11 -8
- vantage6/cli/algorithm/create.py +14 -14
- vantage6/cli/algorithm/update.py +9 -6
- vantage6/cli/algostore/attach.py +32 -0
- vantage6/cli/algostore/new.py +55 -0
- vantage6/cli/algostore/start.py +102 -0
- vantage6/cli/algostore/stop.py +60 -0
- vantage6/cli/cli.py +32 -12
- vantage6/cli/common/decorator.py +92 -0
- vantage6/cli/common/start.py +232 -0
- vantage6/cli/configuration_manager.py +22 -32
- vantage6/cli/configuration_wizard.py +255 -193
- vantage6/cli/context/__init__.py +86 -0
- vantage6/cli/context/algorithm_store.py +130 -0
- vantage6/cli/context/base_server.py +89 -0
- vantage6/cli/context/node.py +254 -0
- vantage6/cli/context/server.py +127 -0
- vantage6/cli/dev/create.py +180 -113
- vantage6/cli/dev/remove.py +20 -19
- vantage6/cli/dev/start.py +10 -10
- vantage6/cli/dev/stop.py +7 -5
- vantage6/cli/globals.py +24 -0
- vantage6/cli/node/attach.py +21 -10
- vantage6/cli/node/clean.py +4 -2
- vantage6/cli/node/common/__init__.py +15 -11
- vantage6/cli/node/create_private_key.py +58 -27
- vantage6/cli/node/files.py +14 -6
- vantage6/cli/node/list.py +18 -24
- vantage6/cli/node/new.py +21 -12
- vantage6/cli/node/remove.py +31 -22
- vantage6/cli/node/set_api_key.py +18 -12
- vantage6/cli/node/start.py +38 -12
- vantage6/cli/node/stop.py +32 -18
- vantage6/cli/node/version.py +23 -13
- vantage6/cli/rabbitmq/__init__.py +9 -9
- vantage6/cli/rabbitmq/definitions.py +24 -28
- vantage6/cli/rabbitmq/queue_manager.py +37 -40
- vantage6/cli/server/attach.py +16 -11
- vantage6/cli/server/common/__init__.py +37 -25
- vantage6/cli/server/files.py +1 -1
- vantage6/cli/server/import_.py +45 -37
- vantage6/cli/server/list.py +22 -23
- vantage6/cli/server/new.py +20 -14
- vantage6/cli/server/remove.py +5 -4
- vantage6/cli/server/shell.py +17 -6
- vantage6/cli/server/start.py +118 -174
- vantage6/cli/server/stop.py +31 -23
- vantage6/cli/server/version.py +16 -13
- vantage6/cli/test/common/diagnostic_runner.py +30 -34
- vantage6/cli/test/feature_tester.py +51 -25
- vantage6/cli/test/integration_test.py +69 -29
- vantage6/cli/utils.py +6 -5
- {vantage6-4.2.1.dist-info → vantage6-4.3.0b3.dist-info}/METADATA +5 -3
- vantage6-4.3.0b3.dist-info/RECORD +68 -0
- vantage6/cli/context.py +0 -416
- vantage6-4.2.1.dist-info/RECORD +0 -58
- {vantage6-4.2.1.dist-info → vantage6-4.3.0b3.dist-info}/WHEEL +0 -0
- {vantage6-4.2.1.dist-info → vantage6-4.3.0b3.dist-info}/entry_points.txt +0 -0
- {vantage6-4.2.1.dist-info → vantage6-4.3.0b3.dist-info}/top_level.txt +0 -0
vantage6/cli/node/stop.py
CHANGED
|
@@ -14,18 +14,30 @@ from vantage6.cli.node.common import find_running_node_names
|
|
|
14
14
|
|
|
15
15
|
@click.command()
|
|
16
16
|
@click.option("-n", "--name", default=None, help="Configuration name")
|
|
17
|
-
@click.option(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@click.option(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
@click.option(
|
|
18
|
+
"--system",
|
|
19
|
+
"system_folders",
|
|
20
|
+
flag_value=True,
|
|
21
|
+
help="Search for configuration in system folders instead of " "user folders",
|
|
22
|
+
)
|
|
23
|
+
@click.option(
|
|
24
|
+
"--user",
|
|
25
|
+
"system_folders",
|
|
26
|
+
flag_value=False,
|
|
27
|
+
default=N_FOL,
|
|
28
|
+
help="Search for configuration in the user folders instead of "
|
|
29
|
+
"system folders. This is the default.",
|
|
30
|
+
)
|
|
31
|
+
@click.option("--all", "all_nodes", flag_value=True, help="Stop all running nodes")
|
|
32
|
+
@click.option(
|
|
33
|
+
"--force",
|
|
34
|
+
"force",
|
|
35
|
+
flag_value=True,
|
|
36
|
+
help="Kill nodes instantly; don't wait for them to shut down",
|
|
37
|
+
)
|
|
38
|
+
def cli_node_stop(
|
|
39
|
+
name: str, system_folders: bool, all_nodes: bool, force: bool
|
|
40
|
+
) -> None:
|
|
29
41
|
"""
|
|
30
42
|
Stop one or all running nodes.
|
|
31
43
|
"""
|
|
@@ -39,9 +51,11 @@ def cli_node_stop(name: str, system_folders: bool, all_nodes: bool,
|
|
|
39
51
|
return
|
|
40
52
|
|
|
41
53
|
if force:
|
|
42
|
-
warning(
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
warning(
|
|
55
|
+
"Forcing the node to stop will not terminate helper "
|
|
56
|
+
"containers, neither will it remove routing rules made on the "
|
|
57
|
+
"host!"
|
|
58
|
+
)
|
|
45
59
|
|
|
46
60
|
if all_nodes:
|
|
47
61
|
for name in running_node_names:
|
|
@@ -53,10 +67,10 @@ def cli_node_stop(name: str, system_folders: bool, all_nodes: bool,
|
|
|
53
67
|
info(f"Stopped the {Fore.GREEN}{name}{Style.RESET_ALL} Node.")
|
|
54
68
|
else:
|
|
55
69
|
if not name:
|
|
56
|
-
name = q.select(
|
|
57
|
-
|
|
70
|
+
name = q.select(
|
|
71
|
+
"Select the node you wish to stop:", choices=running_node_names
|
|
72
|
+
).ask()
|
|
58
73
|
else:
|
|
59
|
-
|
|
60
74
|
post_fix = "system" if system_folders else "user"
|
|
61
75
|
name = f"{APPNAME}-{name}-{post_fix}"
|
|
62
76
|
|
vantage6/cli/node/version.py
CHANGED
|
@@ -12,12 +12,20 @@ from vantage6.cli.node.common import find_running_node_names
|
|
|
12
12
|
|
|
13
13
|
@click.command()
|
|
14
14
|
@click.option("-n", "--name", default=None, help="Configuration name")
|
|
15
|
-
@click.option(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
@click.option(
|
|
16
|
+
"--system",
|
|
17
|
+
"system_folders",
|
|
18
|
+
flag_value=True,
|
|
19
|
+
help="Search for configuration in system folders rather than " "user folders",
|
|
20
|
+
)
|
|
21
|
+
@click.option(
|
|
22
|
+
"--user",
|
|
23
|
+
"system_folders",
|
|
24
|
+
flag_value=False,
|
|
25
|
+
default=N_FOL,
|
|
26
|
+
help="Search for configuration in user folders rather than "
|
|
27
|
+
"system folders. This is the default",
|
|
28
|
+
)
|
|
21
29
|
def cli_node_version(name: str, system_folders: bool) -> None:
|
|
22
30
|
"""
|
|
23
31
|
Returns current version of a vantage6 node.
|
|
@@ -29,19 +37,21 @@ def cli_node_version(name: str, system_folders: bool) -> None:
|
|
|
29
37
|
|
|
30
38
|
if not name:
|
|
31
39
|
if not running_node_names:
|
|
32
|
-
error(
|
|
33
|
-
|
|
40
|
+
error(
|
|
41
|
+
"No nodes are running! You can only check the version for "
|
|
42
|
+
"nodes that are running"
|
|
43
|
+
)
|
|
34
44
|
exit(1)
|
|
35
|
-
name = q.select(
|
|
36
|
-
|
|
45
|
+
name = q.select(
|
|
46
|
+
"Select the node you wish to inspect:", choices=running_node_names
|
|
47
|
+
).ask()
|
|
37
48
|
else:
|
|
38
49
|
post_fix = "system" if system_folders else "user"
|
|
39
50
|
name = f"{APPNAME}-{name}-{post_fix}"
|
|
40
51
|
|
|
41
52
|
if name in running_node_names:
|
|
42
53
|
container = client.containers.get(name)
|
|
43
|
-
version = container.exec_run(cmd=
|
|
44
|
-
click.echo(
|
|
45
|
-
{"node": version.output.decode('utf-8'), "cli": __version__})
|
|
54
|
+
version = container.exec_run(cmd="vnode-local version", stdout=True)
|
|
55
|
+
click.echo({"node": version.output.decode("utf-8"), "cli": __version__})
|
|
46
56
|
else:
|
|
47
57
|
error(f"Node {name} is not running! Cannot provide version...")
|
|
@@ -15,14 +15,14 @@ def split_rabbitmq_uri(rabbit_uri: str) -> dict:
|
|
|
15
15
|
dict[str]
|
|
16
16
|
The vhost defined in the RabbitMQ URI
|
|
17
17
|
"""
|
|
18
|
-
(user_details, location_details) = rabbit_uri.split(
|
|
19
|
-
(user, password) = user_details.split(
|
|
20
|
-
(host, remainder) = location_details.split(
|
|
21
|
-
port, vhost = remainder.split(
|
|
18
|
+
(user_details, location_details) = rabbit_uri.split("@", 1)
|
|
19
|
+
(user, password) = user_details.split("/")[-1].split(":", 1)
|
|
20
|
+
(host, remainder) = location_details.split(":", 1)
|
|
21
|
+
port, vhost = remainder.split("/", 1)
|
|
22
22
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
"user": user,
|
|
24
|
+
"password": password,
|
|
25
|
+
"host": host,
|
|
26
|
+
"port": port,
|
|
27
|
+
"vhost": vhost,
|
|
28
28
|
}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
RABBITMQ_DEFINITIONS = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"policies": [],
|
|
27
|
-
"queues": [],
|
|
28
|
-
"exchanges": [],
|
|
29
|
-
"bindings": []
|
|
2
|
+
"rabbit_version": "3.6.6",
|
|
3
|
+
"users": [
|
|
4
|
+
{
|
|
5
|
+
"name": "{{username}}",
|
|
6
|
+
"password_hash": "{{password}}",
|
|
7
|
+
"hashing_algorithm": "rabbit_password_hashing_sha256",
|
|
8
|
+
"tags": "administrator",
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"vhosts": [{"name": "{{vhost_name}}"}],
|
|
12
|
+
"permissions": [
|
|
13
|
+
{
|
|
14
|
+
"user": "{{username}}",
|
|
15
|
+
"vhost": "{{vhost_name}}",
|
|
16
|
+
"configure": ".*",
|
|
17
|
+
"write": ".*",
|
|
18
|
+
"read": ".*",
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"parameters": [],
|
|
22
|
+
"policies": [],
|
|
23
|
+
"queues": [],
|
|
24
|
+
"exchanges": [],
|
|
25
|
+
"bindings": [],
|
|
30
26
|
}
|
|
@@ -12,14 +12,14 @@ from vantage6.common.globals import APPNAME
|
|
|
12
12
|
from vantage6.common import debug, info, error
|
|
13
13
|
from vantage6.common.docker.addons import get_container
|
|
14
14
|
from vantage6.common.docker.network_manager import NetworkManager
|
|
15
|
-
from vantage6.cli.context import ServerContext
|
|
15
|
+
from vantage6.cli.context.server import ServerContext
|
|
16
16
|
from vantage6.cli.rabbitmq.definitions import RABBITMQ_DEFINITIONS
|
|
17
17
|
from vantage6.cli.globals import RABBIT_TIMEOUT
|
|
18
18
|
from vantage6.cli.rabbitmq import split_rabbitmq_uri
|
|
19
19
|
|
|
20
|
-
DEFAULT_RABBIT_IMAGE =
|
|
21
|
-
RABBIT_CONFIG =
|
|
22
|
-
RABBIT_DIR =
|
|
20
|
+
DEFAULT_RABBIT_IMAGE = "harbor2.vantage6.ai/infrastructure/rabbitmq"
|
|
21
|
+
RABBIT_CONFIG = "rabbitmq.config"
|
|
22
|
+
RABBIT_DIR = "rabbitmq"
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class RabbitMQManager:
|
|
@@ -36,17 +36,19 @@ class RabbitMQManager:
|
|
|
36
36
|
Docker image to use for RabbitMQ container. By default, the image
|
|
37
37
|
harbor2.vantage6.ai/infrastructure/rabbitmq is used.
|
|
38
38
|
"""
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
def __init__(
|
|
41
|
+
self, ctx: ServerContext, network_mgr: NetworkManager, image: str = None
|
|
42
|
+
) -> None:
|
|
41
43
|
self.ctx = ctx
|
|
42
|
-
self.queue_uri = self.ctx.config[
|
|
44
|
+
self.queue_uri = self.ctx.config["rabbitmq"].get("uri")
|
|
43
45
|
rabbit_splitted = split_rabbitmq_uri(self.queue_uri)
|
|
44
|
-
self.rabbit_user = rabbit_splitted[
|
|
45
|
-
self.rabbit_pass = rabbit_splitted[
|
|
46
|
-
self.vhost = rabbit_splitted[
|
|
47
|
-
self.port = rabbit_splitted[
|
|
48
|
-
self.host = rabbit_splitted[
|
|
49
|
-
self.definitions_file = Path(self.ctx.data_dir /
|
|
46
|
+
self.rabbit_user = rabbit_splitted["user"]
|
|
47
|
+
self.rabbit_pass = rabbit_splitted["password"]
|
|
48
|
+
self.vhost = rabbit_splitted["vhost"]
|
|
49
|
+
self.port = rabbit_splitted["port"]
|
|
50
|
+
self.host = rabbit_splitted["host"]
|
|
51
|
+
self.definitions_file = Path(self.ctx.data_dir / "definitions.json")
|
|
50
52
|
self.network_mgr = network_mgr
|
|
51
53
|
|
|
52
54
|
self.docker = docker.from_env()
|
|
@@ -64,19 +66,16 @@ class RabbitMQManager:
|
|
|
64
66
|
# same for 15672 in container to 8080 on host
|
|
65
67
|
# TODO check if these ports are not already used on the host
|
|
66
68
|
ports = {
|
|
67
|
-
f
|
|
69
|
+
f"{self.port}/tcp": self.port,
|
|
68
70
|
# TODO this is for the management tool, do we keep this? Not used
|
|
69
71
|
# at the moment..
|
|
70
|
-
|
|
72
|
+
"15672/tcp": 8080,
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
# check if a RabbitMQ container is already running
|
|
74
|
-
self.rabbit_container = get_container(
|
|
75
|
-
docker_client=self.docker, name=self.host
|
|
76
|
-
)
|
|
76
|
+
self.rabbit_container = get_container(docker_client=self.docker, name=self.host)
|
|
77
77
|
if self.rabbit_container:
|
|
78
|
-
info("RabbitMQ is already running! Linking the server to that "
|
|
79
|
-
"queue")
|
|
78
|
+
info("RabbitMQ is already running! Linking the server to that " "queue")
|
|
80
79
|
if not self.network_mgr.contains(self.rabbit_container):
|
|
81
80
|
self.network_mgr.connect(self.rabbit_container)
|
|
82
81
|
return
|
|
@@ -93,14 +92,14 @@ class RabbitMQManager:
|
|
|
93
92
|
labels={
|
|
94
93
|
f"{APPNAME}-type": "rabbitmq",
|
|
95
94
|
},
|
|
96
|
-
network=self.network_mgr.network_name
|
|
95
|
+
network=self.network_mgr.network_name,
|
|
97
96
|
)
|
|
98
97
|
|
|
99
98
|
# Wait until RabbitMQ is up before continuing with other stuff
|
|
100
99
|
self._wait_for_startup()
|
|
101
100
|
|
|
102
101
|
def _wait_for_startup(self) -> None:
|
|
103
|
-
"""
|
|
102
|
+
"""Wait until RabbitMQ has been initialized"""
|
|
104
103
|
interval = 10
|
|
105
104
|
attempts = int((RABBIT_TIMEOUT + interval) / interval)
|
|
106
105
|
is_running = False
|
|
@@ -144,12 +143,11 @@ class RabbitMQManager:
|
|
|
144
143
|
rabbit_definitions = self._get_rabbitmq_definitions()
|
|
145
144
|
|
|
146
145
|
# write the RabbitMQ definition to file(s)
|
|
147
|
-
with open(self.definitions_file,
|
|
146
|
+
with open(self.definitions_file, "w") as f:
|
|
148
147
|
json.dump(rabbit_definitions, f, indent=2)
|
|
149
148
|
|
|
150
149
|
# write RabbitMQ config to file
|
|
151
|
-
rabbit_conf =
|
|
152
|
-
Path(__file__).parent.resolve() / RABBIT_CONFIG
|
|
150
|
+
rabbit_conf = Path(__file__).parent.resolve() / RABBIT_CONFIG
|
|
153
151
|
shutil.copyfile(rabbit_conf, self.ctx.data_dir / RABBIT_CONFIG)
|
|
154
152
|
|
|
155
153
|
# check if a directory for persistent RabbitMQ storage exists,
|
|
@@ -160,14 +158,12 @@ class RabbitMQManager:
|
|
|
160
158
|
|
|
161
159
|
return {
|
|
162
160
|
self.definitions_file: {
|
|
163
|
-
|
|
161
|
+
"bind": "/etc/rabbitmq/definitions.json",
|
|
162
|
+
"mode": "ro",
|
|
164
163
|
},
|
|
165
|
-
self.ctx.data_dir
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
rabbit_data_dir: {
|
|
169
|
-
'bind': '/var/lib/rabbitmq', 'mode': 'rw'
|
|
170
|
-
}
|
|
164
|
+
self.ctx.data_dir
|
|
165
|
+
/ RABBIT_CONFIG: {"bind": "/etc/rabbitmq/rabbitmq.config", "mode": "ro"},
|
|
166
|
+
rabbit_data_dir: {"bind": "/var/lib/rabbitmq", "mode": "rw"},
|
|
171
167
|
}
|
|
172
168
|
|
|
173
169
|
def _get_rabbitmq_definitions(self) -> dict:
|
|
@@ -181,12 +177,13 @@ class RabbitMQManager:
|
|
|
181
177
|
startup of RabbitMQ
|
|
182
178
|
"""
|
|
183
179
|
rabbit_definitions = RABBITMQ_DEFINITIONS
|
|
184
|
-
rabbit_definitions[
|
|
185
|
-
rabbit_definitions[
|
|
186
|
-
rabbit_definitions[
|
|
187
|
-
self.
|
|
188
|
-
|
|
189
|
-
rabbit_definitions[
|
|
180
|
+
rabbit_definitions["users"][0]["name"] = self.rabbit_user
|
|
181
|
+
rabbit_definitions["permissions"][0]["user"] = self.rabbit_user
|
|
182
|
+
rabbit_definitions["users"][0]["password_hash"] = self._get_hashed_pw(
|
|
183
|
+
self.rabbit_pass
|
|
184
|
+
)
|
|
185
|
+
rabbit_definitions["vhosts"][0]["name"] = self.vhost
|
|
186
|
+
rabbit_definitions["permissions"][0]["vhost"] = self.vhost
|
|
190
187
|
return rabbit_definitions
|
|
191
188
|
|
|
192
189
|
def _get_hashed_pw(self, pw: str) -> str:
|
|
@@ -208,7 +205,7 @@ class RabbitMQManager:
|
|
|
208
205
|
salt = os.urandom(4)
|
|
209
206
|
|
|
210
207
|
# Concatenate that with the UTF-8 representation of the password
|
|
211
|
-
tmp0 = salt + pw.encode(
|
|
208
|
+
tmp0 = salt + pw.encode("utf-8")
|
|
212
209
|
|
|
213
210
|
# Take the SHA256 hash and get the bytes back
|
|
214
211
|
tmp1 = hashlib.sha256(tmp0).digest()
|
|
@@ -218,4 +215,4 @@ class RabbitMQManager:
|
|
|
218
215
|
|
|
219
216
|
# convert to base64 encoding:
|
|
220
217
|
pass_hash = base64.b64encode(salted_hash)
|
|
221
|
-
return pass_hash.decode(
|
|
218
|
+
return pass_hash.decode("utf-8")
|
vantage6/cli/server/attach.py
CHANGED
|
@@ -5,11 +5,11 @@ import click
|
|
|
5
5
|
import questionary as q
|
|
6
6
|
import docker
|
|
7
7
|
|
|
8
|
-
from colorama import
|
|
8
|
+
from colorama import Fore, Style
|
|
9
9
|
|
|
10
10
|
from vantage6.common import info, error
|
|
11
11
|
from vantage6.common.docker.addons import check_docker_running
|
|
12
|
-
from vantage6.common.globals import APPNAME
|
|
12
|
+
from vantage6.common.globals import APPNAME, InstanceType
|
|
13
13
|
|
|
14
14
|
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
15
15
|
from vantage6.cli.server.common import print_log_worker
|
|
@@ -17,9 +17,10 @@ from vantage6.cli.server.common import print_log_worker
|
|
|
17
17
|
|
|
18
18
|
@click.command()
|
|
19
19
|
@click.option("-n", "--name", default=None, help="configuration name")
|
|
20
|
-
@click.option(
|
|
21
|
-
@click.option(
|
|
22
|
-
|
|
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
|
+
)
|
|
23
24
|
def cli_server_attach(name: str, system_folders: bool) -> None:
|
|
24
25
|
"""
|
|
25
26
|
Show the server logs in the current console.
|
|
@@ -28,15 +29,17 @@ def cli_server_attach(name: str, system_folders: bool) -> None:
|
|
|
28
29
|
client = docker.from_env()
|
|
29
30
|
|
|
30
31
|
running_servers = client.containers.list(
|
|
31
|
-
filters={"label": f"{APPNAME}-type=
|
|
32
|
+
filters={"label": f"{APPNAME}-type={InstanceType.SERVER}"}
|
|
33
|
+
)
|
|
32
34
|
running_server_names = [node.name for node in running_servers]
|
|
33
35
|
|
|
34
36
|
if not name:
|
|
35
|
-
name = q.select(
|
|
36
|
-
|
|
37
|
+
name = q.select(
|
|
38
|
+
"Select the server you wish to inspect:", choices=running_server_names
|
|
39
|
+
).ask()
|
|
37
40
|
else:
|
|
38
41
|
post_fix = "system" if system_folders else "user"
|
|
39
|
-
name = f"{APPNAME}-{name}-{post_fix}-
|
|
42
|
+
name = f"{APPNAME}-{name}-{post_fix}-{InstanceType.SERVER}"
|
|
40
43
|
|
|
41
44
|
if name in running_server_names:
|
|
42
45
|
container = client.containers.get(name)
|
|
@@ -47,8 +50,10 @@ def cli_server_attach(name: str, system_folders: bool) -> None:
|
|
|
47
50
|
time.sleep(1)
|
|
48
51
|
except KeyboardInterrupt:
|
|
49
52
|
info("Closing log file. Keyboard Interrupt.")
|
|
50
|
-
info(
|
|
51
|
-
|
|
53
|
+
info(
|
|
54
|
+
"Note that your server is still running! Shut it down "
|
|
55
|
+
f"with {Fore.RED}v6 server stop{Style.RESET_ALL}"
|
|
56
|
+
)
|
|
52
57
|
exit(0)
|
|
53
58
|
else:
|
|
54
59
|
error(f"{Fore.RED}{name}{Style.RESET_ALL} was not running!?")
|
|
@@ -6,11 +6,11 @@ import click
|
|
|
6
6
|
from colorama import Fore, Style
|
|
7
7
|
|
|
8
8
|
from vantage6.common import error, info
|
|
9
|
-
from vantage6.common.globals import STRING_ENCODING, APPNAME
|
|
9
|
+
from vantage6.common.globals import STRING_ENCODING, APPNAME, InstanceType
|
|
10
10
|
from vantage6.common.docker.addons import remove_container, get_container
|
|
11
11
|
|
|
12
12
|
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
13
|
-
from vantage6.cli.context import ServerContext
|
|
13
|
+
from vantage6.cli.context.server import ServerContext
|
|
14
14
|
from vantage6.cli.configuration_wizard import select_configuration_questionaire
|
|
15
15
|
|
|
16
16
|
|
|
@@ -29,19 +29,33 @@ def click_insert_context(func: callable) -> callable:
|
|
|
29
29
|
Callable
|
|
30
30
|
Click function with context
|
|
31
31
|
"""
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@click.option(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
|
|
33
|
+
@click.option(
|
|
34
|
+
"-n", "--name", default=None, help="Name of the configuration you want to use."
|
|
35
|
+
)
|
|
36
|
+
@click.option(
|
|
37
|
+
"-c",
|
|
38
|
+
"--config",
|
|
39
|
+
default=None,
|
|
40
|
+
help="Absolute path to configuration-file; overrides NAME",
|
|
41
|
+
)
|
|
42
|
+
@click.option(
|
|
43
|
+
"--system",
|
|
44
|
+
"system_folders",
|
|
45
|
+
flag_value=True,
|
|
46
|
+
help="Use system folders instead of user folders. This is " "the default",
|
|
47
|
+
)
|
|
48
|
+
@click.option(
|
|
49
|
+
"--user",
|
|
50
|
+
"system_folders",
|
|
51
|
+
flag_value=False,
|
|
52
|
+
default=DEFAULT_SERVER_SYSTEM_FOLDERS,
|
|
53
|
+
help="Use user folders instead of system folders",
|
|
54
|
+
)
|
|
42
55
|
@wraps(func)
|
|
43
|
-
def func_with_context(
|
|
44
|
-
|
|
56
|
+
def func_with_context(
|
|
57
|
+
name: str, config: str, system_folders: bool, *args, **kwargs
|
|
58
|
+
) -> callable:
|
|
45
59
|
"""
|
|
46
60
|
Decorator function that adds the context to the function.
|
|
47
61
|
|
|
@@ -52,14 +66,11 @@ def click_insert_context(func: callable) -> callable:
|
|
|
52
66
|
"""
|
|
53
67
|
# path to configuration file always overrides name
|
|
54
68
|
if config:
|
|
55
|
-
ctx = ServerContext.from_external_config_file(
|
|
56
|
-
|
|
57
|
-
system_folders
|
|
58
|
-
)
|
|
59
|
-
elif 'ctx' in kwargs:
|
|
69
|
+
ctx = ServerContext.from_external_config_file(config, system_folders)
|
|
70
|
+
elif "ctx" in kwargs:
|
|
60
71
|
# if ctx is already in kwargs (typically when one click command
|
|
61
72
|
# calls another internally), use that existing ctx
|
|
62
|
-
ctx = kwargs.pop(
|
|
73
|
+
ctx = kwargs.pop("ctx")
|
|
63
74
|
else:
|
|
64
75
|
# in case no name, ctx or config file is supplied, ask the user to
|
|
65
76
|
# select an existing config by name
|
|
@@ -67,7 +78,7 @@ def click_insert_context(func: callable) -> callable:
|
|
|
67
78
|
try:
|
|
68
79
|
# select configuration if none supplied
|
|
69
80
|
name = select_configuration_questionaire(
|
|
70
|
-
|
|
81
|
+
InstanceType.SERVER, system_folders
|
|
71
82
|
)
|
|
72
83
|
except Exception:
|
|
73
84
|
error("No configurations could be found!")
|
|
@@ -79,8 +90,7 @@ def click_insert_context(func: callable) -> callable:
|
|
|
79
90
|
return func_with_context
|
|
80
91
|
|
|
81
92
|
|
|
82
|
-
def get_server_context(name: str, system_folders: bool)
|
|
83
|
-
-> ServerContext:
|
|
93
|
+
def get_server_context(name: str, system_folders: bool) -> ServerContext:
|
|
84
94
|
"""
|
|
85
95
|
Load the server context from the configuration file.
|
|
86
96
|
|
|
@@ -142,5 +152,7 @@ def stop_ui(client: DockerClient, ctx: ServerContext) -> None:
|
|
|
142
152
|
ui_container = get_container(client, name=ui_container_name)
|
|
143
153
|
if ui_container:
|
|
144
154
|
remove_container(ui_container, kill=True)
|
|
145
|
-
info(
|
|
146
|
-
|
|
155
|
+
info(
|
|
156
|
+
f"Stopped the {Fore.GREEN}{ui_container_name}"
|
|
157
|
+
f"{Style.RESET_ALL} User Interface container."
|
|
158
|
+
)
|