vantage6 5.0.0a34__py3-none-any.whl → 5.0.0a36__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.
- vantage6/cli/algorithm/generate_algorithm_json.py +9 -9
- vantage6/cli/algorithm/update.py +1 -1
- vantage6/cli/algostore/attach.py +1 -0
- vantage6/cli/algostore/files.py +3 -2
- vantage6/cli/algostore/list.py +0 -3
- vantage6/cli/algostore/new.py +83 -2
- vantage6/cli/algostore/remove.py +18 -34
- vantage6/cli/algostore/start.py +10 -7
- vantage6/cli/algostore/stop.py +12 -50
- vantage6/cli/auth/attach.py +60 -0
- vantage6/cli/auth/files.py +16 -0
- vantage6/cli/auth/list.py +13 -0
- vantage6/cli/auth/new.py +80 -0
- vantage6/cli/auth/remove.py +31 -0
- vantage6/cli/auth/start.py +80 -0
- vantage6/cli/auth/stop.py +64 -0
- vantage6/cli/cli.py +67 -37
- vantage6/cli/common/new.py +28 -3
- vantage6/cli/common/remove.py +54 -0
- vantage6/cli/common/start.py +31 -2
- vantage6/cli/common/stop.py +79 -1
- vantage6/cli/common/utils.py +47 -4
- vantage6/cli/configuration_manager.py +57 -13
- vantage6/cli/configuration_wizard.py +18 -397
- vantage6/cli/context/__init__.py +3 -0
- vantage6/cli/context/auth.py +107 -0
- vantage6/cli/context/base_server.py +0 -4
- vantage6/cli/context/node.py +10 -17
- vantage6/cli/dev/clean.py +28 -0
- vantage6/cli/dev/common.py +34 -0
- vantage6/cli/dev/rebuild.py +39 -0
- vantage6/cli/dev/start.py +36 -0
- vantage6/cli/dev/stop.py +23 -0
- vantage6/cli/globals.py +24 -1
- vantage6/cli/node/attach.py +1 -0
- vantage6/cli/node/files.py +12 -25
- vantage6/cli/node/list.py +5 -4
- vantage6/cli/node/new.py +348 -28
- vantage6/cli/node/remove.py +14 -90
- vantage6/cli/node/restart.py +30 -51
- vantage6/cli/node/start.py +81 -304
- vantage6/cli/node/stop.py +36 -96
- vantage6/cli/node/version.py +5 -4
- vantage6/cli/prometheus/monitoring_manager.py +5 -3
- vantage6/cli/rabbitmq/queue_manager.py +13 -11
- vantage6/cli/server/attach.py +1 -0
- vantage6/cli/server/common/__init__.py +1 -27
- vantage6/cli/server/import_.py +1 -1
- vantage6/cli/server/new.py +83 -2
- vantage6/cli/server/remove.py +12 -33
- vantage6/cli/server/start.py +8 -6
- vantage6/cli/server/stop.py +10 -39
- vantage6/cli/template/algo_store_config.j2 +1 -1
- vantage6/cli/template/auth_config.j2 +230 -0
- vantage6/cli/template/node_config.j2 +336 -33
- vantage6/cli/template/node_config_nonk8s.j2 +33 -0
- vantage6/cli/test/common/diagnostic_runner.py +5 -3
- vantage6/cli/use/namespace.py +2 -1
- vantage6/cli/utils.py +0 -2
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a36.dist-info}/METADATA +3 -3
- vantage6-5.0.0a36.dist-info/RECORD +86 -0
- vantage6/cli/dev/create.py +0 -693
- vantage6/cli/dev/data/km_dataset.csv +0 -2401
- vantage6/cli/dev/remove.py +0 -112
- vantage6/cli/node/clean.py +0 -46
- vantage6/cli/server/shell.py +0 -54
- vantage6-5.0.0a34.dist-info/RECORD +0 -75
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a36.dist-info}/WHEEL +0 -0
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a36.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from vantage6.common import info
|
|
4
|
+
from vantage6.common.globals import InstanceType
|
|
5
|
+
|
|
6
|
+
from vantage6.cli.common.stop import execute_stop, helm_uninstall, stop_port_forward
|
|
7
|
+
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS, InfraComponentName
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@click.command()
|
|
11
|
+
@click.option("-n", "--name", default=None, help="Configuration name")
|
|
12
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
13
|
+
@click.option("--namespace", default=None, help="Kubernetes namespace to use")
|
|
14
|
+
@click.option(
|
|
15
|
+
"--system",
|
|
16
|
+
"system_folders",
|
|
17
|
+
flag_value=True,
|
|
18
|
+
default=DEFAULT_SERVER_SYSTEM_FOLDERS,
|
|
19
|
+
help="Search for configuration in system folders instead of user folders. "
|
|
20
|
+
"This is the default.",
|
|
21
|
+
)
|
|
22
|
+
@click.option(
|
|
23
|
+
"--user",
|
|
24
|
+
"system_folders",
|
|
25
|
+
flag_value=False,
|
|
26
|
+
help="Search for configuration in the user folders instead of system folders.",
|
|
27
|
+
)
|
|
28
|
+
def cli_auth_stop(
|
|
29
|
+
name: str,
|
|
30
|
+
context: str,
|
|
31
|
+
namespace: str,
|
|
32
|
+
system_folders: bool,
|
|
33
|
+
):
|
|
34
|
+
"""
|
|
35
|
+
Stop a running auth service.
|
|
36
|
+
"""
|
|
37
|
+
execute_stop(
|
|
38
|
+
stop_function=_stop_auth,
|
|
39
|
+
instance_type=InstanceType.AUTH,
|
|
40
|
+
infra_component=InfraComponentName.AUTH,
|
|
41
|
+
stop_all=False,
|
|
42
|
+
to_stop=name,
|
|
43
|
+
namespace=namespace,
|
|
44
|
+
context=context,
|
|
45
|
+
system_folders=system_folders,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _stop_auth(auth_name: str, namespace: str, context: str) -> None:
|
|
50
|
+
info(f"Stopping auth {auth_name}...")
|
|
51
|
+
|
|
52
|
+
# uninstall the helm release
|
|
53
|
+
helm_uninstall(
|
|
54
|
+
release_name=auth_name,
|
|
55
|
+
context=context,
|
|
56
|
+
namespace=namespace,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# stop the port forwarding for auth service
|
|
60
|
+
stop_port_forward(
|
|
61
|
+
service_name=f"{auth_name}-keycloak",
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
info(f"Auth {auth_name} stopped successfully.")
|
vantage6/cli/cli.py
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
from vantage6.cli.
|
|
4
|
-
from vantage6.cli.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from vantage6.cli.
|
|
8
|
-
from vantage6.cli.
|
|
9
|
-
from vantage6.cli.
|
|
10
|
-
from vantage6.cli.
|
|
11
|
-
from vantage6.cli.
|
|
12
|
-
from vantage6.cli.
|
|
3
|
+
from vantage6.cli.algorithm.create import cli_algorithm_create
|
|
4
|
+
from vantage6.cli.algorithm.generate_algorithm_json import (
|
|
5
|
+
cli_algorithm_generate_algorithm_json,
|
|
6
|
+
)
|
|
7
|
+
from vantage6.cli.algorithm.update import cli_algorithm_update
|
|
8
|
+
from vantage6.cli.algostore.attach import cli_algo_store_attach
|
|
9
|
+
from vantage6.cli.algostore.files import cli_algo_store_files
|
|
10
|
+
from vantage6.cli.algostore.list import cli_algo_store_configuration_list
|
|
11
|
+
from vantage6.cli.algostore.new import cli_algo_store_new
|
|
12
|
+
from vantage6.cli.algostore.remove import cli_algo_store_remove
|
|
13
|
+
from vantage6.cli.algostore.start import cli_algo_store_start
|
|
14
|
+
from vantage6.cli.algostore.stop import cli_algo_store_stop
|
|
15
|
+
from vantage6.cli.auth.attach import cli_auth_attach
|
|
16
|
+
from vantage6.cli.auth.files import cli_auth_files
|
|
17
|
+
from vantage6.cli.auth.list import cli_auth_configuration_list
|
|
18
|
+
from vantage6.cli.auth.new import cli_auth_new
|
|
19
|
+
from vantage6.cli.auth.remove import cli_auth_remove
|
|
20
|
+
from vantage6.cli.auth.start import cli_auth_start
|
|
21
|
+
from vantage6.cli.auth.stop import cli_auth_stop
|
|
22
|
+
from vantage6.cli.dev.clean import cli_clean_dev_env
|
|
23
|
+
from vantage6.cli.dev.rebuild import cli_rebuild_dev_env
|
|
24
|
+
from vantage6.cli.dev.start import cli_start_dev_env
|
|
25
|
+
from vantage6.cli.dev.stop import cli_stop_dev_env
|
|
26
|
+
from vantage6.cli.globals import CLICommandName
|
|
13
27
|
from vantage6.cli.node.attach import cli_node_attach
|
|
14
|
-
from vantage6.cli.node.clean import cli_node_clean
|
|
15
28
|
from vantage6.cli.node.create_private_key import cli_node_create_private_key
|
|
16
29
|
from vantage6.cli.node.files import cli_node_files
|
|
17
30
|
from vantage6.cli.node.list import cli_node_list
|
|
@@ -22,29 +35,25 @@ from vantage6.cli.node.set_api_key import cli_node_set_api_key
|
|
|
22
35
|
from vantage6.cli.node.start import cli_node_start
|
|
23
36
|
from vantage6.cli.node.stop import cli_node_stop
|
|
24
37
|
from vantage6.cli.node.version import cli_node_version
|
|
25
|
-
from vantage6.cli.
|
|
26
|
-
from vantage6.cli.
|
|
27
|
-
from vantage6.cli.
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
from vantage6.cli.server.attach import cli_server_attach
|
|
39
|
+
from vantage6.cli.server.files import cli_server_files
|
|
40
|
+
from vantage6.cli.server.import_ import cli_server_import
|
|
41
|
+
from vantage6.cli.server.list import cli_server_configuration_list
|
|
42
|
+
from vantage6.cli.server.new import cli_server_new
|
|
43
|
+
from vantage6.cli.server.remove import cli_server_remove
|
|
44
|
+
from vantage6.cli.server.start import cli_server_start
|
|
45
|
+
from vantage6.cli.server.stop import cli_server_stop
|
|
46
|
+
from vantage6.cli.server.version import cli_server_version
|
|
30
47
|
|
|
31
48
|
# from vantage6.cli.test.client_script import cli_test_client_script
|
|
32
|
-
from vantage6.cli.test.feature_tester import cli_test_features
|
|
33
|
-
|
|
34
49
|
# from vantage6.cli.test.integration_test import cli_test_integration
|
|
35
|
-
from vantage6.cli.
|
|
36
|
-
from vantage6.cli.algostore.new import cli_algo_store_new
|
|
37
|
-
from vantage6.cli.algostore.start import cli_algo_store_start
|
|
38
|
-
from vantage6.cli.algostore.stop import cli_algo_store_stop
|
|
39
|
-
from vantage6.cli.algostore.files import cli_algo_store_files
|
|
40
|
-
from vantage6.cli.algostore.list import cli_algo_store_configuration_list
|
|
41
|
-
from vantage6.cli.algostore.remove import cli_algo_store_remove
|
|
50
|
+
from vantage6.cli.test.feature_tester import cli_test_features
|
|
42
51
|
from vantage6.cli.use.context import cli_use_context
|
|
43
52
|
from vantage6.cli.use.namespace import cli_use_namespace
|
|
44
53
|
|
|
45
54
|
|
|
46
55
|
# Define the server group
|
|
47
|
-
@click.group(name=
|
|
56
|
+
@click.group(name=CLICommandName.SERVER.value)
|
|
48
57
|
def cli_server() -> None:
|
|
49
58
|
"""
|
|
50
59
|
Manage your vantage6 server instances.
|
|
@@ -58,14 +67,13 @@ cli_server.add_command(cli_server_import, name="import")
|
|
|
58
67
|
cli_server.add_command(cli_server_configuration_list, name="list")
|
|
59
68
|
cli_server.add_command(cli_server_new, name="new")
|
|
60
69
|
cli_server.add_command(cli_server_remove, name="remove")
|
|
61
|
-
cli_server.add_command(cli_server_shell, name="shell")
|
|
62
70
|
cli_server.add_command(cli_server_start, name="start")
|
|
63
71
|
cli_server.add_command(cli_server_stop, name="stop")
|
|
64
72
|
cli_server.add_command(cli_server_version, name="version")
|
|
65
73
|
|
|
66
74
|
|
|
67
75
|
# Define the node group
|
|
68
|
-
@click.group(name=
|
|
76
|
+
@click.group(name=CLICommandName.NODE.value)
|
|
69
77
|
def cli_node() -> None:
|
|
70
78
|
"""
|
|
71
79
|
Manage your vantage6 node instances.
|
|
@@ -74,7 +82,6 @@ def cli_node() -> None:
|
|
|
74
82
|
|
|
75
83
|
# Define the commands for the node group
|
|
76
84
|
cli_node.add_command(cli_node_attach, name="attach")
|
|
77
|
-
cli_node.add_command(cli_node_clean, name="clean")
|
|
78
85
|
cli_node.add_command(cli_node_create_private_key, name="create-private-key")
|
|
79
86
|
cli_node.add_command(cli_node_files, name="files")
|
|
80
87
|
cli_node.add_command(cli_node_list, name="list")
|
|
@@ -88,20 +95,24 @@ cli_node.add_command(cli_node_version, name="version")
|
|
|
88
95
|
|
|
89
96
|
|
|
90
97
|
# Define the dev group
|
|
91
|
-
@click.group(name=
|
|
98
|
+
@click.group(name=CLICommandName.DEV.value)
|
|
92
99
|
def cli_dev() -> None:
|
|
93
100
|
"""
|
|
94
|
-
|
|
101
|
+
Spin up a local development network.
|
|
95
102
|
|
|
96
|
-
|
|
103
|
+
In this environment, any code changes you make will be reflected in the running
|
|
104
|
+
services.
|
|
97
105
|
"""
|
|
98
106
|
|
|
99
107
|
|
|
100
|
-
|
|
108
|
+
cli_dev.add_command(cli_start_dev_env, name="start")
|
|
109
|
+
cli_dev.add_command(cli_stop_dev_env, name="stop")
|
|
110
|
+
cli_dev.add_command(cli_rebuild_dev_env, name="rebuild")
|
|
111
|
+
cli_dev.add_command(cli_clean_dev_env, name="clean")
|
|
101
112
|
|
|
102
113
|
|
|
103
114
|
# Define the algorithm group
|
|
104
|
-
@click.group(name=
|
|
115
|
+
@click.group(name=CLICommandName.ALGORITHM.value)
|
|
105
116
|
def cli_algorithm() -> None:
|
|
106
117
|
"""
|
|
107
118
|
Manage your vantage6 algorithms.
|
|
@@ -117,7 +128,7 @@ cli_algorithm.add_command(
|
|
|
117
128
|
|
|
118
129
|
|
|
119
130
|
# Define the test group
|
|
120
|
-
@click.group(name=
|
|
131
|
+
@click.group(name=CLICommandName.TEST.value)
|
|
121
132
|
def cli_test() -> None:
|
|
122
133
|
"""
|
|
123
134
|
Execute tests on your vantage6 infrastructure.
|
|
@@ -131,7 +142,7 @@ cli_test.add_command(cli_test_features, name="feature-test")
|
|
|
131
142
|
|
|
132
143
|
|
|
133
144
|
# Define the algorithm-store group
|
|
134
|
-
@click.group(name=
|
|
145
|
+
@click.group(name=CLICommandName.ALGORITHM_STORE.value)
|
|
135
146
|
def cli_algo_store() -> None:
|
|
136
147
|
"""
|
|
137
148
|
Manage your vantage6 algorithm store server instances.
|
|
@@ -148,8 +159,26 @@ cli_algo_store.add_command(cli_algo_store_configuration_list, name="list")
|
|
|
148
159
|
cli_algo_store.add_command(cli_algo_store_remove, name="remove")
|
|
149
160
|
|
|
150
161
|
|
|
162
|
+
# Define the auth group
|
|
163
|
+
@click.group(name=CLICommandName.AUTH.value)
|
|
164
|
+
def cli_auth() -> None:
|
|
165
|
+
"""
|
|
166
|
+
Manage your vantage6 authentication server instances.
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# Define the commands for the auth group
|
|
171
|
+
cli_auth.add_command(cli_auth_new, name="new")
|
|
172
|
+
cli_auth.add_command(cli_auth_start, name="start")
|
|
173
|
+
cli_auth.add_command(cli_auth_stop, name="stop")
|
|
174
|
+
cli_auth.add_command(cli_auth_attach, name="attach")
|
|
175
|
+
cli_auth.add_command(cli_auth_files, name="files")
|
|
176
|
+
cli_auth.add_command(cli_auth_configuration_list, name="list")
|
|
177
|
+
cli_auth.add_command(cli_auth_remove, name="remove")
|
|
178
|
+
|
|
179
|
+
|
|
151
180
|
# Add the use group
|
|
152
|
-
@click.group(name=
|
|
181
|
+
@click.group(name=CLICommandName.USE.value)
|
|
153
182
|
def cli_use() -> None:
|
|
154
183
|
"""
|
|
155
184
|
Manage Kubernetes context and namespace.
|
|
@@ -180,3 +209,4 @@ cli_complete.add_command(cli_algorithm)
|
|
|
180
209
|
cli_complete.add_command(cli_test)
|
|
181
210
|
cli_complete.add_command(cli_algo_store)
|
|
182
211
|
cli_complete.add_command(cli_use)
|
|
212
|
+
cli_complete.add_command(cli_auth)
|
vantage6/cli/common/new.py
CHANGED
|
@@ -11,8 +11,31 @@ from vantage6.cli.utils import check_config_name_allowed, prompt_config_name
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def new(
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
questionnaire_function: callable,
|
|
15
|
+
name: str,
|
|
16
|
+
system_folders: bool,
|
|
17
|
+
namespace: str,
|
|
18
|
+
context: str,
|
|
19
|
+
type_: InstanceType,
|
|
20
|
+
) -> None:
|
|
21
|
+
"""
|
|
22
|
+
Create a new configuration.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
questionnaire_function : callable
|
|
27
|
+
Function to generate the configuration
|
|
28
|
+
name : str
|
|
29
|
+
Name of the configuration
|
|
30
|
+
system_folders : bool
|
|
31
|
+
Whether to store the configuration in the system folders
|
|
32
|
+
namespace : str
|
|
33
|
+
Namespace to use
|
|
34
|
+
context : str
|
|
35
|
+
Context to use
|
|
36
|
+
type_ : InstanceType
|
|
37
|
+
Type of the configuration (node, server, algorithm store, etc)
|
|
38
|
+
"""
|
|
16
39
|
cli_config = CliConfig()
|
|
17
40
|
context, namespace = cli_config.compare_changes_config(
|
|
18
41
|
context=context,
|
|
@@ -47,7 +70,9 @@ def new(
|
|
|
47
70
|
|
|
48
71
|
# create config in ctx location
|
|
49
72
|
try:
|
|
50
|
-
cfg_file = configuration_wizard(
|
|
73
|
+
cfg_file = configuration_wizard(
|
|
74
|
+
questionnaire_function, type_, name, system_folders
|
|
75
|
+
)
|
|
51
76
|
except KeyboardInterrupt:
|
|
52
77
|
error("Configuration creation aborted.")
|
|
53
78
|
exit(1)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import itertools
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from shutil import rmtree
|
|
4
|
+
|
|
5
|
+
import questionary as q
|
|
6
|
+
|
|
7
|
+
from vantage6.common import (
|
|
8
|
+
error,
|
|
9
|
+
info,
|
|
10
|
+
)
|
|
11
|
+
from vantage6.common.context import AppContext
|
|
12
|
+
from vantage6.common.globals import InstanceType
|
|
13
|
+
|
|
14
|
+
from vantage6.cli.common.utils import check_running
|
|
15
|
+
from vantage6.cli.globals import InfraComponentName
|
|
16
|
+
from vantage6.cli.utils import remove_file
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def execute_remove(
|
|
20
|
+
ctx: AppContext,
|
|
21
|
+
instance_type: InstanceType,
|
|
22
|
+
infra_component: InfraComponentName,
|
|
23
|
+
name: str,
|
|
24
|
+
system_folders: bool,
|
|
25
|
+
force: bool,
|
|
26
|
+
) -> None:
|
|
27
|
+
if check_running(ctx.helm_release_name, instance_type, name, system_folders):
|
|
28
|
+
error(
|
|
29
|
+
f"The {infra_component.value} {name} is still running! Please stop the "
|
|
30
|
+
f"{infra_component.value} before deleting it."
|
|
31
|
+
)
|
|
32
|
+
exit(1)
|
|
33
|
+
|
|
34
|
+
if not force:
|
|
35
|
+
if not q.confirm(
|
|
36
|
+
f"This {infra_component.value} will be deleted permanently including its "
|
|
37
|
+
"configuration. Are you sure?",
|
|
38
|
+
default=False,
|
|
39
|
+
).ask():
|
|
40
|
+
info(f"The {infra_component.value} {name} will not be deleted")
|
|
41
|
+
exit(0)
|
|
42
|
+
|
|
43
|
+
# remove the config file
|
|
44
|
+
remove_file(ctx.config_file, "configuration")
|
|
45
|
+
|
|
46
|
+
# ensure log files are closed before removing
|
|
47
|
+
log_dir = Path(ctx.log_file.parent)
|
|
48
|
+
if log_dir.exists():
|
|
49
|
+
info(f"Removing log directory: {log_dir}")
|
|
50
|
+
for handler in itertools.chain(ctx.log.handlers, ctx.log.root.handlers):
|
|
51
|
+
handler.close()
|
|
52
|
+
# remove the whole folder with all the log files. This may also still contain
|
|
53
|
+
# other files like (for the server) RabbitMQ configuration etc
|
|
54
|
+
rmtree(log_dir)
|
vantage6/cli/common/start.py
CHANGED
|
@@ -10,6 +10,7 @@ import docker
|
|
|
10
10
|
from docker.client import DockerClient
|
|
11
11
|
|
|
12
12
|
from vantage6.common import error, info, warning
|
|
13
|
+
from vantage6.common.context import AppContext
|
|
13
14
|
from vantage6.common.docker.addons import pull_image
|
|
14
15
|
from vantage6.common.globals import (
|
|
15
16
|
DEFAULT_ALGO_STORE_IMAGE,
|
|
@@ -21,8 +22,36 @@ from vantage6.common.globals import (
|
|
|
21
22
|
InstanceType,
|
|
22
23
|
)
|
|
23
24
|
|
|
25
|
+
from vantage6.cli.common.utils import (
|
|
26
|
+
check_running,
|
|
27
|
+
select_context_and_namespace,
|
|
28
|
+
)
|
|
24
29
|
from vantage6.cli.globals import ChartName
|
|
25
|
-
from vantage6.cli.utils import validate_input_cmd_args
|
|
30
|
+
from vantage6.cli.utils import check_config_name_allowed, validate_input_cmd_args
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def prestart_checks(
|
|
34
|
+
ctx: AppContext,
|
|
35
|
+
instance_type: InstanceType,
|
|
36
|
+
name: str,
|
|
37
|
+
system_folders: bool,
|
|
38
|
+
context: str,
|
|
39
|
+
namespace: str,
|
|
40
|
+
) -> None:
|
|
41
|
+
"""
|
|
42
|
+
Run pre-start checks for an instance.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
check_config_name_allowed(ctx.name)
|
|
46
|
+
|
|
47
|
+
if check_running(ctx.helm_release_name, instance_type, name, system_folders):
|
|
48
|
+
error(f"Instance '{name}' is already running.")
|
|
49
|
+
exit(1)
|
|
50
|
+
|
|
51
|
+
context, namespace = select_context_and_namespace(
|
|
52
|
+
context=context,
|
|
53
|
+
namespace=namespace,
|
|
54
|
+
)
|
|
26
55
|
|
|
27
56
|
|
|
28
57
|
def pull_infra_image(
|
|
@@ -171,7 +200,7 @@ def helm_install(
|
|
|
171
200
|
)
|
|
172
201
|
info(
|
|
173
202
|
f"Successfully installed release '{release_name}' using chart "
|
|
174
|
-
f"'{chart_name}'."
|
|
203
|
+
f"'{chart_name.value}'."
|
|
175
204
|
)
|
|
176
205
|
except subprocess.CalledProcessError:
|
|
177
206
|
error(f"Failed to install release '{release_name}'.")
|
vantage6/cli/common/stop.py
CHANGED
|
@@ -2,11 +2,89 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import subprocess
|
|
4
4
|
|
|
5
|
-
from
|
|
5
|
+
from colorama import Fore, Style
|
|
6
6
|
|
|
7
|
+
from vantage6.common import error, info, warning
|
|
8
|
+
from vantage6.common.globals import InstanceType
|
|
9
|
+
|
|
10
|
+
from vantage6.cli.common.utils import (
|
|
11
|
+
find_running_service_names,
|
|
12
|
+
select_context_and_namespace,
|
|
13
|
+
select_running_service,
|
|
14
|
+
)
|
|
15
|
+
from vantage6.cli.context import get_context
|
|
16
|
+
from vantage6.cli.globals import InfraComponentName
|
|
7
17
|
from vantage6.cli.utils import validate_input_cmd_args
|
|
8
18
|
|
|
9
19
|
|
|
20
|
+
def execute_stop(
|
|
21
|
+
stop_function: callable,
|
|
22
|
+
instance_type: InstanceType,
|
|
23
|
+
infra_component: InfraComponentName,
|
|
24
|
+
stop_all: bool,
|
|
25
|
+
to_stop: str | None,
|
|
26
|
+
namespace: str,
|
|
27
|
+
context: str,
|
|
28
|
+
system_folders: bool,
|
|
29
|
+
):
|
|
30
|
+
"""
|
|
31
|
+
Execute the stop function for a given instance type and infra component.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
stop_function : callable
|
|
36
|
+
The function to stop the service.
|
|
37
|
+
instance_type : InstanceType
|
|
38
|
+
The instance type of the service.
|
|
39
|
+
infra_component : InfraComponentName
|
|
40
|
+
The infra component of the service.
|
|
41
|
+
stop_all : bool
|
|
42
|
+
Whether to stop all services.
|
|
43
|
+
to_stop : str | None
|
|
44
|
+
The name of the service to stop.
|
|
45
|
+
namespace : str
|
|
46
|
+
The namespace of the service.
|
|
47
|
+
context : str
|
|
48
|
+
The context of the service.
|
|
49
|
+
system_folders : bool
|
|
50
|
+
Whether to use system folders.
|
|
51
|
+
"""
|
|
52
|
+
context, namespace = select_context_and_namespace(
|
|
53
|
+
context=context,
|
|
54
|
+
namespace=namespace,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
running_services = find_running_service_names(
|
|
58
|
+
instance_type=instance_type,
|
|
59
|
+
only_system_folders=system_folders,
|
|
60
|
+
only_user_folders=not system_folders,
|
|
61
|
+
context=context,
|
|
62
|
+
namespace=namespace,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if not running_services:
|
|
66
|
+
error(f"No running {infra_component.value}s found.")
|
|
67
|
+
return
|
|
68
|
+
|
|
69
|
+
if stop_all:
|
|
70
|
+
for service in running_services:
|
|
71
|
+
stop_function(service, namespace, context)
|
|
72
|
+
else:
|
|
73
|
+
if not to_stop:
|
|
74
|
+
helm_name = select_running_service(running_services, instance_type)
|
|
75
|
+
else:
|
|
76
|
+
ctx = get_context(instance_type, to_stop, system_folders)
|
|
77
|
+
helm_name = ctx.helm_release_name
|
|
78
|
+
|
|
79
|
+
if helm_name in running_services:
|
|
80
|
+
stop_function(helm_name, namespace, context)
|
|
81
|
+
info(
|
|
82
|
+
f"Stopped the {Fore.GREEN}{helm_name}{Style.RESET_ALL} {infra_component.value}."
|
|
83
|
+
)
|
|
84
|
+
else:
|
|
85
|
+
error(f"{Fore.RED}{to_stop}{Style.RESET_ALL} is not running?!")
|
|
86
|
+
|
|
87
|
+
|
|
10
88
|
def stop_port_forward(service_name: str) -> None:
|
|
11
89
|
"""
|
|
12
90
|
Stop the port forwarding process for a given service name.
|
vantage6/cli/common/utils.py
CHANGED
|
@@ -14,6 +14,7 @@ from vantage6.common.globals import APPNAME, STRING_ENCODING, InstanceType
|
|
|
14
14
|
|
|
15
15
|
from vantage6.cli.config import CliConfig
|
|
16
16
|
from vantage6.cli.context import select_context_class
|
|
17
|
+
from vantage6.cli.globals import CLICommandName
|
|
17
18
|
from vantage6.cli.utils import validate_input_cmd_args
|
|
18
19
|
|
|
19
20
|
|
|
@@ -173,7 +174,7 @@ def select_running_service(
|
|
|
173
174
|
"""
|
|
174
175
|
try:
|
|
175
176
|
name = q.select(
|
|
176
|
-
f"Select
|
|
177
|
+
f"Select a {instance_type.value}:",
|
|
177
178
|
choices=running_services,
|
|
178
179
|
).unsafe_ask()
|
|
179
180
|
except KeyboardInterrupt:
|
|
@@ -340,6 +341,16 @@ def get_name_from_container_name(container_name: str) -> str:
|
|
|
340
341
|
return "-".join(container_name.split("-")[1:-1])
|
|
341
342
|
|
|
342
343
|
|
|
344
|
+
def get_config_name_from_service_name(service_name: str) -> str:
|
|
345
|
+
"""
|
|
346
|
+
Get the config name from a service name.
|
|
347
|
+
"""
|
|
348
|
+
# helm release name is structured as:
|
|
349
|
+
# f"{APPNAME}-{name}-{scope}-{instance_type}"
|
|
350
|
+
# we want to get the name from the service name
|
|
351
|
+
return "-".join(service_name.split("-")[1:-2])
|
|
352
|
+
|
|
353
|
+
|
|
343
354
|
def attach_logs(*labels: list[str]) -> None:
|
|
344
355
|
"""
|
|
345
356
|
Attach to the logs of the given labels.
|
|
@@ -364,10 +375,42 @@ def get_main_cli_command_name(instance_type: InstanceType) -> str:
|
|
|
364
375
|
The type of instance to get the main CLI command name for
|
|
365
376
|
"""
|
|
366
377
|
if instance_type == InstanceType.SERVER:
|
|
367
|
-
return
|
|
378
|
+
return CLICommandName.SERVER.value
|
|
368
379
|
elif instance_type == InstanceType.ALGORITHM_STORE:
|
|
369
|
-
return
|
|
380
|
+
return CLICommandName.ALGORITHM_STORE.value
|
|
370
381
|
elif instance_type == InstanceType.NODE:
|
|
371
|
-
return
|
|
382
|
+
return CLICommandName.NODE.value
|
|
383
|
+
elif instance_type == InstanceType.AUTH:
|
|
384
|
+
return CLICommandName.AUTH.value
|
|
372
385
|
else:
|
|
373
386
|
raise ValueError(f"Invalid instance type: {instance_type}")
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def check_running(
|
|
390
|
+
helm_release_name: str, instance_type: InstanceType, name: str, system_folders: bool
|
|
391
|
+
) -> bool:
|
|
392
|
+
"""
|
|
393
|
+
Check if the instance is already running.
|
|
394
|
+
|
|
395
|
+
Parameters
|
|
396
|
+
----------
|
|
397
|
+
helm_release_name : str
|
|
398
|
+
The name of the Helm release.
|
|
399
|
+
instance_type : InstanceType
|
|
400
|
+
The type of instance to check
|
|
401
|
+
name : str
|
|
402
|
+
The name of the instance to check
|
|
403
|
+
system_folders : bool
|
|
404
|
+
Whether to use system folders or not
|
|
405
|
+
|
|
406
|
+
Returns
|
|
407
|
+
-------
|
|
408
|
+
bool
|
|
409
|
+
True if the instance is already running, False otherwise
|
|
410
|
+
"""
|
|
411
|
+
running_services = find_running_service_names(
|
|
412
|
+
instance_type=instance_type,
|
|
413
|
+
only_system_folders=system_folders,
|
|
414
|
+
only_user_folders=not system_folders,
|
|
415
|
+
)
|
|
416
|
+
return helm_release_name in running_services
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
from typing import Self
|
|
2
2
|
|
|
3
|
-
from schema import And,
|
|
3
|
+
from schema import And, Use
|
|
4
4
|
|
|
5
5
|
from vantage6.common.configuration_manager import Configuration, ConfigurationManager
|
|
6
6
|
|
|
7
|
-
from vantage6.cli.globals import
|
|
7
|
+
from vantage6.cli.globals import (
|
|
8
|
+
ALGO_STORE_TEMPLATE_FILE,
|
|
9
|
+
AUTH_TEMPLATE_FILE,
|
|
10
|
+
NODE_TEMPLATE_FILE,
|
|
11
|
+
SERVER_TEMPLATE_FILE,
|
|
12
|
+
)
|
|
8
13
|
|
|
9
14
|
LOGGING_VALIDATORS = {
|
|
10
15
|
"level": And(
|
|
@@ -43,21 +48,30 @@ class NodeConfiguration(Configuration):
|
|
|
43
48
|
validators.
|
|
44
49
|
"""
|
|
45
50
|
|
|
51
|
+
# TODO perhaps we can remove these classes and do validation of the configuration
|
|
52
|
+
# file more easily with helm values.yaml checks.
|
|
46
53
|
VALIDATORS = {
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
#
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
Optional("
|
|
56
|
-
Optional("
|
|
57
|
-
Optional("
|
|
54
|
+
# # TODO enable validators for node. To see if it works, use v6 node list
|
|
55
|
+
# "node": {
|
|
56
|
+
# "server_url": Use(str),
|
|
57
|
+
# "port": Or(Use(int), None),
|
|
58
|
+
# "task_dir": Use(str),
|
|
59
|
+
# # TODO: remove `dict` validation from databases
|
|
60
|
+
# "api_path": Use(str),
|
|
61
|
+
# "logging": LOGGING_VALIDATORS,
|
|
62
|
+
# "encryption": {"enabled": bool, Optional("private_key"): Use(str)},
|
|
63
|
+
# Optional("node_extra_env"): dict,
|
|
64
|
+
# Optional("node_extra_mounts"): [str],
|
|
65
|
+
# Optional("node_extra_hosts"): dict,
|
|
66
|
+
# Optional("share_algorithm_logs"): Use(bool),
|
|
67
|
+
# }
|
|
58
68
|
}
|
|
59
69
|
|
|
60
70
|
|
|
71
|
+
class AuthConfiguration(Configuration):
|
|
72
|
+
VALIDATORS = {}
|
|
73
|
+
|
|
74
|
+
|
|
61
75
|
class TestConfiguration(Configuration):
|
|
62
76
|
VALIDATORS = {}
|
|
63
77
|
|
|
@@ -93,6 +107,12 @@ class NodeConfigurationManager(ConfigurationManager):
|
|
|
93
107
|
"""
|
|
94
108
|
return super().from_file(path, conf_class=NodeConfiguration)
|
|
95
109
|
|
|
110
|
+
def get_config_template(self) -> str:
|
|
111
|
+
"""
|
|
112
|
+
Get the configuration template for the node.
|
|
113
|
+
"""
|
|
114
|
+
return super()._get_config_template(NODE_TEMPLATE_FILE)
|
|
115
|
+
|
|
96
116
|
|
|
97
117
|
class ServerConfigurationManager(ConfigurationManager):
|
|
98
118
|
"""
|
|
@@ -180,6 +200,30 @@ class AlgorithmStoreConfigurationManager(ConfigurationManager):
|
|
|
180
200
|
return super()._get_config_template(ALGO_STORE_TEMPLATE_FILE)
|
|
181
201
|
|
|
182
202
|
|
|
203
|
+
class AuthConfigurationManager(ConfigurationManager):
|
|
204
|
+
"""
|
|
205
|
+
Maintains the auth's configuration.
|
|
206
|
+
|
|
207
|
+
Parameters
|
|
208
|
+
----------
|
|
209
|
+
name : str
|
|
210
|
+
Name of the configuration file.
|
|
211
|
+
"""
|
|
212
|
+
|
|
213
|
+
def __init__(self, name, *args, **kwargs):
|
|
214
|
+
super().__init__(conf_class=AuthConfiguration, name=name)
|
|
215
|
+
|
|
216
|
+
@classmethod
|
|
217
|
+
def from_file(cls, path: str) -> Self:
|
|
218
|
+
return super().from_file(path, conf_class=AuthConfiguration)
|
|
219
|
+
|
|
220
|
+
def get_config_template(self) -> str:
|
|
221
|
+
"""
|
|
222
|
+
Get the configuration template for the auth.
|
|
223
|
+
"""
|
|
224
|
+
return super()._get_config_template(AUTH_TEMPLATE_FILE)
|
|
225
|
+
|
|
226
|
+
|
|
183
227
|
class TestingConfigurationManager(ConfigurationManager):
|
|
184
228
|
def __init__(self, name, *args, **kwargs):
|
|
185
229
|
super().__init__(conf_class=TestConfiguration, name=name)
|