diracx-cli 0.0.1a26__py3-none-any.whl → 0.0.1a28__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.
- diracx/cli/internal/legacy.py +115 -35
- {diracx_cli-0.0.1a26.dist-info → diracx_cli-0.0.1a28.dist-info}/METADATA +1 -1
- {diracx_cli-0.0.1a26.dist-info → diracx_cli-0.0.1a28.dist-info}/RECORD +6 -6
- {diracx_cli-0.0.1a26.dist-info → diracx_cli-0.0.1a28.dist-info}/WHEEL +1 -1
- {diracx_cli-0.0.1a26.dist-info → diracx_cli-0.0.1a28.dist-info}/entry_points.txt +0 -0
- {diracx_cli-0.0.1a26.dist-info → diracx_cli-0.0.1a28.dist-info}/top_level.txt +0 -0
diracx/cli/internal/legacy.py
CHANGED
|
@@ -4,6 +4,7 @@ import base64
|
|
|
4
4
|
import hashlib
|
|
5
5
|
import json
|
|
6
6
|
import os
|
|
7
|
+
import re
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
from typing import TYPE_CHECKING, cast
|
|
9
10
|
from urllib.parse import urljoin, urlparse
|
|
@@ -26,6 +27,12 @@ from ..utils import AsyncTyper
|
|
|
26
27
|
app = AsyncTyper()
|
|
27
28
|
|
|
28
29
|
|
|
30
|
+
BASE_64_URL_SAFE_PATTERN = (
|
|
31
|
+
r"(?:[A-Za-z0-9\-_]{4})*(?:[A-Za-z0-9\-_]{2}==|[A-Za-z0-9\-_]{3}=)?"
|
|
32
|
+
)
|
|
33
|
+
LEGACY_EXCHANGE_PATTERN = rf"diracx:legacy:({BASE_64_URL_SAFE_PATTERN})"
|
|
34
|
+
|
|
35
|
+
|
|
29
36
|
class IdPConfig(BaseModel):
|
|
30
37
|
URL: str
|
|
31
38
|
ClientID: str
|
|
@@ -182,12 +189,13 @@ def generate_helm_values(
|
|
|
182
189
|
"developer": {"enabled": False},
|
|
183
190
|
"initCs": {"enabled": True},
|
|
184
191
|
"initSecrets": {"enabled": True},
|
|
185
|
-
"initSql": {"enabled": False
|
|
192
|
+
"initSql": {"enabled": False},
|
|
186
193
|
"cert-manager": {"enabled": False},
|
|
187
194
|
"cert-manager-issuer": {"enabled": False},
|
|
188
195
|
"minio": {"enabled": False},
|
|
189
196
|
"dex": {"enabled": False},
|
|
190
197
|
"opensearch": {"enabled": False},
|
|
198
|
+
# This is Openshift specific, change it maybe
|
|
191
199
|
"ingress": {
|
|
192
200
|
"enabled": True,
|
|
193
201
|
"className": None,
|
|
@@ -199,12 +207,7 @@ def generate_helm_values(
|
|
|
199
207
|
},
|
|
200
208
|
"rabbitmq": {"enabled": False},
|
|
201
209
|
"mysql": {"enabled": False},
|
|
202
|
-
"
|
|
203
|
-
"manageOSIndices": False,
|
|
204
|
-
"mysqlDatabases": [],
|
|
205
|
-
"osDatabases": [],
|
|
206
|
-
"settings": {},
|
|
207
|
-
},
|
|
210
|
+
"global": {"images": {"services": "FILL ME"}, "storageClassName": "FILL ME"},
|
|
208
211
|
}
|
|
209
212
|
|
|
210
213
|
cfg = diraccfg.CFG().loadFromBuffer(public_cfg.read_text())
|
|
@@ -216,19 +219,18 @@ def generate_helm_values(
|
|
|
216
219
|
|
|
217
220
|
diracx_url = cfg["DiracX"]["URL"]
|
|
218
221
|
diracx_hostname = urlparse(diracx_url).netloc.split(":", 1)[0]
|
|
219
|
-
|
|
220
|
-
diracx_config = {
|
|
221
|
-
"
|
|
222
|
-
"
|
|
223
|
-
"osDatabases": [],
|
|
224
|
-
"settings": {},
|
|
222
|
+
|
|
223
|
+
diracx_config: dict = {
|
|
224
|
+
"sqlDbs": {},
|
|
225
|
+
"osDbs": {},
|
|
225
226
|
}
|
|
226
227
|
|
|
227
|
-
diracx_settings: dict[str, str] = {}
|
|
228
|
+
diracx_settings: dict[str, str] = {"DIRACX_CONFIG_BACKEND_URL": "FILL ME"}
|
|
228
229
|
diracx_config["settings"] = diracx_settings
|
|
229
230
|
helm_values["diracx"] = diracx_config
|
|
230
231
|
diracx_config["hostname"] = diracx_hostname
|
|
231
232
|
|
|
233
|
+
diracx_settings["DIRACX_SERVICE_AUTH_TOKEN_ISSUER"] = diracx_url
|
|
232
234
|
diracx_settings["DIRACX_SERVICE_AUTH_ALLOWED_REDIRECTS"] = json.dumps(
|
|
233
235
|
[
|
|
234
236
|
urljoin(diracx_url, "api/docs/oauth2-redirect"),
|
|
@@ -236,47 +238,122 @@ def generate_helm_values(
|
|
|
236
238
|
]
|
|
237
239
|
)
|
|
238
240
|
|
|
241
|
+
### SQL DBs
|
|
242
|
+
|
|
239
243
|
default_db_user = cfg["Systems"].get("Databases", {}).get("User")
|
|
240
244
|
default_db_password = cfg["Systems"].get("Databases", {}).get("Password")
|
|
241
|
-
|
|
242
|
-
|
|
245
|
+
default_db_host = cfg["Systems"].get("Databases", {}).get("Host", "FILL ME")
|
|
246
|
+
default_db_port = cfg["Systems"].get("Databases", {}).get("Port", "FILL ME")
|
|
243
247
|
|
|
244
248
|
all_db_configs = {}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
sql_dbs = {
|
|
250
|
+
"dbs": {},
|
|
251
|
+
"default": {
|
|
252
|
+
"host": f"{default_db_host}:{default_db_port}",
|
|
253
|
+
"password": default_db_password,
|
|
254
|
+
"rootPassword": "FILL ME",
|
|
255
|
+
"rootUser": "FILL ME",
|
|
256
|
+
"user": default_db_user,
|
|
257
|
+
},
|
|
258
|
+
}
|
|
259
|
+
for _system, system_config in cfg["Systems"].items():
|
|
260
|
+
all_db_configs.update(system_config.get("Databases", {}))
|
|
249
261
|
|
|
250
262
|
from diracx.core.extensions import select_from_extension
|
|
251
263
|
|
|
252
264
|
for entry_point in select_from_extension(group="diracx.db.sql"):
|
|
265
|
+
|
|
253
266
|
db_name = entry_point.name
|
|
267
|
+
db_config = all_db_configs.get(db_name, {})
|
|
268
|
+
|
|
269
|
+
sql_dbs["dbs"][db_name] = {}
|
|
254
270
|
# There is a DIRAC AuthDB, but it is not the same
|
|
255
271
|
# as the DiracX one
|
|
256
272
|
if db_name == "AuthDB":
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
db_config = all_db_configs[db_name]
|
|
261
|
-
url_name = f"DIRACX_DB_URL_{entry_point.name.upper()}"
|
|
262
|
-
db_user = db_config.get("User", default_db_user)
|
|
263
|
-
db_password = db_config.get("Password", default_db_password)
|
|
264
|
-
db_host = db_config["Host"]
|
|
265
|
-
db_port = db_config["Port"]
|
|
273
|
+
sql_dbs["dbs"]["AuthDB"] = {"internalName": "DiracXAuthDB"}
|
|
274
|
+
|
|
275
|
+
if "DBName" in db_config:
|
|
266
276
|
indb_name = db_config["DBName"]
|
|
277
|
+
if indb_name != db_name:
|
|
278
|
+
sql_dbs["dbs"]["internalName"] = indb_name
|
|
279
|
+
if "User" in db_config:
|
|
280
|
+
sql_dbs["dbs"][db_name]["user"] = db_config.get("User")
|
|
281
|
+
if "Password" in db_config:
|
|
282
|
+
sql_dbs["dbs"][db_name]["password"] = db_config.get("Password")
|
|
283
|
+
if "Host" in db_config or "Port" in db_config:
|
|
284
|
+
sql_dbs["dbs"][db_name][
|
|
285
|
+
"host"
|
|
286
|
+
] = f"{db_config.get('Host', default_db_host)}:{db_config.get('Port', default_db_port)}"
|
|
287
|
+
if not sql_dbs["dbs"][db_name]:
|
|
288
|
+
sql_dbs["dbs"][db_name] = None
|
|
289
|
+
|
|
290
|
+
diracx_config["sqlDbs"] = sql_dbs
|
|
291
|
+
|
|
292
|
+
#### END SQL DB
|
|
293
|
+
|
|
294
|
+
# #### OS DBs
|
|
295
|
+
|
|
296
|
+
default_os_db_user = cfg["Systems"].get("NoSQLDatabases", {}).get("User")
|
|
297
|
+
default_os_db_password = cfg["Systems"].get("NoSQLDatabases", {}).get("Password")
|
|
298
|
+
default_os_db_host = cfg["Systems"].get("NoSQLDatabases", {}).get("Host", "FILL ME")
|
|
299
|
+
|
|
300
|
+
os_dbs = {
|
|
301
|
+
"dbs": {},
|
|
302
|
+
"default": {
|
|
303
|
+
"host": f"{default_os_db_host}",
|
|
304
|
+
"password": default_os_db_password,
|
|
305
|
+
"rootPassword": "FILL ME",
|
|
306
|
+
"rootUser": "FILL ME",
|
|
307
|
+
"user": default_os_db_user,
|
|
308
|
+
},
|
|
309
|
+
}
|
|
267
310
|
|
|
268
|
-
|
|
269
|
-
|
|
311
|
+
for entry_point in select_from_extension(group="diracx.db.os"):
|
|
312
|
+
db_name = entry_point.name
|
|
313
|
+
db_config = all_db_configs.get(db_name, {})
|
|
314
|
+
|
|
315
|
+
os_dbs["dbs"][db_name] = {}
|
|
316
|
+
# There is a DIRAC AuthDB, but it is not the same
|
|
317
|
+
# as the DiracX one
|
|
318
|
+
|
|
319
|
+
if "DBName" in db_config:
|
|
320
|
+
indb_name = db_config["DBName"]
|
|
321
|
+
if indb_name != db_name:
|
|
322
|
+
os_dbs["dbs"]["internalName"] = indb_name
|
|
323
|
+
if "User" in db_config:
|
|
324
|
+
os_dbs["dbs"][db_name]["user"] = db_config["User"]
|
|
325
|
+
if "Password" in db_config:
|
|
326
|
+
os_dbs["dbs"][db_name]["password"] = db_config["Password"]
|
|
327
|
+
if "Host" in db_config:
|
|
328
|
+
os_dbs["dbs"][db_name]["host"] = db_config["Host"]
|
|
329
|
+
|
|
330
|
+
if not os_dbs["dbs"][db_name]:
|
|
331
|
+
os_dbs["dbs"][db_name] = None
|
|
332
|
+
|
|
333
|
+
diracx_config["osDbs"] = os_dbs
|
|
334
|
+
|
|
335
|
+
#### End OS DBs
|
|
270
336
|
|
|
271
337
|
# Settings for the legacy
|
|
272
338
|
try:
|
|
339
|
+
if match := re.fullmatch(
|
|
340
|
+
LEGACY_EXCHANGE_PATTERN, cfg["DiracX"]["LegacyExchangeApiKey"]
|
|
341
|
+
):
|
|
342
|
+
raw_token = base64.urlsafe_b64decode(match.group(1))
|
|
343
|
+
else:
|
|
344
|
+
raise ValueError(
|
|
345
|
+
"Invalid authorization header",
|
|
346
|
+
)
|
|
347
|
+
|
|
273
348
|
diracx_settings["DIRACX_LEGACY_EXCHANGE_HASHED_API_KEY"] = hashlib.sha256(
|
|
274
|
-
|
|
349
|
+
raw_token
|
|
275
350
|
).hexdigest()
|
|
276
351
|
except KeyError:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
352
|
+
error_msg = """
|
|
353
|
+
ERROR: you must have '/DiracX/LegacyExchangeApiKey' already set.
|
|
354
|
+
See the `legacy_exchange` function definition for how to generate it in python
|
|
355
|
+
"""
|
|
356
|
+
typer.echo(error_msg, err=True)
|
|
280
357
|
raise typer.Exit(1) from None
|
|
281
358
|
# Sandboxstore settings
|
|
282
359
|
# TODO: Integrate minio for production use (ingress, etc)
|
|
@@ -295,3 +372,6 @@ def generate_helm_values(
|
|
|
295
372
|
diracx_settings["DIRACX_SERVICE_JOBS_ENABLED"] = "true"
|
|
296
373
|
diracx_settings["DIRACX_SANDBOX_STORE_AUTO_CREATE_BUCKET"] = "true"
|
|
297
374
|
output_file.write_text(yaml.safe_dump(helm_values))
|
|
375
|
+
typer.echo(
|
|
376
|
+
"The file is incomplete and needs manual editing (grep for 'FILL ME')", err=True
|
|
377
|
+
)
|
|
@@ -7,9 +7,9 @@ diracx/cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
7
7
|
diracx/cli/utils.py,sha256=NwhMMHwveKOdW2aoSqpnLnfOKhPnjmPPLpX69naPAzc,855
|
|
8
8
|
diracx/cli/internal/__init__.py,sha256=KZrzVcKu3YhNev2XF2KA2nttAa9ONU3CVUgatVMonJ4,143
|
|
9
9
|
diracx/cli/internal/config.py,sha256=xPT7lnJ3QPqJgaNJuMoUpV6CIIxZY_d7HKFb4uINb_8,6552
|
|
10
|
-
diracx/cli/internal/legacy.py,sha256=
|
|
11
|
-
diracx_cli-0.0.
|
|
12
|
-
diracx_cli-0.0.
|
|
13
|
-
diracx_cli-0.0.
|
|
14
|
-
diracx_cli-0.0.
|
|
15
|
-
diracx_cli-0.0.
|
|
10
|
+
diracx/cli/internal/legacy.py,sha256=sbiWdvIWTLDE4gnuZQJ00xCf1th2rYffPtMsl9X--lU,13181
|
|
11
|
+
diracx_cli-0.0.1a28.dist-info/METADATA,sha256=YTyI_qhZis30sjljxRe0v95YeKq-vVr9Oui7p4Og76o,803
|
|
12
|
+
diracx_cli-0.0.1a28.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
13
|
+
diracx_cli-0.0.1a28.dist-info/entry_points.txt,sha256=b1909GHVOkFUiHVglNlpwia4Ug-7Ncrg-8D5xtYVAlw,169
|
|
14
|
+
diracx_cli-0.0.1a28.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
|
|
15
|
+
diracx_cli-0.0.1a28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|