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
|
@@ -276,23 +276,23 @@ class Function:
|
|
|
276
276
|
else:
|
|
277
277
|
type_ = param.annotation
|
|
278
278
|
|
|
279
|
-
if type_
|
|
279
|
+
if type_ is str:
|
|
280
280
|
return AlgorithmArgumentType.STRING
|
|
281
|
-
elif type_
|
|
281
|
+
elif type_ is dict:
|
|
282
282
|
return AlgorithmArgumentType.JSON
|
|
283
|
-
elif type_
|
|
283
|
+
elif type_ is int:
|
|
284
284
|
return AlgorithmArgumentType.INTEGER
|
|
285
|
-
elif type_
|
|
285
|
+
elif type_ is float:
|
|
286
286
|
return AlgorithmArgumentType.FLOAT
|
|
287
|
-
elif type_
|
|
287
|
+
elif type_ is bool:
|
|
288
288
|
return AlgorithmArgumentType.BOOLEAN
|
|
289
|
-
elif type_
|
|
289
|
+
elif type_ is list:
|
|
290
290
|
return AlgorithmArgumentType.STRINGS
|
|
291
|
-
elif type_
|
|
291
|
+
elif type_ is list[str]:
|
|
292
292
|
return AlgorithmArgumentType.STRINGS
|
|
293
|
-
elif type_
|
|
293
|
+
elif type_ is list[int]:
|
|
294
294
|
return AlgorithmArgumentType.INTEGERS
|
|
295
|
-
elif type_
|
|
295
|
+
elif type_ is list[float]:
|
|
296
296
|
return AlgorithmArgumentType.FLOATS
|
|
297
297
|
else:
|
|
298
298
|
warning(
|
vantage6/cli/algorithm/update.py
CHANGED
vantage6/cli/algostore/attach.py
CHANGED
vantage6/cli/algostore/files.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
3
|
from vantage6.common import info
|
|
4
|
-
from vantage6.cli.context.server import ServerContext
|
|
5
|
-
from vantage6.cli.common.decorator import click_insert_context
|
|
6
4
|
from vantage6.common.globals import InstanceType
|
|
7
5
|
|
|
6
|
+
from vantage6.cli.common.decorator import click_insert_context
|
|
7
|
+
from vantage6.cli.context.server import ServerContext
|
|
8
|
+
|
|
8
9
|
|
|
9
10
|
@click.command()
|
|
10
11
|
@click_insert_context(type_=InstanceType.ALGORITHM_STORE)
|
vantage6/cli/algostore/list.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
from vantage6.common.docker.addons import check_docker_running
|
|
4
3
|
from vantage6.common.globals import InstanceType
|
|
5
4
|
|
|
6
5
|
from vantage6.cli.common.utils import get_server_configuration_list
|
|
@@ -11,6 +10,4 @@ def cli_algo_store_configuration_list() -> None:
|
|
|
11
10
|
"""
|
|
12
11
|
Print the available server configurations.
|
|
13
12
|
"""
|
|
14
|
-
check_docker_running()
|
|
15
|
-
|
|
16
13
|
get_server_configuration_list(InstanceType.ALGORITHM_STORE)
|
vantage6/cli/algostore/new.py
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import click
|
|
2
|
+
import questionary as q
|
|
2
3
|
|
|
3
|
-
from vantage6.common.globals import
|
|
4
|
+
from vantage6.common.globals import (
|
|
5
|
+
DEFAULT_API_PATH,
|
|
6
|
+
InstanceType,
|
|
7
|
+
Ports,
|
|
8
|
+
)
|
|
4
9
|
|
|
5
10
|
from vantage6.cli.common.new import new
|
|
11
|
+
from vantage6.cli.configuration_wizard import add_common_server_config
|
|
6
12
|
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
7
13
|
|
|
8
14
|
|
|
@@ -36,4 +42,79 @@ def cli_algo_store_new(
|
|
|
36
42
|
Create a new server configuration.
|
|
37
43
|
"""
|
|
38
44
|
|
|
39
|
-
new(
|
|
45
|
+
new(
|
|
46
|
+
questionnaire_function=algo_store_configuration_questionaire,
|
|
47
|
+
name=name,
|
|
48
|
+
system_folders=system_folders,
|
|
49
|
+
namespace=namespace,
|
|
50
|
+
context=context,
|
|
51
|
+
type_=InstanceType.ALGORITHM_STORE,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def algo_store_configuration_questionaire(instance_name: str) -> dict:
|
|
56
|
+
"""
|
|
57
|
+
Questionary to generate a config file for the algorithm store server
|
|
58
|
+
instance.
|
|
59
|
+
|
|
60
|
+
Parameters
|
|
61
|
+
----------
|
|
62
|
+
instance_name : str
|
|
63
|
+
Name of the server instance.
|
|
64
|
+
|
|
65
|
+
Returns
|
|
66
|
+
-------
|
|
67
|
+
dict
|
|
68
|
+
Dictionary with the new server configuration
|
|
69
|
+
"""
|
|
70
|
+
config = {"store": {}, "database": {}}
|
|
71
|
+
|
|
72
|
+
config, is_production = add_common_server_config(
|
|
73
|
+
config, InstanceType.ALGORITHM_STORE, instance_name
|
|
74
|
+
)
|
|
75
|
+
if not is_production:
|
|
76
|
+
config["store"]["dev"] = {
|
|
77
|
+
"host_uri": "host.docker.internal",
|
|
78
|
+
"disable_review": True,
|
|
79
|
+
"review_own_algorithm": True,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
default_v6_server_uri = f"http://localhost:{Ports.DEV_SERVER}{DEFAULT_API_PATH}"
|
|
83
|
+
default_root_username = "admin"
|
|
84
|
+
|
|
85
|
+
v6_server_uri = q.text(
|
|
86
|
+
"What is the Vantage6 server linked to the algorithm store? "
|
|
87
|
+
"Provide the link to the server endpoint.",
|
|
88
|
+
default=default_v6_server_uri,
|
|
89
|
+
).unsafe_ask()
|
|
90
|
+
|
|
91
|
+
root_username = q.text(
|
|
92
|
+
"What is the username of the root user?",
|
|
93
|
+
default=default_root_username,
|
|
94
|
+
).unsafe_ask()
|
|
95
|
+
|
|
96
|
+
config["root_user"] = {
|
|
97
|
+
"v6_server_uri": v6_server_uri,
|
|
98
|
+
"username": root_username,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# ask about openness of the algorithm store
|
|
102
|
+
config["policies"] = {}
|
|
103
|
+
is_open = q.confirm(
|
|
104
|
+
"Do you want to open the algorithm store to the public? This will allow anyone "
|
|
105
|
+
"to view the algorithms, but they cannot modify them.",
|
|
106
|
+
default=False,
|
|
107
|
+
).unsafe_ask()
|
|
108
|
+
if is_open:
|
|
109
|
+
open_algos_policy = "public"
|
|
110
|
+
else:
|
|
111
|
+
is_open_to_whitelist = q.confirm(
|
|
112
|
+
"Do you want to allow all authenticated users to access "
|
|
113
|
+
"the algorithms in the store? If not allowing this, you will have to assign"
|
|
114
|
+
" the appropriate permissions to each user individually.",
|
|
115
|
+
default=True,
|
|
116
|
+
).unsafe_ask()
|
|
117
|
+
open_algos_policy = "authenticated" if is_open_to_whitelist else "private"
|
|
118
|
+
config["policies"]["algorithm_view"] = open_algos_policy
|
|
119
|
+
|
|
120
|
+
return config
|
vantage6/cli/algostore/remove.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import itertools
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from shutil import rmtree
|
|
4
1
|
import click
|
|
5
|
-
import questionary as q
|
|
6
2
|
|
|
7
|
-
from vantage6.common import
|
|
8
|
-
|
|
3
|
+
from vantage6.common.globals import InstanceType
|
|
4
|
+
|
|
9
5
|
from vantage6.cli.common.decorator import click_insert_context
|
|
6
|
+
from vantage6.cli.common.remove import execute_remove
|
|
10
7
|
from vantage6.cli.context import AlgorithmStoreContext
|
|
11
|
-
from vantage6.cli.
|
|
12
|
-
from vantage6.common.globals import InstanceType
|
|
8
|
+
from vantage6.cli.globals import InfraComponentName
|
|
13
9
|
|
|
14
10
|
|
|
15
11
|
@click.command()
|
|
16
|
-
@click_insert_context(
|
|
12
|
+
@click_insert_context(
|
|
13
|
+
type_=InstanceType.ALGORITHM_STORE, include_name=True, include_system_folders=True
|
|
14
|
+
)
|
|
17
15
|
@click.option("-f", "--force", "force", flag_value=True)
|
|
18
|
-
def cli_algo_store_remove(
|
|
16
|
+
def cli_algo_store_remove(
|
|
17
|
+
ctx: AlgorithmStoreContext, name: str, system_folders: bool, force: bool
|
|
18
|
+
) -> None:
|
|
19
19
|
"""
|
|
20
20
|
Function to remove an algorithm store.
|
|
21
21
|
|
|
@@ -26,27 +26,11 @@ def cli_algo_store_remove(ctx: AlgorithmStoreContext, force: bool) -> None:
|
|
|
26
26
|
force : bool
|
|
27
27
|
Whether to ask for confirmation before removing or not
|
|
28
28
|
"""
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
info("Algorithm store will not be deleted")
|
|
38
|
-
exit(0)
|
|
39
|
-
|
|
40
|
-
# now remove the folders...
|
|
41
|
-
remove_file(ctx.config_file, "configuration")
|
|
42
|
-
|
|
43
|
-
# ensure log files are closed before removing
|
|
44
|
-
log_dir = Path(ctx.log_file.parent)
|
|
45
|
-
info(f"Removing log directory: {log_dir}")
|
|
46
|
-
for handler in itertools.chain(ctx.log.handlers, ctx.log.root.handlers):
|
|
47
|
-
handler.close()
|
|
48
|
-
# remove the whole folder with all the log files (if it exists)
|
|
49
|
-
try:
|
|
50
|
-
rmtree(log_dir)
|
|
51
|
-
except FileNotFoundError:
|
|
52
|
-
pass
|
|
29
|
+
execute_remove(
|
|
30
|
+
ctx,
|
|
31
|
+
InstanceType.ALGORITHM_STORE,
|
|
32
|
+
InfraComponentName.ALGORITHM_STORE,
|
|
33
|
+
name,
|
|
34
|
+
system_folders,
|
|
35
|
+
force,
|
|
36
|
+
)
|
vantage6/cli/algostore/start.py
CHANGED
|
@@ -9,12 +9,12 @@ from vantage6.common.globals import (
|
|
|
9
9
|
from vantage6.cli.common.decorator import click_insert_context
|
|
10
10
|
from vantage6.cli.common.start import (
|
|
11
11
|
helm_install,
|
|
12
|
+
prestart_checks,
|
|
12
13
|
start_port_forward,
|
|
13
14
|
)
|
|
14
15
|
from vantage6.cli.common.utils import (
|
|
15
16
|
attach_logs,
|
|
16
17
|
create_directory_if_not_exists,
|
|
17
|
-
select_context_and_namespace,
|
|
18
18
|
)
|
|
19
19
|
from vantage6.cli.context.algorithm_store import AlgorithmStoreContext
|
|
20
20
|
from vantage6.cli.globals import ChartName
|
|
@@ -30,9 +30,13 @@ from vantage6.cli.globals import ChartName
|
|
|
30
30
|
default=False,
|
|
31
31
|
help="Print server logs to the console after start",
|
|
32
32
|
)
|
|
33
|
-
@click_insert_context(
|
|
33
|
+
@click_insert_context(
|
|
34
|
+
InstanceType.ALGORITHM_STORE, include_name=True, include_system_folders=True
|
|
35
|
+
)
|
|
34
36
|
def cli_algo_store_start(
|
|
35
37
|
ctx: AlgorithmStoreContext,
|
|
38
|
+
name: str,
|
|
39
|
+
system_folders: bool,
|
|
36
40
|
context: str,
|
|
37
41
|
namespace: str,
|
|
38
42
|
ip: str,
|
|
@@ -43,9 +47,9 @@ def cli_algo_store_start(
|
|
|
43
47
|
Start the algorithm store.
|
|
44
48
|
"""
|
|
45
49
|
info("Starting algorithm store...")
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
namespace
|
|
50
|
+
|
|
51
|
+
prestart_checks(
|
|
52
|
+
ctx, InstanceType.ALGORITHM_STORE, name, system_folders, context, namespace
|
|
49
53
|
)
|
|
50
54
|
|
|
51
55
|
create_directory_if_not_exists(ctx.log_dir)
|
|
@@ -58,10 +62,9 @@ def cli_algo_store_start(
|
|
|
58
62
|
namespace=namespace,
|
|
59
63
|
)
|
|
60
64
|
|
|
61
|
-
# port forward for server
|
|
62
65
|
info("Port forwarding for algorithm store")
|
|
63
66
|
start_port_forward(
|
|
64
|
-
service_name=f"{ctx.helm_release_name}-
|
|
67
|
+
service_name=f"{ctx.helm_release_name}-store-service",
|
|
65
68
|
service_port=ctx.config["store"].get("port", Ports.DEV_ALGO_STORE.value),
|
|
66
69
|
port=port or ctx.config["store"].get("port", Ports.DEV_ALGO_STORE.value),
|
|
67
70
|
ip=ip,
|
vantage6/cli/algostore/stop.py
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import click
|
|
2
|
-
from colorama import Fore, Style
|
|
3
2
|
|
|
4
|
-
from vantage6.common import
|
|
3
|
+
from vantage6.common import info
|
|
5
4
|
from vantage6.common.globals import InstanceType
|
|
6
5
|
|
|
7
|
-
from vantage6.cli.common.stop import helm_uninstall, stop_port_forward
|
|
8
|
-
from vantage6.cli.
|
|
9
|
-
find_running_service_names,
|
|
10
|
-
select_context_and_namespace,
|
|
11
|
-
select_running_service,
|
|
12
|
-
)
|
|
13
|
-
from vantage6.cli.context import get_context
|
|
14
|
-
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
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
|
|
15
8
|
|
|
16
9
|
|
|
17
10
|
@click.command()
|
|
@@ -43,54 +36,23 @@ def cli_algo_store_stop(
|
|
|
43
36
|
"""
|
|
44
37
|
Stop one or all running algorithm store(s).
|
|
45
38
|
"""
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
namespace=namespace,
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
running_stores = find_running_service_names(
|
|
39
|
+
execute_stop(
|
|
40
|
+
stop_function=_stop_store,
|
|
52
41
|
instance_type=InstanceType.ALGORITHM_STORE,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
infra_component=InfraComponentName.ALGORITHM_STORE,
|
|
43
|
+
stop_all=all_stores,
|
|
44
|
+
to_stop=name,
|
|
56
45
|
namespace=namespace,
|
|
46
|
+
context=context,
|
|
47
|
+
system_folders=system_folders,
|
|
57
48
|
)
|
|
58
49
|
|
|
59
|
-
if not running_stores:
|
|
60
|
-
error("No running algorithm stores found.")
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
if all_stores:
|
|
64
|
-
for store in running_stores:
|
|
65
|
-
_stop_store(store["name"], namespace, context)
|
|
66
|
-
else:
|
|
67
|
-
if not name:
|
|
68
|
-
store_name = select_running_service(
|
|
69
|
-
running_stores, InstanceType.ALGORITHM_STORE
|
|
70
|
-
)
|
|
71
|
-
else:
|
|
72
|
-
ctx = get_context(InstanceType.ALGORITHM_STORE, name, system_folders)
|
|
73
|
-
store_name = ctx.helm_release_name
|
|
74
|
-
|
|
75
|
-
if store_name in running_stores:
|
|
76
|
-
_stop_store(store_name, namespace, context)
|
|
77
|
-
info(f"Stopped the {Fore.GREEN}{store_name}{Style.RESET_ALL} store.")
|
|
78
|
-
else:
|
|
79
|
-
error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running?!")
|
|
80
|
-
|
|
81
50
|
|
|
82
51
|
def _stop_store(store_name: str, namespace: str, context: str) -> None:
|
|
83
52
|
info(f"Stopping store {store_name}...")
|
|
84
53
|
|
|
85
|
-
|
|
86
|
-
helm_uninstall(
|
|
87
|
-
release_name=store_name,
|
|
88
|
-
context=context,
|
|
89
|
-
namespace=namespace,
|
|
90
|
-
)
|
|
54
|
+
helm_uninstall(release_name=store_name, context=context, namespace=namespace)
|
|
91
55
|
|
|
92
|
-
stop_port_forward(
|
|
93
|
-
service_name=f"{store_name}-vantage6-algorithm-store-service",
|
|
94
|
-
)
|
|
56
|
+
stop_port_forward(service_name=f"{store_name}-store-service")
|
|
95
57
|
|
|
96
58
|
info(f"Store {store_name} stopped successfully.")
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from vantage6.common import error, info
|
|
4
|
+
from vantage6.common.globals import InstanceType
|
|
5
|
+
|
|
6
|
+
from vantage6.cli.common.utils import (
|
|
7
|
+
attach_logs,
|
|
8
|
+
find_running_service_names,
|
|
9
|
+
select_context_and_namespace,
|
|
10
|
+
select_running_service,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@click.command()
|
|
15
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
16
|
+
@click.option("--namespace", default=None, help="Kubernetes namespace to use")
|
|
17
|
+
@click.option(
|
|
18
|
+
"-n", "--name", default=None, help="Name of the auth service to attach to"
|
|
19
|
+
)
|
|
20
|
+
def cli_auth_attach(context: str, namespace: str, name: str) -> None:
|
|
21
|
+
"""
|
|
22
|
+
Show the server logs in the current console.
|
|
23
|
+
"""
|
|
24
|
+
info("Attaching to auth logs...")
|
|
25
|
+
|
|
26
|
+
context, namespace = select_context_and_namespace(
|
|
27
|
+
context=context,
|
|
28
|
+
namespace=namespace,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
running_services = find_running_service_names(
|
|
32
|
+
instance_type=InstanceType.AUTH,
|
|
33
|
+
only_system_folders=False,
|
|
34
|
+
only_user_folders=False,
|
|
35
|
+
context=context,
|
|
36
|
+
namespace=namespace,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
if not running_services:
|
|
40
|
+
error("No running auth services found.")
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
if name:
|
|
44
|
+
# search for a running auth service started up either in user or system folders
|
|
45
|
+
svc_name_options = [
|
|
46
|
+
f"vantage6-{name}-user-auth",
|
|
47
|
+
f"vantage6-{name}-system-auth",
|
|
48
|
+
]
|
|
49
|
+
helm_name = next(
|
|
50
|
+
(svc for svc in svc_name_options if svc in running_services), None
|
|
51
|
+
)
|
|
52
|
+
if not helm_name:
|
|
53
|
+
error(f"No running auth service found for {name}.")
|
|
54
|
+
return
|
|
55
|
+
else:
|
|
56
|
+
helm_name = select_running_service(running_services, InstanceType.AUTH)
|
|
57
|
+
|
|
58
|
+
attach_logs(
|
|
59
|
+
f"app.kubernetes.io/instance={helm_name}",
|
|
60
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from vantage6.common import info
|
|
4
|
+
from vantage6.common.globals import InstanceType
|
|
5
|
+
|
|
6
|
+
from vantage6.cli.common.decorator import click_insert_context
|
|
7
|
+
from vantage6.cli.context.auth import AuthContext
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@click.command()
|
|
11
|
+
@click_insert_context(type_=InstanceType.AUTH)
|
|
12
|
+
def cli_auth_files(ctx: AuthContext) -> None:
|
|
13
|
+
"""
|
|
14
|
+
List files that belong to a particular auth instance.
|
|
15
|
+
"""
|
|
16
|
+
info(f"Configuration file = {ctx.config_file}")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from vantage6.common.globals import InstanceType
|
|
4
|
+
|
|
5
|
+
from vantage6.cli.common.utils import get_server_configuration_list
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.command()
|
|
9
|
+
def cli_auth_configuration_list() -> None:
|
|
10
|
+
"""
|
|
11
|
+
Print the available auth configurations.
|
|
12
|
+
"""
|
|
13
|
+
get_server_configuration_list(InstanceType.AUTH)
|
vantage6/cli/auth/new.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
import questionary as q
|
|
5
|
+
|
|
6
|
+
from vantage6.common.globals import (
|
|
7
|
+
InstanceType,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from vantage6.cli.common.new import new
|
|
11
|
+
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@click.command()
|
|
15
|
+
@click.option(
|
|
16
|
+
"-n", "--name", default=None, help="name of the configuration you want to use."
|
|
17
|
+
)
|
|
18
|
+
@click.option(
|
|
19
|
+
"--system",
|
|
20
|
+
"system_folders",
|
|
21
|
+
flag_value=True,
|
|
22
|
+
help="Use system folders instead of user folders. This is the default",
|
|
23
|
+
)
|
|
24
|
+
@click.option(
|
|
25
|
+
"--user",
|
|
26
|
+
"system_folders",
|
|
27
|
+
flag_value=False,
|
|
28
|
+
default=DEFAULT_SERVER_SYSTEM_FOLDERS,
|
|
29
|
+
help="Use user folders instead of system folders",
|
|
30
|
+
)
|
|
31
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
32
|
+
@click.option(
|
|
33
|
+
"--namespace",
|
|
34
|
+
default=None,
|
|
35
|
+
help="Kubernetes namespace to use",
|
|
36
|
+
)
|
|
37
|
+
def cli_auth_new(
|
|
38
|
+
name: str,
|
|
39
|
+
system_folders: bool,
|
|
40
|
+
namespace: str,
|
|
41
|
+
context: str,
|
|
42
|
+
) -> None:
|
|
43
|
+
"""
|
|
44
|
+
Create a new server configuration.
|
|
45
|
+
"""
|
|
46
|
+
new(
|
|
47
|
+
questionnaire_function=auth_configuration_questionaire,
|
|
48
|
+
name=name,
|
|
49
|
+
system_folders=system_folders,
|
|
50
|
+
namespace=namespace,
|
|
51
|
+
context=context,
|
|
52
|
+
type_=InstanceType.AUTH,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def auth_configuration_questionaire(instance_name: str) -> dict[str, Any]:
|
|
57
|
+
"""
|
|
58
|
+
Kubernetes-specific questionnaire to generate Helm values for the Keycloak helm
|
|
59
|
+
chart.
|
|
60
|
+
"""
|
|
61
|
+
config = {"keycloak": {}}
|
|
62
|
+
|
|
63
|
+
is_production = q.confirm(
|
|
64
|
+
"Do you want to use production settings? If not, the service will be configured"
|
|
65
|
+
" to be more suitable for development or testing purposes.",
|
|
66
|
+
default=True,
|
|
67
|
+
).unsafe_ask()
|
|
68
|
+
|
|
69
|
+
config["keycloak"]["production"] = is_production
|
|
70
|
+
|
|
71
|
+
if is_production:
|
|
72
|
+
ui_url = q.text(
|
|
73
|
+
"Please provide the URL of the UI. This is the URL that users will use to "
|
|
74
|
+
"log in to the service.",
|
|
75
|
+
default="https://ui.vantage6.ai",
|
|
76
|
+
).unsafe_ask()
|
|
77
|
+
# add http://localhost:7681 as that is used by the Python client
|
|
78
|
+
config["keycloak"]["redirectUris"] = [ui_url, "http://localhost:7681"]
|
|
79
|
+
|
|
80
|
+
return config
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from vantage6.common.globals import InstanceType
|
|
4
|
+
|
|
5
|
+
from vantage6.cli.common.decorator import click_insert_context
|
|
6
|
+
from vantage6.cli.common.remove import execute_remove
|
|
7
|
+
from vantage6.cli.context.auth import AuthContext
|
|
8
|
+
from vantage6.cli.globals import InfraComponentName
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@click.command()
|
|
12
|
+
@click_insert_context(
|
|
13
|
+
type_=InstanceType.AUTH, include_name=True, include_system_folders=True
|
|
14
|
+
)
|
|
15
|
+
@click.option("-f", "--force", "force", flag_value=True)
|
|
16
|
+
def cli_auth_remove(
|
|
17
|
+
ctx: AuthContext, name: str, system_folders: bool, force: bool
|
|
18
|
+
) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Function to remove a server.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
ctx : ServerContext
|
|
25
|
+
Server context object
|
|
26
|
+
force : bool
|
|
27
|
+
Whether to ask for confirmation before removing or not
|
|
28
|
+
"""
|
|
29
|
+
execute_remove(
|
|
30
|
+
ctx, InstanceType.AUTH, InfraComponentName.AUTH, name, system_folders, force
|
|
31
|
+
)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from vantage6.common import info
|
|
4
|
+
from vantage6.common.globals import InstanceType, Ports
|
|
5
|
+
|
|
6
|
+
from vantage6.cli.common.decorator import click_insert_context
|
|
7
|
+
from vantage6.cli.common.start import (
|
|
8
|
+
helm_install,
|
|
9
|
+
prestart_checks,
|
|
10
|
+
start_port_forward,
|
|
11
|
+
)
|
|
12
|
+
from vantage6.cli.common.utils import (
|
|
13
|
+
attach_logs,
|
|
14
|
+
)
|
|
15
|
+
from vantage6.cli.context.auth import AuthContext
|
|
16
|
+
from vantage6.cli.globals import ChartName
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@click.command()
|
|
20
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
21
|
+
@click.option("--namespace", default=None, help="Kubernetes namespace to use")
|
|
22
|
+
@click.option("--ip", default=None, help="IP address to listen on")
|
|
23
|
+
@click.option(
|
|
24
|
+
"-p",
|
|
25
|
+
"--port",
|
|
26
|
+
default=None,
|
|
27
|
+
type=int,
|
|
28
|
+
help="Port to listen on for the auth service",
|
|
29
|
+
)
|
|
30
|
+
@click.option(
|
|
31
|
+
"--attach/--detach",
|
|
32
|
+
default=False,
|
|
33
|
+
help="Print server logs to the console after start",
|
|
34
|
+
)
|
|
35
|
+
@click_insert_context(
|
|
36
|
+
type_=InstanceType.AUTH, include_name=True, include_system_folders=True
|
|
37
|
+
)
|
|
38
|
+
def cli_auth_start(
|
|
39
|
+
ctx: AuthContext,
|
|
40
|
+
name: str,
|
|
41
|
+
system_folders: bool,
|
|
42
|
+
context: str,
|
|
43
|
+
namespace: str,
|
|
44
|
+
ip: str,
|
|
45
|
+
port: int,
|
|
46
|
+
attach: bool,
|
|
47
|
+
) -> None:
|
|
48
|
+
"""
|
|
49
|
+
Start the auth service.
|
|
50
|
+
"""
|
|
51
|
+
info("Starting authentication service...")
|
|
52
|
+
|
|
53
|
+
prestart_checks(ctx, InstanceType.AUTH, name, system_folders, context, namespace)
|
|
54
|
+
|
|
55
|
+
# TODO: re-enable when we save the auth logs
|
|
56
|
+
# create_directory_if_not_exists(ctx.log_dir)
|
|
57
|
+
|
|
58
|
+
helm_install(
|
|
59
|
+
release_name=ctx.helm_release_name,
|
|
60
|
+
chart_name=ChartName.AUTH,
|
|
61
|
+
values_file=ctx.config_file,
|
|
62
|
+
context=context,
|
|
63
|
+
namespace=namespace,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# port forward for auth service
|
|
67
|
+
info("Port forwarding for auth service")
|
|
68
|
+
start_port_forward(
|
|
69
|
+
service_name=f"{ctx.helm_release_name}-keycloak",
|
|
70
|
+
service_port=Ports.HTTP.value,
|
|
71
|
+
port=port or Ports.DEV_AUTH.value,
|
|
72
|
+
ip=ip,
|
|
73
|
+
context=context,
|
|
74
|
+
namespace=namespace,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
if attach:
|
|
78
|
+
attach_logs(
|
|
79
|
+
f"app.kubernetes.io/instance={ctx.helm_release_name}",
|
|
80
|
+
)
|