rucio-clients 35.8.2__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.
- rucio/__init__.py +17 -0
- rucio/alembicrevision.py +15 -0
- rucio/client/__init__.py +15 -0
- rucio/client/accountclient.py +433 -0
- rucio/client/accountlimitclient.py +183 -0
- rucio/client/baseclient.py +974 -0
- rucio/client/client.py +76 -0
- rucio/client/configclient.py +126 -0
- rucio/client/credentialclient.py +59 -0
- rucio/client/didclient.py +866 -0
- rucio/client/diracclient.py +56 -0
- rucio/client/downloadclient.py +1785 -0
- rucio/client/exportclient.py +44 -0
- rucio/client/fileclient.py +50 -0
- rucio/client/importclient.py +42 -0
- rucio/client/lifetimeclient.py +90 -0
- rucio/client/lockclient.py +109 -0
- rucio/client/metaconventionsclient.py +140 -0
- rucio/client/pingclient.py +44 -0
- rucio/client/replicaclient.py +454 -0
- rucio/client/requestclient.py +125 -0
- rucio/client/rseclient.py +746 -0
- rucio/client/ruleclient.py +294 -0
- rucio/client/scopeclient.py +90 -0
- rucio/client/subscriptionclient.py +173 -0
- rucio/client/touchclient.py +82 -0
- rucio/client/uploadclient.py +955 -0
- rucio/common/__init__.py +13 -0
- rucio/common/cache.py +74 -0
- rucio/common/config.py +801 -0
- rucio/common/constants.py +159 -0
- rucio/common/constraints.py +17 -0
- rucio/common/didtype.py +189 -0
- rucio/common/exception.py +1151 -0
- rucio/common/extra.py +36 -0
- rucio/common/logging.py +420 -0
- rucio/common/pcache.py +1408 -0
- rucio/common/plugins.py +153 -0
- rucio/common/policy.py +84 -0
- rucio/common/schema/__init__.py +150 -0
- rucio/common/schema/atlas.py +413 -0
- rucio/common/schema/belleii.py +408 -0
- rucio/common/schema/domatpc.py +401 -0
- rucio/common/schema/escape.py +426 -0
- rucio/common/schema/generic.py +433 -0
- rucio/common/schema/generic_multi_vo.py +412 -0
- rucio/common/schema/icecube.py +406 -0
- rucio/common/stomp_utils.py +159 -0
- rucio/common/stopwatch.py +55 -0
- rucio/common/test_rucio_server.py +148 -0
- rucio/common/types.py +403 -0
- rucio/common/utils.py +2238 -0
- rucio/rse/__init__.py +96 -0
- rucio/rse/protocols/__init__.py +13 -0
- rucio/rse/protocols/bittorrent.py +184 -0
- rucio/rse/protocols/cache.py +122 -0
- rucio/rse/protocols/dummy.py +111 -0
- rucio/rse/protocols/gfal.py +703 -0
- rucio/rse/protocols/globus.py +243 -0
- rucio/rse/protocols/gsiftp.py +92 -0
- rucio/rse/protocols/http_cache.py +82 -0
- rucio/rse/protocols/mock.py +123 -0
- rucio/rse/protocols/ngarc.py +209 -0
- rucio/rse/protocols/posix.py +250 -0
- rucio/rse/protocols/protocol.py +594 -0
- rucio/rse/protocols/rclone.py +364 -0
- rucio/rse/protocols/rfio.py +136 -0
- rucio/rse/protocols/srm.py +338 -0
- rucio/rse/protocols/ssh.py +413 -0
- rucio/rse/protocols/storm.py +206 -0
- rucio/rse/protocols/webdav.py +550 -0
- rucio/rse/protocols/xrootd.py +301 -0
- rucio/rse/rsemanager.py +764 -0
- rucio/vcsversion.py +11 -0
- rucio/version.py +38 -0
- rucio_clients-35.8.2.data/data/etc/rse-accounts.cfg.template +25 -0
- rucio_clients-35.8.2.data/data/etc/rucio.cfg.atlas.client.template +42 -0
- rucio_clients-35.8.2.data/data/etc/rucio.cfg.template +257 -0
- rucio_clients-35.8.2.data/data/requirements.client.txt +15 -0
- rucio_clients-35.8.2.data/data/rucio_client/merge_rucio_configs.py +144 -0
- rucio_clients-35.8.2.data/scripts/rucio +2542 -0
- rucio_clients-35.8.2.data/scripts/rucio-admin +2447 -0
- rucio_clients-35.8.2.dist-info/METADATA +50 -0
- rucio_clients-35.8.2.dist-info/RECORD +88 -0
- rucio_clients-35.8.2.dist-info/WHEEL +5 -0
- rucio_clients-35.8.2.dist-info/licenses/AUTHORS.rst +97 -0
- rucio_clients-35.8.2.dist-info/licenses/LICENSE +201 -0
- rucio_clients-35.8.2.dist-info/top_level.txt +1 -0
rucio/common/plugins.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Copyright European Organization for Nuclear Research (CERN) since 2012
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import importlib
|
|
16
|
+
import os
|
|
17
|
+
from collections.abc import Callable
|
|
18
|
+
from configparser import NoOptionError, NoSectionError
|
|
19
|
+
from typing import Any, TypeVar
|
|
20
|
+
|
|
21
|
+
from rucio.common import config
|
|
22
|
+
from rucio.common.exception import InvalidAlgorithmName
|
|
23
|
+
|
|
24
|
+
PolicyPackageAlgorithmsT = TypeVar('PolicyPackageAlgorithmsT', bound='PolicyPackageAlgorithms')
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PolicyPackageAlgorithms:
|
|
28
|
+
"""
|
|
29
|
+
Base class for Rucio Policy Package Algorithms
|
|
30
|
+
|
|
31
|
+
ALGORITHMS is of type Dict[str, Dict[str. Callable[..., Any]]]
|
|
32
|
+
where the key is the algorithm type and the value is a dictionary of algorithm names and their callables
|
|
33
|
+
"""
|
|
34
|
+
_ALGORITHMS: dict[str, dict[str, Callable[..., Any]]] = {}
|
|
35
|
+
_loaded_policy_modules = False
|
|
36
|
+
|
|
37
|
+
def __init__(self) -> None:
|
|
38
|
+
if not self._loaded_policy_modules:
|
|
39
|
+
self._register_all_policy_package_algorithms()
|
|
40
|
+
self._loaded_policy_modules = True
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def _get_one_algorithm(cls: type[PolicyPackageAlgorithmsT], algorithm_type: str, name: str) -> Callable[..., Any]:
|
|
44
|
+
"""
|
|
45
|
+
Get the algorithm from the dictionary of algorithms
|
|
46
|
+
"""
|
|
47
|
+
return cls._ALGORITHMS[algorithm_type][name]
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def _get_algorithms(cls: type[PolicyPackageAlgorithmsT], algorithm_type: str) -> dict[str, Callable[..., Any]]:
|
|
51
|
+
"""
|
|
52
|
+
Get the dictionary of algorithms for a given type
|
|
53
|
+
"""
|
|
54
|
+
return cls._ALGORITHMS[algorithm_type]
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def _register(
|
|
58
|
+
cls: type[PolicyPackageAlgorithmsT],
|
|
59
|
+
algorithm_type: str, algorithm_dict: dict[str, Callable[..., Any]]) -> None:
|
|
60
|
+
"""
|
|
61
|
+
Provided a dictionary of callable function,
|
|
62
|
+
and the associated algorithm type,
|
|
63
|
+
register it as one of the valid algorithms.
|
|
64
|
+
"""
|
|
65
|
+
if algorithm_type in cls._ALGORITHMS:
|
|
66
|
+
cls._ALGORITHMS[algorithm_type].update(algorithm_dict)
|
|
67
|
+
else:
|
|
68
|
+
cls._ALGORITHMS[algorithm_type] = algorithm_dict
|
|
69
|
+
|
|
70
|
+
@classmethod
|
|
71
|
+
def _supports(cls: type[PolicyPackageAlgorithmsT], algorithm_type: str, name: str) -> bool:
|
|
72
|
+
"""
|
|
73
|
+
Check if a algorithm is supported by the plugin
|
|
74
|
+
"""
|
|
75
|
+
return name in cls._ALGORITHMS.get(algorithm_type, {})
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def _register_all_policy_package_algorithms(cls: type[PolicyPackageAlgorithmsT]) -> None:
|
|
79
|
+
'''
|
|
80
|
+
Loads all the algorithms of a given type from the policy package(s) and registers them
|
|
81
|
+
:param algorithm_type: the type of algorithm to register (e.g. 'lfn2pfn')
|
|
82
|
+
:param dictionary: the dictionary to register them in
|
|
83
|
+
:param vo: the name of the relevant VO (None for single VO)
|
|
84
|
+
'''
|
|
85
|
+
try:
|
|
86
|
+
multivo = config.config_get_bool('common', 'multi_vo')
|
|
87
|
+
except (NoOptionError, NoSectionError):
|
|
88
|
+
multivo = False
|
|
89
|
+
if not multivo:
|
|
90
|
+
# single policy package
|
|
91
|
+
cls._try_importing_policy()
|
|
92
|
+
else:
|
|
93
|
+
# determine whether on client or server
|
|
94
|
+
client = False
|
|
95
|
+
if 'RUCIO_CLIENT_MODE' not in os.environ:
|
|
96
|
+
if not config.config_has_section('database') and config.config_has_section('client'):
|
|
97
|
+
client = True
|
|
98
|
+
else:
|
|
99
|
+
if os.environ['RUCIO_CLIENT_MODE']:
|
|
100
|
+
client = True
|
|
101
|
+
|
|
102
|
+
# on client, only register algorithms for selected VO
|
|
103
|
+
if client:
|
|
104
|
+
if 'RUCIO_VO' in os.environ:
|
|
105
|
+
vo = os.environ['RUCIO_VO']
|
|
106
|
+
else:
|
|
107
|
+
try:
|
|
108
|
+
vo = str(config.config_get('client', 'vo'))
|
|
109
|
+
except (NoOptionError, NoSectionError):
|
|
110
|
+
vo = 'def'
|
|
111
|
+
cls._try_importing_policy(vo)
|
|
112
|
+
# on server, list all VOs and register their algorithms
|
|
113
|
+
else:
|
|
114
|
+
from rucio.core.vo import list_vos
|
|
115
|
+
# policy package per VO
|
|
116
|
+
vos = list_vos()
|
|
117
|
+
for vo in vos:
|
|
118
|
+
cls._try_importing_policy(vo['vo'])
|
|
119
|
+
|
|
120
|
+
@classmethod
|
|
121
|
+
def _try_importing_policy(cls: type[PolicyPackageAlgorithmsT], vo: str = "") -> None:
|
|
122
|
+
try:
|
|
123
|
+
# import from utils here to avoid circular import
|
|
124
|
+
from rucio.common.utils import check_policy_package_version
|
|
125
|
+
|
|
126
|
+
env_name = 'RUCIO_POLICY_PACKAGE' + ('' if not vo else '_' + vo.upper())
|
|
127
|
+
package = getattr(os.environ, env_name, "")
|
|
128
|
+
if not package:
|
|
129
|
+
package = str(config.config_get('policy', 'package' + ('' if not vo else '-' + vo)))
|
|
130
|
+
|
|
131
|
+
check_policy_package_version(package)
|
|
132
|
+
module = importlib.import_module(package)
|
|
133
|
+
|
|
134
|
+
if hasattr(module, 'get_algorithms'):
|
|
135
|
+
all_algorithms = module.get_algorithms()
|
|
136
|
+
|
|
137
|
+
# for backward compatibility, rename 'surl' to 'non_deterministic_pfn' here
|
|
138
|
+
if 'surl' in all_algorithms:
|
|
139
|
+
all_algorithms['non_deterministic_pfn'] = all_algorithms['surl']
|
|
140
|
+
|
|
141
|
+
# check that the names are correctly prefixed for multi-VO
|
|
142
|
+
if vo:
|
|
143
|
+
for _, algorithms in all_algorithms.items():
|
|
144
|
+
for k in algorithms.keys():
|
|
145
|
+
if not k.lower().startswith(vo.lower()):
|
|
146
|
+
raise InvalidAlgorithmName(k, vo)
|
|
147
|
+
|
|
148
|
+
# Updates the dictionary with the algorithms from the policy package
|
|
149
|
+
for algorithm_type, algorithm_dict in all_algorithms.items():
|
|
150
|
+
cls._register(algorithm_type, algorithm_dict)
|
|
151
|
+
|
|
152
|
+
except (NoOptionError, NoSectionError, ImportError):
|
|
153
|
+
pass
|
rucio/common/policy.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Copyright European Organization for Nuclear Research (CERN) since 2012
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
import os
|
|
17
|
+
from configparser import NoOptionError, NoSectionError
|
|
18
|
+
from functools import wraps
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
from dogpile.cache import make_region
|
|
22
|
+
from dogpile.cache.api import NoValue
|
|
23
|
+
|
|
24
|
+
from rucio.common.config import config_get
|
|
25
|
+
from rucio.common.exception import UndefinedPolicy
|
|
26
|
+
|
|
27
|
+
REGION = make_region().configure('dogpile.cache.memory',
|
|
28
|
+
expiration_time=900)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def get_policy() -> str:
|
|
32
|
+
policy = REGION.get('policy')
|
|
33
|
+
if isinstance(policy, NoValue):
|
|
34
|
+
try:
|
|
35
|
+
policy = config_get('policy', 'permission')
|
|
36
|
+
except (NoOptionError, NoSectionError):
|
|
37
|
+
policy = 'atlas'
|
|
38
|
+
REGION.set('policy', policy)
|
|
39
|
+
return policy
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_scratchdisk_lifetime() -> int:
|
|
43
|
+
scratchdisk_lifetime = REGION.get('scratchdisk_lifetime')
|
|
44
|
+
if isinstance(scratchdisk_lifetime, NoValue):
|
|
45
|
+
try:
|
|
46
|
+
scratchdisk_lifetime = config_get('policy', 'scratchdisk_lifetime')
|
|
47
|
+
scratchdisk_lifetime = int(scratchdisk_lifetime)
|
|
48
|
+
except (NoOptionError, NoSectionError, ValueError):
|
|
49
|
+
scratchdisk_lifetime = 14
|
|
50
|
+
REGION.set('scratchdisk_lifetime', scratchdisk_lifetime)
|
|
51
|
+
return scratchdisk_lifetime
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def get_lifetime_policy() -> dict[str, list[dict[str, Any]]]:
|
|
55
|
+
lifetime_dict = REGION.get('lifetime_dict')
|
|
56
|
+
if isinstance(lifetime_dict, NoValue):
|
|
57
|
+
lifetime_dict = {'data': [], 'mc': [], 'valid': [], 'other': []}
|
|
58
|
+
lifetime_dir = '/opt/rucio/etc/policies'
|
|
59
|
+
try:
|
|
60
|
+
lifetime_dir = config_get('lifetime', 'directory')
|
|
61
|
+
except (NoSectionError, NoOptionError):
|
|
62
|
+
pass
|
|
63
|
+
for dtype in ['data', 'mc', 'valid', 'other']:
|
|
64
|
+
input_file_name = '%s/config_%s.json' % (lifetime_dir, dtype)
|
|
65
|
+
if os.path.isfile(input_file_name):
|
|
66
|
+
with open(input_file_name, 'r') as input_file:
|
|
67
|
+
lifetime_dict[dtype] = json.load(input_file)
|
|
68
|
+
REGION.set('lifetime_dict', lifetime_dict)
|
|
69
|
+
return lifetime_dict
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def policy_filter(function):
|
|
73
|
+
mapping = {'atlas': ['get_scratch_policy', 'archive_localgroupdisk_datasets']}
|
|
74
|
+
policy = get_policy()
|
|
75
|
+
if policy in mapping and function.__name__ in mapping[policy]:
|
|
76
|
+
@wraps(function)
|
|
77
|
+
def new_funct(*args, **kwargs):
|
|
78
|
+
return function(*args, **kwargs)
|
|
79
|
+
return new_funct
|
|
80
|
+
|
|
81
|
+
@wraps(function)
|
|
82
|
+
def raise_funct(*args, **kwargs):
|
|
83
|
+
raise UndefinedPolicy
|
|
84
|
+
return raise_funct
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Copyright European Organization for Nuclear Research (CERN) since 2012
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import importlib
|
|
16
|
+
from configparser import NoOptionError, NoSectionError
|
|
17
|
+
from os import environ
|
|
18
|
+
from typing import TYPE_CHECKING, Any
|
|
19
|
+
|
|
20
|
+
from rucio.common import config, exception
|
|
21
|
+
from rucio.common.utils import check_policy_package_version
|
|
22
|
+
|
|
23
|
+
if TYPE_CHECKING:
|
|
24
|
+
from types import ModuleType
|
|
25
|
+
|
|
26
|
+
# dictionary of schema modules for each VO
|
|
27
|
+
schema_modules: dict[str, "ModuleType"] = {}
|
|
28
|
+
|
|
29
|
+
# list of unique SCOPE_NAME_REGEXP values from all schemas
|
|
30
|
+
scope_name_regexps: list[str] = []
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
multivo = config.config_get_bool('common', 'multi_vo', check_config_table=False)
|
|
34
|
+
except (NoOptionError, NoSectionError):
|
|
35
|
+
multivo = False
|
|
36
|
+
|
|
37
|
+
# multi-VO version loads schema per-VO on demand
|
|
38
|
+
# we can't get a list of VOs here because the database might not
|
|
39
|
+
# be available as this is imported during the bootstrapping process
|
|
40
|
+
if not multivo:
|
|
41
|
+
GENERIC_FALLBACK = 'generic'
|
|
42
|
+
|
|
43
|
+
if config.config_has_section('policy'):
|
|
44
|
+
try:
|
|
45
|
+
if 'RUCIO_POLICY_PACKAGE' in environ:
|
|
46
|
+
POLICY = environ['RUCIO_POLICY_PACKAGE']
|
|
47
|
+
else:
|
|
48
|
+
POLICY = config.config_get('policy', 'package', check_config_table=False)
|
|
49
|
+
check_policy_package_version(POLICY)
|
|
50
|
+
POLICY = POLICY + ".schema"
|
|
51
|
+
except (NoOptionError, NoSectionError):
|
|
52
|
+
# fall back to old system for now
|
|
53
|
+
try:
|
|
54
|
+
POLICY = config.config_get('policy', 'schema', check_config_table=False)
|
|
55
|
+
except (NoOptionError, NoSectionError):
|
|
56
|
+
POLICY = GENERIC_FALLBACK
|
|
57
|
+
POLICY = 'rucio.common.schema.' + POLICY.lower()
|
|
58
|
+
else:
|
|
59
|
+
POLICY = 'rucio.common.schema.' + GENERIC_FALLBACK.lower()
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
module = importlib.import_module(POLICY)
|
|
63
|
+
except ModuleNotFoundError:
|
|
64
|
+
raise exception.PolicyPackageNotFound(POLICY)
|
|
65
|
+
except ImportError:
|
|
66
|
+
raise exception.ErrorLoadingPolicyPackage(POLICY)
|
|
67
|
+
|
|
68
|
+
schema_modules["def"] = module
|
|
69
|
+
scope_name_regexps.append(module.SCOPE_NAME_REGEXP)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def load_schema_for_vo(vo: str) -> None:
|
|
73
|
+
GENERIC_FALLBACK = 'generic_multi_vo'
|
|
74
|
+
if config.config_has_section('policy'):
|
|
75
|
+
try:
|
|
76
|
+
env_name = 'RUCIO_POLICY_PACKAGE_' + vo.upper()
|
|
77
|
+
if env_name in environ:
|
|
78
|
+
POLICY = environ[env_name]
|
|
79
|
+
else:
|
|
80
|
+
POLICY = config.config_get('policy', 'package-' + vo, check_config_table=False)
|
|
81
|
+
check_policy_package_version(POLICY)
|
|
82
|
+
POLICY = POLICY + ".schema"
|
|
83
|
+
except (NoOptionError, NoSectionError):
|
|
84
|
+
# fall back to old system for now
|
|
85
|
+
try:
|
|
86
|
+
POLICY = config.config_get('policy', 'schema', check_config_table=False)
|
|
87
|
+
except (NoOptionError, NoSectionError):
|
|
88
|
+
POLICY = GENERIC_FALLBACK
|
|
89
|
+
POLICY = 'rucio.common.schema.' + POLICY.lower()
|
|
90
|
+
else:
|
|
91
|
+
POLICY = 'rucio.common.schema.' + GENERIC_FALLBACK.lower()
|
|
92
|
+
|
|
93
|
+
try:
|
|
94
|
+
module = importlib.import_module(POLICY)
|
|
95
|
+
except ModuleNotFoundError:
|
|
96
|
+
raise exception.PolicyPackageNotFound(POLICY)
|
|
97
|
+
except ImportError:
|
|
98
|
+
raise exception.ErrorLoadingPolicyPackage(POLICY)
|
|
99
|
+
|
|
100
|
+
schema_modules[vo] = module
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def validate_schema(name: str, obj: Any, vo: str = 'def') -> None:
|
|
104
|
+
if vo not in schema_modules:
|
|
105
|
+
load_schema_for_vo(vo)
|
|
106
|
+
schema_modules[vo].validate_schema(name, obj)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def get_schema_value(key: str, vo: str = 'def') -> Any:
|
|
110
|
+
if vo not in schema_modules:
|
|
111
|
+
load_schema_for_vo(vo)
|
|
112
|
+
return getattr(schema_modules[vo], key)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def get_scope_name_regexps() -> list[str]:
|
|
116
|
+
""" returns a list of all unique SCOPE_NAME_REGEXPs from all schemas """
|
|
117
|
+
|
|
118
|
+
if len(scope_name_regexps) == 0:
|
|
119
|
+
# load schemas for all VOs here and add unique scope_name_regexps to list
|
|
120
|
+
from rucio.core.vo import list_vos
|
|
121
|
+
vos = list_vos()
|
|
122
|
+
for vo in vos:
|
|
123
|
+
if not vo['vo'] in schema_modules:
|
|
124
|
+
load_schema_for_vo(vo['vo'])
|
|
125
|
+
scope_name_regexp = schema_modules[vo['vo']].SCOPE_NAME_REGEXP
|
|
126
|
+
if scope_name_regexp not in scope_name_regexps:
|
|
127
|
+
scope_name_regexps.append(scope_name_regexp)
|
|
128
|
+
return scope_name_regexps
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def insert_scope_name(urls: tuple[str, ...]) -> tuple[str, str]:
|
|
132
|
+
"""
|
|
133
|
+
given a tuple of URLs for webpy with '%s' as a placeholder for
|
|
134
|
+
SCOPE_NAME_REGEXP, return a finalised tuple of URLs that will work for all
|
|
135
|
+
SCOPE_NAME_REGEXPs in all schemas
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
regexps = get_scope_name_regexps()
|
|
139
|
+
result = []
|
|
140
|
+
for i in range(0, len(urls), 2):
|
|
141
|
+
if "%s" in urls[i]:
|
|
142
|
+
# add a copy for each unique SCOPE_NAME_REGEXP
|
|
143
|
+
for scope_name_regexp in regexps:
|
|
144
|
+
result.append(urls[i] % scope_name_regexp)
|
|
145
|
+
result.append(urls[i + 1])
|
|
146
|
+
else:
|
|
147
|
+
# pass through unmodified
|
|
148
|
+
result.append(urls[i])
|
|
149
|
+
result.append(urls[i + 1])
|
|
150
|
+
return tuple(result)
|