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/server/import_.py
CHANGED
|
@@ -4,6 +4,7 @@ from threading import Thread
|
|
|
4
4
|
import click
|
|
5
5
|
import docker
|
|
6
6
|
from sqlalchemy.engine.url import make_url
|
|
7
|
+
from vantage6.cli.globals import ServerGlobals
|
|
7
8
|
|
|
8
9
|
from vantage6.common import info, warning
|
|
9
10
|
from vantage6.common.docker.addons import check_docker_running
|
|
@@ -11,28 +12,44 @@ from vantage6.common.globals import (
|
|
|
11
12
|
APPNAME,
|
|
12
13
|
DEFAULT_DOCKER_REGISTRY,
|
|
13
14
|
DEFAULT_SERVER_IMAGE,
|
|
15
|
+
InstanceType,
|
|
14
16
|
)
|
|
15
|
-
from vantage6.cli.context import ServerContext
|
|
17
|
+
from vantage6.cli.context.server import ServerContext
|
|
16
18
|
from vantage6.cli.utils import check_config_name_allowed
|
|
17
19
|
from vantage6.cli.server.common import click_insert_context, print_log_worker
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
# TODO this method has a lot of duplicated code from `start`
|
|
21
23
|
@click.command()
|
|
22
|
-
@click.argument(
|
|
23
|
-
@click.option(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@click.option(
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
@click.argument("file", type=click.Path(exists=True))
|
|
25
|
+
@click.option(
|
|
26
|
+
"--drop-all",
|
|
27
|
+
is_flag=True,
|
|
28
|
+
default=False,
|
|
29
|
+
help="Drop all existing data before importing",
|
|
30
|
+
)
|
|
31
|
+
@click.option("-i", "--image", default=None, help="Node Docker image to use")
|
|
32
|
+
@click.option(
|
|
33
|
+
"--mount-src",
|
|
34
|
+
default="",
|
|
35
|
+
help="Override vantage6 source code in container with the source"
|
|
36
|
+
" code in this path",
|
|
37
|
+
)
|
|
38
|
+
@click.option(
|
|
39
|
+
"--keep/--auto-remove",
|
|
40
|
+
default=False,
|
|
41
|
+
help="Keep image after finishing. Useful for debugging",
|
|
42
|
+
)
|
|
43
|
+
@click.option("--wait", default=False, help="Wait for the import to finish")
|
|
32
44
|
@click_insert_context
|
|
33
45
|
def cli_server_import(
|
|
34
|
-
ctx: ServerContext,
|
|
35
|
-
|
|
46
|
+
ctx: ServerContext,
|
|
47
|
+
file: str,
|
|
48
|
+
drop_all: bool,
|
|
49
|
+
image: str,
|
|
50
|
+
mount_src: str,
|
|
51
|
+
keep: bool,
|
|
52
|
+
wait: bool,
|
|
36
53
|
) -> None:
|
|
37
54
|
"""
|
|
38
55
|
Import vantage6 resources into a server instance.
|
|
@@ -56,31 +73,26 @@ def cli_server_import(
|
|
|
56
73
|
# pull latest Docker image
|
|
57
74
|
if image is None:
|
|
58
75
|
image = ctx.config.get(
|
|
59
|
-
"image",
|
|
60
|
-
f"{DEFAULT_DOCKER_REGISTRY}/{DEFAULT_SERVER_IMAGE}"
|
|
76
|
+
"image", f"{DEFAULT_DOCKER_REGISTRY}/{DEFAULT_SERVER_IMAGE}"
|
|
61
77
|
)
|
|
62
78
|
info(f"Pulling latest server image '{image}'.")
|
|
63
79
|
try:
|
|
64
80
|
docker_client.images.pull(image)
|
|
65
81
|
except Exception as e:
|
|
66
|
-
warning(
|
|
82
|
+
warning(" ... Getting latest node image failed:")
|
|
67
83
|
warning(f" {e}")
|
|
68
84
|
else:
|
|
69
85
|
info(" ... success!")
|
|
70
86
|
|
|
71
87
|
info("Creating mounts")
|
|
72
88
|
mounts = [
|
|
73
|
-
docker.types.Mount(
|
|
74
|
-
|
|
75
|
-
),
|
|
76
|
-
docker.types.Mount(
|
|
77
|
-
"/mnt/import.yaml", str(file), type="bind"
|
|
78
|
-
)
|
|
89
|
+
docker.types.Mount("/mnt/config.yaml", str(ctx.config_file), type="bind"),
|
|
90
|
+
docker.types.Mount("/mnt/import.yaml", str(file), type="bind"),
|
|
79
91
|
]
|
|
80
92
|
|
|
81
93
|
# FIXME: code duplication with cli_server_start()
|
|
82
94
|
# try to mount database
|
|
83
|
-
uri = ctx.config[
|
|
95
|
+
uri = ctx.config["uri"]
|
|
84
96
|
url = make_url(uri)
|
|
85
97
|
environment_vars = None
|
|
86
98
|
|
|
@@ -89,7 +101,7 @@ def cli_server_import(
|
|
|
89
101
|
mounts.append(docker.types.Mount("/vantage6", mount_src, type="bind"))
|
|
90
102
|
|
|
91
103
|
# If host is None, we're dealing with a file-based DB, like SQLite
|
|
92
|
-
if
|
|
104
|
+
if url.host is None:
|
|
93
105
|
db_path = url.database
|
|
94
106
|
|
|
95
107
|
if not os.path.isabs(db_path):
|
|
@@ -101,22 +113,21 @@ def cli_server_import(
|
|
|
101
113
|
os.makedirs(dirname, exist_ok=True)
|
|
102
114
|
|
|
103
115
|
# we're mounting the entire folder that contains the database
|
|
104
|
-
mounts.append(docker.types.Mount(
|
|
105
|
-
"/mnt/database/", dirname, type="bind"
|
|
106
|
-
))
|
|
116
|
+
mounts.append(docker.types.Mount("/mnt/database/", dirname, type="bind"))
|
|
107
117
|
|
|
108
118
|
environment_vars = {
|
|
109
|
-
|
|
119
|
+
ServerGlobals.DB_URI_ENV_VAR: f"sqlite:////mnt/database/{basename}"
|
|
110
120
|
}
|
|
111
121
|
|
|
112
122
|
else:
|
|
113
|
-
warning(
|
|
114
|
-
|
|
123
|
+
warning(
|
|
124
|
+
f"Database could not be transferred, make sure {url.host} "
|
|
125
|
+
"is reachable from the Docker container"
|
|
126
|
+
)
|
|
115
127
|
info("Consider using the docker-compose method to start a server")
|
|
116
128
|
|
|
117
129
|
drop_all_ = "--drop-all" if drop_all else ""
|
|
118
|
-
cmd =
|
|
119
|
-
'/mnt/import.yaml')
|
|
130
|
+
cmd = f"vserver-local import -c /mnt/config.yaml {drop_all_} " "/mnt/import.yaml"
|
|
120
131
|
|
|
121
132
|
info(cmd)
|
|
122
133
|
|
|
@@ -126,13 +137,10 @@ def cli_server_import(
|
|
|
126
137
|
command=cmd,
|
|
127
138
|
mounts=mounts,
|
|
128
139
|
detach=True,
|
|
129
|
-
labels={
|
|
130
|
-
f"{APPNAME}-type": "server",
|
|
131
|
-
"name": ctx.config_file_name
|
|
132
|
-
},
|
|
140
|
+
labels={f"{APPNAME}-type": InstanceType.SERVER, "name": ctx.config_file_name},
|
|
133
141
|
environment=environment_vars,
|
|
134
142
|
auto_remove=not keep,
|
|
135
|
-
tty=True
|
|
143
|
+
tty=True,
|
|
136
144
|
)
|
|
137
145
|
logs = container.logs(stream=True, stdout=True)
|
|
138
146
|
Thread(target=print_log_worker, args=(logs,), daemon=False).start()
|
vantage6/cli/server/list.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import click
|
|
2
2
|
import docker
|
|
3
3
|
|
|
4
|
-
from colorama import
|
|
4
|
+
from colorama import Fore, Style
|
|
5
5
|
|
|
6
6
|
from vantage6.common import warning
|
|
7
7
|
from vantage6.common.docker.addons import check_docker_running
|
|
8
|
-
from vantage6.common.globals import APPNAME
|
|
9
|
-
from vantage6.cli.context import ServerContext
|
|
8
|
+
from vantage6.common.globals import APPNAME, InstanceType
|
|
9
|
+
from vantage6.cli.context.server import ServerContext
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@click.command()
|
|
@@ -18,18 +18,16 @@ def cli_server_configuration_list() -> None:
|
|
|
18
18
|
client = docker.from_env()
|
|
19
19
|
|
|
20
20
|
running_server = client.containers.list(
|
|
21
|
-
filters={"label": f"{APPNAME}-type=
|
|
21
|
+
filters={"label": f"{APPNAME}-type={InstanceType.SERVER}"}
|
|
22
|
+
)
|
|
22
23
|
running_node_names = []
|
|
23
24
|
for node in running_server:
|
|
24
25
|
running_node_names.append(node.name)
|
|
25
26
|
|
|
26
|
-
header = \
|
|
27
|
-
"\nName"+(21*" ") + \
|
|
28
|
-
"Status"+(10*" ") + \
|
|
29
|
-
"System/User"
|
|
27
|
+
header = "\nName" + (21 * " ") + "Status" + (10 * " ") + "System/User"
|
|
30
28
|
|
|
31
29
|
click.echo(header)
|
|
32
|
-
click.echo("-"*len(header))
|
|
30
|
+
click.echo("-" * len(header))
|
|
33
31
|
|
|
34
32
|
running = Fore.GREEN + "Running" + Style.RESET_ALL
|
|
35
33
|
stopped = Fore.RED + "Not running" + Style.RESET_ALL
|
|
@@ -37,24 +35,25 @@ def cli_server_configuration_list() -> None:
|
|
|
37
35
|
# system folders
|
|
38
36
|
configs, f1 = ServerContext.available_configurations(system_folders=True)
|
|
39
37
|
for config in configs:
|
|
40
|
-
status =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
status = (
|
|
39
|
+
running
|
|
40
|
+
if f"{APPNAME}-{config.name}-system-{InstanceType.SERVER}"
|
|
41
|
+
in running_node_names
|
|
42
|
+
else stopped
|
|
45
43
|
)
|
|
44
|
+
click.echo(f"{config.name:25}" f"{status:25} System ")
|
|
46
45
|
|
|
47
46
|
# user folders
|
|
48
47
|
configs, f2 = ServerContext.available_configurations(system_folders=False)
|
|
49
48
|
for config in configs:
|
|
50
|
-
status =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
status = (
|
|
50
|
+
running
|
|
51
|
+
if f"{APPNAME}-{config.name}-user-{InstanceType.SERVER}"
|
|
52
|
+
in running_node_names
|
|
53
|
+
else stopped
|
|
55
54
|
)
|
|
55
|
+
click.echo(f"{config.name:25}" f"{status:25} User ")
|
|
56
56
|
|
|
57
|
-
click.echo("-"*85)
|
|
58
|
-
if len(f1)+len(f2):
|
|
59
|
-
warning(
|
|
60
|
-
f"{Fore.RED}Failed imports: {len(f1)+len(f2)}{Style.RESET_ALL}")
|
|
57
|
+
click.echo("-" * 85)
|
|
58
|
+
if len(f1) + len(f2):
|
|
59
|
+
warning(f"{Fore.RED}Failed imports: {len(f1)+len(f2)}{Style.RESET_ALL}")
|
vantage6/cli/server/new.py
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import click
|
|
2
|
-
from colorama import
|
|
2
|
+
from colorama import Fore, Style
|
|
3
3
|
|
|
4
4
|
from vantage6.common import info, error, check_config_writeable
|
|
5
5
|
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
6
|
-
from vantage6.cli.context import ServerContext
|
|
6
|
+
from vantage6.cli.context.server import ServerContext
|
|
7
7
|
from vantage6.cli.configuration_wizard import configuration_wizard
|
|
8
8
|
from vantage6.cli.utils import check_config_name_allowed, prompt_config_name
|
|
9
|
+
from vantage6.common.globals import InstanceType
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
@click.command()
|
|
12
|
-
@click.option(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@click.option(
|
|
16
|
-
|
|
13
|
+
@click.option(
|
|
14
|
+
"-n", "--name", default=None, help="name of the configuration you want to use."
|
|
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
|
+
)
|
|
17
20
|
def cli_server_new(name: str, system_folders: bool) -> None:
|
|
18
21
|
"""
|
|
19
22
|
Create a new server configuration.
|
|
@@ -26,8 +29,7 @@ def cli_server_new(name: str, system_folders: bool) -> None:
|
|
|
26
29
|
# check that this config does not exist
|
|
27
30
|
try:
|
|
28
31
|
if ServerContext.config_exists(name, system_folders):
|
|
29
|
-
error(f"Configuration {Fore.RED}{name}{Style.RESET_ALL} already "
|
|
30
|
-
"exists!")
|
|
32
|
+
error(f"Configuration {Fore.RED}{name}{Style.RESET_ALL} already " "exists!")
|
|
31
33
|
exit(1)
|
|
32
34
|
except Exception as e:
|
|
33
35
|
error(e)
|
|
@@ -36,15 +38,19 @@ def cli_server_new(name: str, system_folders: bool) -> None:
|
|
|
36
38
|
# Check that we can write in this folder
|
|
37
39
|
if not check_config_writeable(system_folders):
|
|
38
40
|
error("Your user does not have write access to all folders. Exiting")
|
|
39
|
-
info(
|
|
40
|
-
|
|
41
|
+
info(
|
|
42
|
+
f"Create a new server using '{Fore.GREEN}v6 server new "
|
|
43
|
+
f"--user{Style.RESET_ALL}' instead!"
|
|
44
|
+
)
|
|
41
45
|
exit(1)
|
|
42
46
|
|
|
43
47
|
# create config in ctx location
|
|
44
|
-
cfg_file = configuration_wizard(
|
|
48
|
+
cfg_file = configuration_wizard(InstanceType.SERVER, name, system_folders)
|
|
45
49
|
info(f"New configuration created: {Fore.GREEN}{cfg_file}{Style.RESET_ALL}")
|
|
46
50
|
|
|
47
51
|
# info(f"root user created.")
|
|
48
52
|
flag = "" if system_folders else "--user"
|
|
49
|
-
info(
|
|
50
|
-
|
|
53
|
+
info(
|
|
54
|
+
f"You can start the server by running {Fore.GREEN}v6 server start "
|
|
55
|
+
f"{flag}{Style.RESET_ALL}"
|
|
56
|
+
)
|
vantage6/cli/server/remove.py
CHANGED
|
@@ -11,7 +11,7 @@ from vantage6.cli.utils import remove_file
|
|
|
11
11
|
|
|
12
12
|
@click.command()
|
|
13
13
|
@click_insert_context
|
|
14
|
-
@click.option(
|
|
14
|
+
@click.option("-f", "--force", "force", flag_value=True)
|
|
15
15
|
def cli_server_remove(ctx: ServerContext, force: bool) -> None:
|
|
16
16
|
"""
|
|
17
17
|
Function to remove a server.
|
|
@@ -28,14 +28,15 @@ def cli_server_remove(ctx: ServerContext, force: bool) -> None:
|
|
|
28
28
|
if not force:
|
|
29
29
|
if not q.confirm(
|
|
30
30
|
"This server will be deleted permanently including its "
|
|
31
|
-
"configuration. Are you sure?",
|
|
31
|
+
"configuration. Are you sure?",
|
|
32
|
+
default=False,
|
|
32
33
|
).ask():
|
|
33
34
|
info("Server will not be deleted")
|
|
34
35
|
exit(0)
|
|
35
36
|
|
|
36
37
|
# now remove the folders...
|
|
37
|
-
remove_file(ctx.config_file,
|
|
38
|
+
remove_file(ctx.config_file, "configuration")
|
|
38
39
|
|
|
39
40
|
for handler in itertools.chain(ctx.log.handlers, ctx.log.root.handlers):
|
|
40
41
|
handler.close()
|
|
41
|
-
remove_file(ctx.log_file,
|
|
42
|
+
remove_file(ctx.log_file, "log")
|
vantage6/cli/server/shell.py
CHANGED
|
@@ -2,12 +2,12 @@ import subprocess
|
|
|
2
2
|
|
|
3
3
|
import click
|
|
4
4
|
import docker
|
|
5
|
-
from colorama import
|
|
5
|
+
from colorama import Fore, Style
|
|
6
6
|
|
|
7
7
|
from vantage6.common import info, error, debug as debug_msg
|
|
8
8
|
from vantage6.common.docker.addons import check_docker_running
|
|
9
|
-
from vantage6.common.globals import APPNAME
|
|
10
|
-
from vantage6.cli.context import ServerContext
|
|
9
|
+
from vantage6.common.globals import APPNAME, InstanceType
|
|
10
|
+
from vantage6.cli.context.server import ServerContext
|
|
11
11
|
from vantage6.cli.server.common import click_insert_context
|
|
12
12
|
|
|
13
13
|
|
|
@@ -28,15 +28,26 @@ 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=
|
|
31
|
+
filters={"label": f"{APPNAME}-type={InstanceType.SERVER}"}
|
|
32
|
+
)
|
|
32
33
|
|
|
33
34
|
if ctx.docker_container_name not in [s.name for s in running_servers]:
|
|
34
35
|
error(f"Server {Fore.RED}{ctx.name}{Style.RESET_ALL} is not running?")
|
|
35
36
|
return
|
|
36
37
|
|
|
37
38
|
try:
|
|
38
|
-
subprocess.run(
|
|
39
|
-
|
|
39
|
+
subprocess.run(
|
|
40
|
+
[
|
|
41
|
+
"docker",
|
|
42
|
+
"exec",
|
|
43
|
+
"-it",
|
|
44
|
+
ctx.docker_container_name,
|
|
45
|
+
"vserver-local",
|
|
46
|
+
"shell",
|
|
47
|
+
"-c",
|
|
48
|
+
"/mnt/config.yaml",
|
|
49
|
+
]
|
|
50
|
+
)
|
|
40
51
|
except Exception as e:
|
|
41
52
|
info("Failed to start subprocess...")
|
|
42
53
|
debug_msg(e)
|