vantage6 5.0.0a36__py3-none-any.whl → 5.0.0a38__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 +0 -1
- vantage6/cli/algostore/attach.py +28 -3
- vantage6/cli/algostore/list.py +2 -2
- vantage6/cli/algostore/new.py +3 -2
- vantage6/cli/algostore/start.py +25 -6
- vantage6/cli/algostore/stop.py +3 -0
- vantage6/cli/algostore/version.py +62 -0
- vantage6/cli/auth/attach.py +1 -1
- vantage6/cli/auth/list.py +2 -2
- vantage6/cli/auth/new.py +3 -2
- vantage6/cli/auth/remove.py +58 -0
- vantage6/cli/auth/start.py +27 -9
- vantage6/cli/auth/stop.py +3 -0
- vantage6/cli/cli.py +21 -0
- vantage6/cli/common/attach.py +114 -0
- vantage6/cli/common/decorator.py +25 -4
- vantage6/cli/common/list.py +68 -0
- vantage6/cli/common/new.py +27 -7
- vantage6/cli/common/remove.py +18 -0
- vantage6/cli/common/start.py +48 -40
- vantage6/cli/common/stop.py +16 -4
- vantage6/cli/common/utils.py +65 -74
- vantage6/cli/common/version.py +82 -0
- vantage6/cli/config.py +10 -2
- vantage6/cli/{configuration_wizard.py → configuration_create.py} +22 -14
- vantage6/cli/configuration_manager.py +70 -21
- vantage6/cli/context/__init__.py +10 -5
- vantage6/cli/context/algorithm_store.py +13 -7
- vantage6/cli/context/auth.py +23 -5
- vantage6/cli/context/node.py +25 -8
- vantage6/cli/context/server.py +18 -6
- vantage6/cli/globals.py +1 -0
- vantage6/cli/node/attach.py +27 -3
- vantage6/cli/node/common/__init__.py +26 -10
- vantage6/cli/node/common/task_cleanup.py +153 -0
- vantage6/cli/node/list.py +3 -44
- vantage6/cli/node/new.py +13 -6
- vantage6/cli/node/set_api_key.py +1 -1
- vantage6/cli/node/start.py +30 -7
- vantage6/cli/node/stop.py +151 -7
- vantage6/cli/node/version.py +96 -33
- vantage6/cli/sandbox/config/base.py +109 -0
- vantage6/cli/sandbox/config/core.py +300 -0
- vantage6/cli/sandbox/config/node.py +311 -0
- vantage6/cli/sandbox/data/km_dataset.csv +2401 -0
- vantage6/cli/sandbox/data/olympic_athletes_2016.csv +2425 -0
- vantage6/cli/sandbox/new.py +207 -0
- vantage6/cli/sandbox/populate/__init__.py +173 -0
- vantage6/cli/sandbox/populate/helpers/connect_store.py +203 -0
- vantage6/cli/sandbox/populate/helpers/delete_fixtures.py +67 -0
- vantage6/cli/sandbox/populate/helpers/load_fixtures.py +476 -0
- vantage6/cli/sandbox/populate/helpers/utils.py +35 -0
- vantage6/cli/sandbox/remove.py +155 -0
- vantage6/cli/sandbox/start.py +349 -0
- vantage6/cli/sandbox/stop.py +106 -0
- vantage6/cli/server/attach.py +28 -3
- vantage6/cli/server/common/__init__.py +5 -6
- vantage6/cli/server/import_.py +137 -119
- vantage6/cli/server/list.py +2 -2
- vantage6/cli/server/new.py +5 -3
- vantage6/cli/server/start.py +21 -4
- vantage6/cli/server/stop.py +2 -0
- vantage6/cli/server/version.py +31 -18
- vantage6/cli/template/algo_store_config.j2 +3 -0
- vantage6/cli/template/auth_config.j2 +24 -1
- vantage6/cli/template/node_config.j2 +2 -0
- vantage6/cli/template/server_config.j2 +10 -7
- vantage6/cli/use/context.py +8 -1
- vantage6/cli/use/namespace.py +10 -7
- vantage6/cli/utils.py +33 -1
- vantage6/cli/utils_kubernetes.py +270 -0
- {vantage6-5.0.0a36.dist-info → vantage6-5.0.0a38.dist-info}/METADATA +4 -4
- vantage6-5.0.0a38.dist-info/RECORD +102 -0
- vantage6/cli/rabbitmq/__init__.py +0 -0
- vantage6/cli/rabbitmq/definitions.py +0 -26
- vantage6/cli/rabbitmq/queue_manager.py +0 -220
- vantage6/cli/rabbitmq/rabbitmq.config +0 -8
- vantage6-5.0.0a36.dist-info/RECORD +0 -86
- {vantage6-5.0.0a36.dist-info → vantage6-5.0.0a38.dist-info}/WHEEL +0 -0
- {vantage6-5.0.0a36.dist-info → vantage6-5.0.0a38.dist-info}/entry_points.txt +0 -0
vantage6/cli/context/server.py
CHANGED
|
@@ -36,12 +36,14 @@ class ServerContext(BaseServerContext):
|
|
|
36
36
|
instance_name: str,
|
|
37
37
|
system_folders: bool = S_FOL,
|
|
38
38
|
in_container: bool = False,
|
|
39
|
+
is_sandbox: bool = False,
|
|
39
40
|
):
|
|
40
41
|
super().__init__(
|
|
41
42
|
InstanceType.SERVER,
|
|
42
43
|
instance_name,
|
|
43
44
|
system_folders=system_folders,
|
|
44
45
|
in_container=in_container,
|
|
46
|
+
is_sandbox=is_sandbox,
|
|
45
47
|
)
|
|
46
48
|
self.log.info("vantage6 version '%s'", __version__)
|
|
47
49
|
|
|
@@ -123,7 +125,9 @@ class ServerContext(BaseServerContext):
|
|
|
123
125
|
)
|
|
124
126
|
|
|
125
127
|
@classmethod
|
|
126
|
-
def config_exists(
|
|
128
|
+
def config_exists(
|
|
129
|
+
cls, instance_name: str, system_folders: bool = S_FOL, is_sandbox: bool = False
|
|
130
|
+
) -> bool:
|
|
127
131
|
"""
|
|
128
132
|
Check if a configuration file exists.
|
|
129
133
|
|
|
@@ -134,19 +138,23 @@ class ServerContext(BaseServerContext):
|
|
|
134
138
|
of the configuration file.
|
|
135
139
|
system_folders : bool, optional
|
|
136
140
|
System wide or user configuration, by default S_FOL
|
|
137
|
-
|
|
141
|
+
is_sandbox : bool, optional
|
|
142
|
+
Whether the configuration is a sandbox configuration, by default False
|
|
138
143
|
Returns
|
|
139
144
|
-------
|
|
140
145
|
bool
|
|
141
146
|
Whether the configuration file exists or not
|
|
142
147
|
"""
|
|
143
|
-
return super().
|
|
144
|
-
InstanceType.SERVER,
|
|
148
|
+
return super().base_config_exists(
|
|
149
|
+
InstanceType.SERVER,
|
|
150
|
+
instance_name,
|
|
151
|
+
system_folders=system_folders,
|
|
152
|
+
is_sandbox=is_sandbox,
|
|
145
153
|
)
|
|
146
154
|
|
|
147
155
|
@classmethod
|
|
148
156
|
def available_configurations(
|
|
149
|
-
cls, system_folders: bool = S_FOL
|
|
157
|
+
cls, system_folders: bool = S_FOL, is_sandbox: bool = False
|
|
150
158
|
) -> tuple[list, list]:
|
|
151
159
|
"""
|
|
152
160
|
Find all available server configurations in the default folders.
|
|
@@ -155,6 +163,8 @@ class ServerContext(BaseServerContext):
|
|
|
155
163
|
----------
|
|
156
164
|
system_folders : bool, optional
|
|
157
165
|
System wide or user configuration, by default S_FOL
|
|
166
|
+
is_sandbox : bool, optional
|
|
167
|
+
Whether the configuration is a sandbox configuration, by default False
|
|
158
168
|
|
|
159
169
|
Returns
|
|
160
170
|
-------
|
|
@@ -162,4 +172,6 @@ class ServerContext(BaseServerContext):
|
|
|
162
172
|
The first list contains validated configuration files, the second
|
|
163
173
|
list contains invalid configuration files.
|
|
164
174
|
"""
|
|
165
|
-
return super().available_configurations(
|
|
175
|
+
return super().available_configurations(
|
|
176
|
+
InstanceType.SERVER, system_folders, is_sandbox
|
|
177
|
+
)
|
vantage6/cli/globals.py
CHANGED
vantage6/cli/node/attach.py
CHANGED
|
@@ -2,13 +2,37 @@ import click
|
|
|
2
2
|
|
|
3
3
|
from vantage6.common import info
|
|
4
4
|
|
|
5
|
-
from vantage6.cli.common.
|
|
5
|
+
from vantage6.cli.common.attach import attach_logs
|
|
6
|
+
from vantage6.cli.context import InstanceType
|
|
7
|
+
from vantage6.cli.globals import InfraComponentName
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
@click.command()
|
|
9
|
-
|
|
11
|
+
@click.option("-n", "--name", default=None, help="Name of the configuration")
|
|
12
|
+
@click.option("--system", "system_folders", flag_value=True, help="Use system folders")
|
|
13
|
+
@click.option("--user", "system_folders", flag_value=False, help="Use user folders")
|
|
14
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
15
|
+
@click.option("--namespace", default=None, help="Kubernetes namespace to use")
|
|
16
|
+
@click.option(
|
|
17
|
+
"--sandbox", "is_sandbox", flag_value=True, help="Attach to a sandbox environment"
|
|
18
|
+
)
|
|
19
|
+
def cli_node_attach(
|
|
20
|
+
name: str | None,
|
|
21
|
+
system_folders: bool,
|
|
22
|
+
context: str,
|
|
23
|
+
namespace: str,
|
|
24
|
+
is_sandbox: bool,
|
|
25
|
+
) -> None:
|
|
10
26
|
"""
|
|
11
27
|
Show the node logs in the current console.
|
|
12
28
|
"""
|
|
13
29
|
info("Attaching to node logs...")
|
|
14
|
-
attach_logs(
|
|
30
|
+
attach_logs(
|
|
31
|
+
name,
|
|
32
|
+
instance_type=InstanceType.NODE,
|
|
33
|
+
infra_component=InfraComponentName.NODE,
|
|
34
|
+
system_folders=system_folders,
|
|
35
|
+
context=context,
|
|
36
|
+
namespace=namespace,
|
|
37
|
+
is_sandbox=is_sandbox,
|
|
38
|
+
)
|
|
@@ -8,11 +8,16 @@ import docker
|
|
|
8
8
|
from colorama import Fore, Style
|
|
9
9
|
|
|
10
10
|
from vantage6.common import debug, error, info
|
|
11
|
-
from vantage6.common.globals import
|
|
11
|
+
from vantage6.common.globals import (
|
|
12
|
+
APPNAME,
|
|
13
|
+
HTTP_LOCALHOST,
|
|
14
|
+
InstanceType,
|
|
15
|
+
RequiredNodeEnvVars,
|
|
16
|
+
)
|
|
12
17
|
|
|
13
18
|
from vantage6.client import UserClient
|
|
14
19
|
|
|
15
|
-
from vantage6.cli.
|
|
20
|
+
from vantage6.cli.configuration_create import select_configuration_questionnaire
|
|
16
21
|
from vantage6.cli.context.node import NodeContext
|
|
17
22
|
|
|
18
23
|
|
|
@@ -33,7 +38,7 @@ def create_client(ctx: NodeContext) -> UserClient:
|
|
|
33
38
|
# if the server is run locally, we need to use localhost here instead of
|
|
34
39
|
# the host address of docker
|
|
35
40
|
if host in ["http://host.docker.internal", "http://172.17.0.1"]:
|
|
36
|
-
host =
|
|
41
|
+
host = HTTP_LOCALHOST
|
|
37
42
|
port = ctx.config["port"]
|
|
38
43
|
api_path = ctx.config["api_path"]
|
|
39
44
|
info(f"Connecting to server at '{host}:{port}{api_path}'")
|
|
@@ -64,26 +69,37 @@ def create_client_and_authenticate(ctx: NodeContext) -> UserClient:
|
|
|
64
69
|
client.authenticate()
|
|
65
70
|
except Exception as exc:
|
|
66
71
|
error("Could not authenticate with server!")
|
|
67
|
-
debug(exc)
|
|
72
|
+
debug(str(exc))
|
|
68
73
|
exit(1)
|
|
69
74
|
|
|
70
75
|
return client
|
|
71
76
|
|
|
72
77
|
|
|
73
|
-
def select_node(name: str, system_folders: bool) ->
|
|
78
|
+
def select_node(name: str, system_folders: bool) -> str:
|
|
74
79
|
"""
|
|
75
80
|
Let user select node through questionnaire if name is not given.
|
|
76
81
|
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
name : str
|
|
85
|
+
Name of the node to select
|
|
86
|
+
system_folders : bool
|
|
87
|
+
Whether to use system folders or not
|
|
88
|
+
|
|
77
89
|
Returns
|
|
78
90
|
-------
|
|
79
91
|
str
|
|
80
92
|
Name of the configuration file
|
|
81
93
|
"""
|
|
82
|
-
|
|
83
|
-
name
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
try:
|
|
95
|
+
name = (
|
|
96
|
+
name
|
|
97
|
+
if name
|
|
98
|
+
else select_configuration_questionnaire(InstanceType.NODE, system_folders)
|
|
99
|
+
)
|
|
100
|
+
except Exception:
|
|
101
|
+
error("No configurations could be found!")
|
|
102
|
+
exit()
|
|
87
103
|
|
|
88
104
|
# raise error if config could not be found
|
|
89
105
|
if not NodeContext.config_exists(name, system_folders):
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from kubernetes import client as k8s_client
|
|
4
|
+
from kubernetes.client.rest import ApiException
|
|
5
|
+
|
|
6
|
+
from vantage6.common import logger_name
|
|
7
|
+
|
|
8
|
+
log = logging.getLogger(logger_name(__name__))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def delete_job_related_pods(
|
|
12
|
+
run_id: int,
|
|
13
|
+
container_name: str,
|
|
14
|
+
namespace: str,
|
|
15
|
+
core_api: k8s_client.CoreV1Api,
|
|
16
|
+
batch_api: k8s_client.BatchV1Api,
|
|
17
|
+
) -> None:
|
|
18
|
+
"""
|
|
19
|
+
Deletes all the PODs created by a Kubernetes job in a given namespace
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
run_id: int
|
|
24
|
+
Server run identifier
|
|
25
|
+
container_name: str
|
|
26
|
+
Name of the container
|
|
27
|
+
namespace: str
|
|
28
|
+
Namespace where the container is located
|
|
29
|
+
core_api: k8s_client.CoreV1Api
|
|
30
|
+
Kubernetes Core API instance
|
|
31
|
+
batch_api: k8s_client.BatchV1Api
|
|
32
|
+
Kubernetes Batch API instance
|
|
33
|
+
"""
|
|
34
|
+
log.info(
|
|
35
|
+
"Cleaning up kubernetes Job %s (run_id = %s) and related PODs",
|
|
36
|
+
container_name,
|
|
37
|
+
run_id,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
__delete_job(container_name, namespace, batch_api)
|
|
41
|
+
|
|
42
|
+
job_selector = f"job-name={container_name}"
|
|
43
|
+
job_pods_list = core_api.list_namespaced_pod(namespace, label_selector=job_selector)
|
|
44
|
+
for job_pod in job_pods_list.items:
|
|
45
|
+
__delete_pod(job_pod.metadata.name, namespace, core_api)
|
|
46
|
+
|
|
47
|
+
__delete_secret(container_name, namespace, core_api)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def __delete_secret(
|
|
51
|
+
secret_name: str, namespace: str, core_api: k8s_client.CoreV1Api
|
|
52
|
+
) -> None:
|
|
53
|
+
"""
|
|
54
|
+
Deletes a secret in a given namespace
|
|
55
|
+
|
|
56
|
+
Parameters
|
|
57
|
+
----------
|
|
58
|
+
secret_name: str
|
|
59
|
+
Name of the secret
|
|
60
|
+
namespace: str
|
|
61
|
+
Namespace where the secret is located
|
|
62
|
+
core_api: k8s_client.CoreV1Api
|
|
63
|
+
Kubernetes Core API instance
|
|
64
|
+
"""
|
|
65
|
+
try:
|
|
66
|
+
core_api.delete_namespaced_secret(name=secret_name, namespace=namespace)
|
|
67
|
+
log.info(
|
|
68
|
+
"Removed kubernetes Secret %s in namespace %s",
|
|
69
|
+
secret_name,
|
|
70
|
+
namespace,
|
|
71
|
+
)
|
|
72
|
+
except ApiException as exc:
|
|
73
|
+
if exc.status == 404:
|
|
74
|
+
log.debug("No secret %s to remove in namespace %s", secret_name, namespace)
|
|
75
|
+
else:
|
|
76
|
+
log.error("Exception when deleting namespaced secret: %s", exc)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def __delete_job(
|
|
80
|
+
job_name: str, namespace: str, batch_api: k8s_client.BatchV1Api
|
|
81
|
+
) -> None:
|
|
82
|
+
"""
|
|
83
|
+
Deletes a job in a given namespace
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
job_name: str
|
|
88
|
+
Name of the job
|
|
89
|
+
namespace: str
|
|
90
|
+
Namespace where the job is located
|
|
91
|
+
batch_api: k8s_client.BatchV1Api
|
|
92
|
+
Kubernetes Batch API instance
|
|
93
|
+
"""
|
|
94
|
+
log.info(
|
|
95
|
+
"Cleaning up kubernetes Job %s and related PODs",
|
|
96
|
+
job_name,
|
|
97
|
+
)
|
|
98
|
+
try:
|
|
99
|
+
# Check if the job exists before attempting to delete it
|
|
100
|
+
job = batch_api.read_namespaced_job(name=job_name, namespace=namespace)
|
|
101
|
+
if job:
|
|
102
|
+
batch_api.delete_namespaced_job(name=job_name, namespace=namespace)
|
|
103
|
+
else:
|
|
104
|
+
log.warning(
|
|
105
|
+
"Job %s not found in namespace %s, skipping deletion",
|
|
106
|
+
job_name,
|
|
107
|
+
namespace,
|
|
108
|
+
)
|
|
109
|
+
except ApiException as exc:
|
|
110
|
+
if exc.status == 404:
|
|
111
|
+
log.warning(
|
|
112
|
+
"Job %s not found in namespace %s, skipping deletion",
|
|
113
|
+
job_name,
|
|
114
|
+
namespace,
|
|
115
|
+
)
|
|
116
|
+
else:
|
|
117
|
+
log.error("Exception when deleting namespaced job: %s", exc)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def __delete_pod(pod_name: str, namespace: str, core_api: k8s_client.CoreV1Api) -> None:
|
|
121
|
+
"""
|
|
122
|
+
Deletes a job in a given namespace
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
pod_name: str
|
|
127
|
+
Name of the job
|
|
128
|
+
namespace: str
|
|
129
|
+
Namespace where the job is located
|
|
130
|
+
core_api: k8s_client.CoreV1Api
|
|
131
|
+
Kubernetes Core API instance
|
|
132
|
+
"""
|
|
133
|
+
log.info("Cleaning up kubernetes pod %s in namespace %s", pod_name, namespace)
|
|
134
|
+
try:
|
|
135
|
+
# Check if the job exists before attempting to delete it
|
|
136
|
+
job = core_api.read_namespaced_pod(name=pod_name, namespace=namespace)
|
|
137
|
+
if job:
|
|
138
|
+
core_api.delete_namespaced_pod(name=pod_name, namespace=namespace)
|
|
139
|
+
else:
|
|
140
|
+
log.warning(
|
|
141
|
+
"Pod %s not found in namespace %s, skipping deletion",
|
|
142
|
+
pod_name,
|
|
143
|
+
namespace,
|
|
144
|
+
)
|
|
145
|
+
except ApiException as exc:
|
|
146
|
+
if exc.status == 404:
|
|
147
|
+
log.warning(
|
|
148
|
+
"Pod %s not found in namespace %s, skipping deletion",
|
|
149
|
+
pod_name,
|
|
150
|
+
namespace,
|
|
151
|
+
)
|
|
152
|
+
else:
|
|
153
|
+
log.error("Exception when deleting namespaced job: %s", exc)
|
vantage6/cli/node/list.py
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import click
|
|
2
|
-
import docker
|
|
3
|
-
from colorama import Fore, Style
|
|
4
2
|
|
|
5
|
-
from vantage6.common import
|
|
6
|
-
from vantage6.common.docker.addons import check_docker_running
|
|
7
|
-
from vantage6.common.globals import APPNAME
|
|
3
|
+
from vantage6.common.globals import InstanceType
|
|
8
4
|
|
|
9
|
-
from vantage6.cli.
|
|
10
|
-
from vantage6.cli.node.common import find_running_node_names
|
|
5
|
+
from vantage6.cli.common.list import get_configuration_list
|
|
11
6
|
|
|
12
7
|
|
|
13
8
|
@click.command()
|
|
@@ -18,40 +13,4 @@ def cli_node_list() -> None:
|
|
|
18
13
|
Note that this command cannot find node configuration files in custom
|
|
19
14
|
directories.
|
|
20
15
|
"""
|
|
21
|
-
|
|
22
|
-
check_docker_running()
|
|
23
|
-
client = docker.from_env()
|
|
24
|
-
|
|
25
|
-
running_node_names = find_running_node_names(client)
|
|
26
|
-
|
|
27
|
-
header = "\nName" + (21 * " ") + "Status" + (10 * " ") + "System/User"
|
|
28
|
-
|
|
29
|
-
click.echo(header)
|
|
30
|
-
click.echo("-" * len(header))
|
|
31
|
-
|
|
32
|
-
running = Fore.GREEN + "Running" + Style.RESET_ALL
|
|
33
|
-
stopped = Fore.RED + "Not running" + Style.RESET_ALL
|
|
34
|
-
|
|
35
|
-
# system folders
|
|
36
|
-
configs, f1 = NodeContext.available_configurations(system_folders=True)
|
|
37
|
-
for config in configs:
|
|
38
|
-
status = (
|
|
39
|
-
running
|
|
40
|
-
if f"{APPNAME}-{config.name}-system" in running_node_names
|
|
41
|
-
else stopped
|
|
42
|
-
)
|
|
43
|
-
click.echo(f"{config.name:25}{status:25}System ")
|
|
44
|
-
|
|
45
|
-
# user folders
|
|
46
|
-
configs, f2 = NodeContext.available_configurations(system_folders=False)
|
|
47
|
-
for config in configs:
|
|
48
|
-
status = (
|
|
49
|
-
running
|
|
50
|
-
if f"{APPNAME}-{config.name}-user" in running_node_names
|
|
51
|
-
else stopped
|
|
52
|
-
)
|
|
53
|
-
click.echo(f"{config.name:25}{status:25}User ")
|
|
54
|
-
|
|
55
|
-
click.echo("-" * 53)
|
|
56
|
-
if len(f1) + len(f2):
|
|
57
|
-
warning(f"{Fore.RED}Failed imports: {len(f1) + len(f2)}{Style.RESET_ALL}")
|
|
16
|
+
get_configuration_list(InstanceType.NODE)
|
vantage6/cli/node/new.py
CHANGED
|
@@ -6,8 +6,10 @@ import questionary as q
|
|
|
6
6
|
|
|
7
7
|
from vantage6.common import error, info, warning
|
|
8
8
|
from vantage6.common.client.node_client import NodeClient
|
|
9
|
+
from vantage6.common.context import AppContext
|
|
9
10
|
from vantage6.common.globals import (
|
|
10
11
|
FILE_BASED_DATABASE_TYPES,
|
|
12
|
+
HTTP_LOCALHOST,
|
|
11
13
|
SERVICE_BASED_DATABASE_TYPES,
|
|
12
14
|
InstanceType,
|
|
13
15
|
NodePolicy,
|
|
@@ -17,6 +19,7 @@ from vantage6.common.globals import (
|
|
|
17
19
|
|
|
18
20
|
from vantage6.cli.common.new import new
|
|
19
21
|
from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
|
|
22
|
+
from vantage6.cli.utils import prompt_config_name
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
@click.command()
|
|
@@ -52,8 +55,12 @@ def cli_node_new_configuration(
|
|
|
52
55
|
Checks if the configuration already exists. If this is not the case
|
|
53
56
|
a questionnaire is invoked to create a new configuration file.
|
|
54
57
|
"""
|
|
58
|
+
name = prompt_config_name(name)
|
|
59
|
+
dirs = AppContext.instance_folders(InstanceType.NODE, name, system_folders)
|
|
60
|
+
default_data_dir = str(dirs["data"])
|
|
55
61
|
new(
|
|
56
|
-
|
|
62
|
+
config_producing_func=node_configuration_questionaire,
|
|
63
|
+
config_producing_func_args=(default_data_dir, name),
|
|
57
64
|
name=name,
|
|
58
65
|
system_folders=system_folders,
|
|
59
66
|
namespace=namespace,
|
|
@@ -62,14 +69,14 @@ def cli_node_new_configuration(
|
|
|
62
69
|
)
|
|
63
70
|
|
|
64
71
|
|
|
65
|
-
def node_configuration_questionaire(
|
|
72
|
+
def node_configuration_questionaire(data_dir: str, instance_name: str) -> dict:
|
|
66
73
|
"""
|
|
67
74
|
Questionary to generate a config file for the node instance.
|
|
68
75
|
|
|
69
76
|
Parameters
|
|
70
77
|
----------
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
data_dir : str
|
|
79
|
+
Path to the data directory of the node instance.
|
|
73
80
|
instance_name : str
|
|
74
81
|
Name of the node instance.
|
|
75
82
|
|
|
@@ -85,7 +92,7 @@ def node_configuration_questionaire(dirs: dict, instance_name: str) -> dict:
|
|
|
85
92
|
"type": "text",
|
|
86
93
|
"name": "server_url",
|
|
87
94
|
"message": "The base-URL of the server:",
|
|
88
|
-
"default":
|
|
95
|
+
"default": HTTP_LOCALHOST,
|
|
89
96
|
},
|
|
90
97
|
]
|
|
91
98
|
)
|
|
@@ -117,7 +124,7 @@ def node_configuration_questionaire(dirs: dict, instance_name: str) -> dict:
|
|
|
117
124
|
"type": "text",
|
|
118
125
|
"name": "task_dir",
|
|
119
126
|
"message": "Task directory path:",
|
|
120
|
-
"default":
|
|
127
|
+
"default": data_dir,
|
|
121
128
|
},
|
|
122
129
|
]
|
|
123
130
|
)
|
vantage6/cli/node/set_api_key.py
CHANGED
|
@@ -3,7 +3,7 @@ import questionary as q
|
|
|
3
3
|
|
|
4
4
|
from vantage6.common import ensure_config_dir_writable, error, info
|
|
5
5
|
|
|
6
|
-
from vantage6.cli.
|
|
6
|
+
from vantage6.cli.configuration_create import NodeConfigurationManager
|
|
7
7
|
from vantage6.cli.context.node import NodeContext
|
|
8
8
|
from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
|
|
9
9
|
from vantage6.cli.node.common import select_node
|
vantage6/cli/node/start.py
CHANGED
|
@@ -3,6 +3,7 @@ import click
|
|
|
3
3
|
from vantage6.common import info
|
|
4
4
|
from vantage6.common.globals import InstanceType
|
|
5
5
|
|
|
6
|
+
from vantage6.cli.common.attach import attach_logs
|
|
6
7
|
from vantage6.cli.common.decorator import click_insert_context
|
|
7
8
|
from vantage6.cli.common.start import (
|
|
8
9
|
helm_install,
|
|
@@ -10,11 +11,11 @@ from vantage6.cli.common.start import (
|
|
|
10
11
|
start_port_forward,
|
|
11
12
|
)
|
|
12
13
|
from vantage6.cli.common.utils import (
|
|
13
|
-
attach_logs,
|
|
14
14
|
create_directory_if_not_exists,
|
|
15
|
+
select_context_and_namespace,
|
|
15
16
|
)
|
|
16
17
|
from vantage6.cli.context.node import NodeContext
|
|
17
|
-
from vantage6.cli.globals import ChartName
|
|
18
|
+
from vantage6.cli.globals import ChartName, InfraComponentName
|
|
18
19
|
|
|
19
20
|
from vantage6.node.globals import DEFAULT_PROXY_SERVER_PORT
|
|
20
21
|
|
|
@@ -27,7 +28,14 @@ from vantage6.node.globals import DEFAULT_PROXY_SERVER_PORT
|
|
|
27
28
|
default=False,
|
|
28
29
|
help="Show node logs on the current console after starting the node",
|
|
29
30
|
)
|
|
30
|
-
@
|
|
31
|
+
@click.option("--local-chart-dir", default=None, help="Local chart directory to use")
|
|
32
|
+
@click.option("--sandbox/--no-sandbox", "sandbox", default=False)
|
|
33
|
+
@click_insert_context(
|
|
34
|
+
InstanceType.NODE,
|
|
35
|
+
include_name=True,
|
|
36
|
+
include_system_folders=True,
|
|
37
|
+
sandbox_param="sandbox",
|
|
38
|
+
)
|
|
31
39
|
def cli_node_start(
|
|
32
40
|
ctx: NodeContext,
|
|
33
41
|
name: str,
|
|
@@ -35,13 +43,19 @@ def cli_node_start(
|
|
|
35
43
|
context: str,
|
|
36
44
|
namespace: str,
|
|
37
45
|
attach: bool,
|
|
46
|
+
local_chart_dir: str,
|
|
38
47
|
) -> None:
|
|
39
48
|
"""
|
|
40
49
|
Start the node.
|
|
41
50
|
"""
|
|
42
51
|
info("Starting node...")
|
|
43
52
|
|
|
44
|
-
prestart_checks(ctx, InstanceType.NODE, name, system_folders
|
|
53
|
+
prestart_checks(ctx, InstanceType.NODE, name, system_folders)
|
|
54
|
+
|
|
55
|
+
context, namespace = select_context_and_namespace(
|
|
56
|
+
context=context,
|
|
57
|
+
namespace=namespace,
|
|
58
|
+
)
|
|
45
59
|
|
|
46
60
|
create_directory_if_not_exists(ctx.log_dir)
|
|
47
61
|
create_directory_if_not_exists(ctx.data_dir)
|
|
@@ -96,16 +110,25 @@ def cli_node_start(
|
|
|
96
110
|
values_file=ctx.config_file,
|
|
97
111
|
context=context,
|
|
98
112
|
namespace=namespace,
|
|
113
|
+
local_chart_dir=local_chart_dir,
|
|
99
114
|
)
|
|
100
115
|
|
|
101
116
|
# start port forward for the node proxy server
|
|
102
117
|
start_port_forward(
|
|
103
118
|
service_name=f"{ctx.helm_release_name}-node-service",
|
|
104
|
-
service_port=ctx.config["node"].get("
|
|
105
|
-
port=ctx.config["node"].get("
|
|
119
|
+
service_port=ctx.config["node"].get("proxyPort", DEFAULT_PROXY_SERVER_PORT),
|
|
120
|
+
port=ctx.config["node"].get("proxyPort", DEFAULT_PROXY_SERVER_PORT),
|
|
106
121
|
context=context,
|
|
107
122
|
namespace=namespace,
|
|
108
123
|
)
|
|
109
124
|
|
|
110
125
|
if attach:
|
|
111
|
-
attach_logs(
|
|
126
|
+
attach_logs(
|
|
127
|
+
name,
|
|
128
|
+
instance_type=InstanceType.NODE,
|
|
129
|
+
infra_component=InfraComponentName.NODE,
|
|
130
|
+
system_folders=system_folders,
|
|
131
|
+
context=context,
|
|
132
|
+
namespace=namespace,
|
|
133
|
+
is_sandbox=ctx.is_sandbox,
|
|
134
|
+
)
|