rucio-clients 32.8.6__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 rucio-clients might be problematic. Click here for more details.
- rucio/__init__.py +18 -0
- rucio/alembicrevision.py +16 -0
- rucio/client/__init__.py +16 -0
- rucio/client/accountclient.py +413 -0
- rucio/client/accountlimitclient.py +155 -0
- rucio/client/baseclient.py +929 -0
- rucio/client/client.py +77 -0
- rucio/client/configclient.py +113 -0
- rucio/client/credentialclient.py +54 -0
- rucio/client/didclient.py +691 -0
- rucio/client/diracclient.py +48 -0
- rucio/client/downloadclient.py +1674 -0
- rucio/client/exportclient.py +44 -0
- rucio/client/fileclient.py +51 -0
- rucio/client/importclient.py +42 -0
- rucio/client/lifetimeclient.py +74 -0
- rucio/client/lockclient.py +99 -0
- rucio/client/metaclient.py +137 -0
- rucio/client/pingclient.py +45 -0
- rucio/client/replicaclient.py +444 -0
- rucio/client/requestclient.py +109 -0
- rucio/client/rseclient.py +664 -0
- rucio/client/ruleclient.py +287 -0
- rucio/client/scopeclient.py +88 -0
- rucio/client/subscriptionclient.py +161 -0
- rucio/client/touchclient.py +78 -0
- rucio/client/uploadclient.py +871 -0
- rucio/common/__init__.py +14 -0
- rucio/common/cache.py +74 -0
- rucio/common/config.py +796 -0
- rucio/common/constants.py +92 -0
- rucio/common/constraints.py +18 -0
- rucio/common/didtype.py +187 -0
- rucio/common/exception.py +1092 -0
- rucio/common/extra.py +37 -0
- rucio/common/logging.py +404 -0
- rucio/common/pcache.py +1387 -0
- rucio/common/policy.py +84 -0
- rucio/common/schema/__init__.py +143 -0
- rucio/common/schema/atlas.py +411 -0
- rucio/common/schema/belleii.py +406 -0
- rucio/common/schema/cms.py +478 -0
- rucio/common/schema/domatpc.py +399 -0
- rucio/common/schema/escape.py +424 -0
- rucio/common/schema/generic.py +431 -0
- rucio/common/schema/generic_multi_vo.py +410 -0
- rucio/common/schema/icecube.py +404 -0
- rucio/common/schema/lsst.py +423 -0
- rucio/common/stomp_utils.py +160 -0
- rucio/common/stopwatch.py +56 -0
- rucio/common/test_rucio_server.py +148 -0
- rucio/common/types.py +158 -0
- rucio/common/utils.py +1946 -0
- rucio/rse/__init__.py +97 -0
- rucio/rse/protocols/__init__.py +14 -0
- rucio/rse/protocols/cache.py +123 -0
- rucio/rse/protocols/dummy.py +112 -0
- rucio/rse/protocols/gfal.py +701 -0
- rucio/rse/protocols/globus.py +243 -0
- rucio/rse/protocols/gsiftp.py +93 -0
- rucio/rse/protocols/http_cache.py +83 -0
- rucio/rse/protocols/mock.py +124 -0
- rucio/rse/protocols/ngarc.py +210 -0
- rucio/rse/protocols/posix.py +251 -0
- rucio/rse/protocols/protocol.py +530 -0
- rucio/rse/protocols/rclone.py +365 -0
- rucio/rse/protocols/rfio.py +137 -0
- rucio/rse/protocols/srm.py +339 -0
- rucio/rse/protocols/ssh.py +414 -0
- rucio/rse/protocols/storm.py +207 -0
- rucio/rse/protocols/webdav.py +547 -0
- rucio/rse/protocols/xrootd.py +295 -0
- rucio/rse/rsemanager.py +752 -0
- rucio/vcsversion.py +11 -0
- rucio/version.py +46 -0
- rucio_clients-32.8.6.data/data/etc/rse-accounts.cfg.template +25 -0
- rucio_clients-32.8.6.data/data/etc/rucio.cfg.atlas.client.template +42 -0
- rucio_clients-32.8.6.data/data/etc/rucio.cfg.template +257 -0
- rucio_clients-32.8.6.data/data/requirements.txt +55 -0
- rucio_clients-32.8.6.data/data/rucio_client/merge_rucio_configs.py +147 -0
- rucio_clients-32.8.6.data/scripts/rucio +2540 -0
- rucio_clients-32.8.6.data/scripts/rucio-admin +2434 -0
- rucio_clients-32.8.6.dist-info/METADATA +50 -0
- rucio_clients-32.8.6.dist-info/RECORD +88 -0
- rucio_clients-32.8.6.dist-info/WHEEL +5 -0
- rucio_clients-32.8.6.dist-info/licenses/AUTHORS.rst +94 -0
- rucio_clients-32.8.6.dist-info/licenses/LICENSE +201 -0
- rucio_clients-32.8.6.dist-info/top_level.txt +1 -0
rucio/common/policy.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright European Organization for Nuclear Research (CERN) since 2012
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
from configparser import NoOptionError, NoSectionError
|
|
19
|
+
from functools import wraps
|
|
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():
|
|
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():
|
|
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():
|
|
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,143 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright European Organization for Nuclear Research (CERN) since 2012
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
import importlib
|
|
17
|
+
from configparser import NoOptionError, NoSectionError
|
|
18
|
+
from os import environ
|
|
19
|
+
|
|
20
|
+
from rucio.common import config, exception
|
|
21
|
+
from rucio.common.utils import check_policy_package_version
|
|
22
|
+
|
|
23
|
+
# dictionary of schema modules for each VO
|
|
24
|
+
schema_modules = {}
|
|
25
|
+
|
|
26
|
+
# list of unique SCOPE_NAME_REGEXP values from all schemas
|
|
27
|
+
scope_name_regexps = []
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
multivo = config.config_get_bool('common', 'multi_vo', check_config_table=False)
|
|
31
|
+
except (NoOptionError, NoSectionError):
|
|
32
|
+
multivo = False
|
|
33
|
+
|
|
34
|
+
# multi-VO version loads schema per-VO on demand
|
|
35
|
+
# we can't get a list of VOs here because the database might not
|
|
36
|
+
# be available as this is imported during the bootstrapping process
|
|
37
|
+
if not multivo:
|
|
38
|
+
GENERIC_FALLBACK = 'generic'
|
|
39
|
+
|
|
40
|
+
if config.config_has_section('policy'):
|
|
41
|
+
try:
|
|
42
|
+
if 'RUCIO_POLICY_PACKAGE' in environ:
|
|
43
|
+
POLICY = environ['RUCIO_POLICY_PACKAGE']
|
|
44
|
+
else:
|
|
45
|
+
POLICY = config.config_get('policy', 'package', check_config_table=False)
|
|
46
|
+
check_policy_package_version(POLICY)
|
|
47
|
+
POLICY = POLICY + ".schema"
|
|
48
|
+
except (NoOptionError, NoSectionError):
|
|
49
|
+
# fall back to old system for now
|
|
50
|
+
try:
|
|
51
|
+
POLICY = config.config_get('policy', 'schema', check_config_table=False)
|
|
52
|
+
except (NoOptionError, NoSectionError):
|
|
53
|
+
POLICY = GENERIC_FALLBACK
|
|
54
|
+
POLICY = 'rucio.common.schema.' + POLICY.lower()
|
|
55
|
+
else:
|
|
56
|
+
POLICY = 'rucio.common.schema.' + GENERIC_FALLBACK.lower()
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
module = importlib.import_module(POLICY)
|
|
60
|
+
except ImportError:
|
|
61
|
+
raise exception.PolicyPackageNotFound('Module ' + POLICY + ' not found')
|
|
62
|
+
|
|
63
|
+
schema_modules["def"] = module
|
|
64
|
+
scope_name_regexps.append(module.SCOPE_NAME_REGEXP)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def load_schema_for_vo(vo):
|
|
68
|
+
GENERIC_FALLBACK = 'generic_multi_vo'
|
|
69
|
+
if config.config_has_section('policy'):
|
|
70
|
+
try:
|
|
71
|
+
env_name = 'RUCIO_POLICY_PACKAGE_' + vo.upper()
|
|
72
|
+
if env_name in environ:
|
|
73
|
+
POLICY = environ[env_name]
|
|
74
|
+
else:
|
|
75
|
+
POLICY = config.config_get('policy', 'package-' + vo, check_config_table=False)
|
|
76
|
+
check_policy_package_version(POLICY)
|
|
77
|
+
POLICY = POLICY + ".schema"
|
|
78
|
+
except (NoOptionError, NoSectionError):
|
|
79
|
+
# fall back to old system for now
|
|
80
|
+
try:
|
|
81
|
+
POLICY = config.config_get('policy', 'schema', check_config_table=False)
|
|
82
|
+
except (NoOptionError, NoSectionError):
|
|
83
|
+
POLICY = GENERIC_FALLBACK
|
|
84
|
+
POLICY = 'rucio.common.schema.' + POLICY.lower()
|
|
85
|
+
else:
|
|
86
|
+
POLICY = 'rucio.common.schema.' + GENERIC_FALLBACK.lower()
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
module = importlib.import_module(POLICY)
|
|
90
|
+
except ImportError:
|
|
91
|
+
raise exception.PolicyPackageNotFound('Module ' + POLICY + ' not found')
|
|
92
|
+
|
|
93
|
+
schema_modules[vo] = module
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def validate_schema(name, obj, vo='def'):
|
|
97
|
+
if vo not in schema_modules:
|
|
98
|
+
load_schema_for_vo(vo)
|
|
99
|
+
schema_modules[vo].validate_schema(name, obj)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def get_schema_value(key, vo='def'):
|
|
103
|
+
if vo not in schema_modules:
|
|
104
|
+
load_schema_for_vo(vo)
|
|
105
|
+
return getattr(schema_modules[vo], key)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def get_scope_name_regexps():
|
|
109
|
+
""" returns a list of all unique SCOPE_NAME_REGEXPs from all schemas """
|
|
110
|
+
|
|
111
|
+
if len(scope_name_regexps) == 0:
|
|
112
|
+
# load schemas for all VOs here and add unique scope_name_regexps to list
|
|
113
|
+
from rucio.core.vo import list_vos
|
|
114
|
+
vos = list_vos()
|
|
115
|
+
for vo in vos:
|
|
116
|
+
if not vo['vo'] in schema_modules:
|
|
117
|
+
load_schema_for_vo(vo['vo'])
|
|
118
|
+
scope_name_regexp = schema_modules[vo['vo']].SCOPE_NAME_REGEXP
|
|
119
|
+
if scope_name_regexp not in scope_name_regexps:
|
|
120
|
+
scope_name_regexps.append(scope_name_regexp)
|
|
121
|
+
return scope_name_regexps
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def insert_scope_name(urls):
|
|
125
|
+
"""
|
|
126
|
+
given a tuple of URLs for webpy with '%s' as a placeholder for
|
|
127
|
+
SCOPE_NAME_REGEXP, return a finalised tuple of URLs that will work for all
|
|
128
|
+
SCOPE_NAME_REGEXPs in all schemas
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
regexps = get_scope_name_regexps()
|
|
132
|
+
result = []
|
|
133
|
+
for i in range(0, len(urls), 2):
|
|
134
|
+
if "%s" in urls[i]:
|
|
135
|
+
# add a copy for each unique SCOPE_NAME_REGEXP
|
|
136
|
+
for scope_name_regexp in regexps:
|
|
137
|
+
result.append(urls[i] % scope_name_regexp)
|
|
138
|
+
result.append(urls[i + 1])
|
|
139
|
+
else:
|
|
140
|
+
# pass through unmodified
|
|
141
|
+
result.append(urls[i])
|
|
142
|
+
result.append(urls[i + 1])
|
|
143
|
+
return tuple(result)
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright European Organization for Nuclear Research (CERN) since 2012
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
from jsonschema import validate, ValidationError
|
|
17
|
+
|
|
18
|
+
from rucio.common.exception import InvalidObject
|
|
19
|
+
|
|
20
|
+
ACCOUNT_LENGTH = 25
|
|
21
|
+
|
|
22
|
+
ACCOUNT = {"description": "Account name",
|
|
23
|
+
"type": "string",
|
|
24
|
+
"pattern": "^[a-z0-9-_]{1,%s}$" % ACCOUNT_LENGTH}
|
|
25
|
+
|
|
26
|
+
ACCOUNTS = {"description": "Array of accounts",
|
|
27
|
+
"type": "array",
|
|
28
|
+
"items": ACCOUNT,
|
|
29
|
+
"minItems": 0,
|
|
30
|
+
"maxItems": 1000}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
ACCOUNT_TYPE = {"description": "Account type",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"enum": ["USER", "GROUP", "SERVICE"]}
|
|
36
|
+
|
|
37
|
+
ACTIVITY = {"description": "Activity name",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": ["Data Brokering", "Data Consolidation", "Data Rebalancing",
|
|
40
|
+
"Debug", "Express", "Functional Test", "Functional Test XrootD",
|
|
41
|
+
"Functional Test WebDAV", "Group Subscriptions",
|
|
42
|
+
"Production Input", "Production Output",
|
|
43
|
+
"Analysis Input", "Analysis Output", "Staging",
|
|
44
|
+
"T0 Export", "T0 Tape", "Upload/Download (Job)",
|
|
45
|
+
"Upload/Download (User)", "User Subscriptions",
|
|
46
|
+
"Globus Online Test", "Data Challenge"]}
|
|
47
|
+
|
|
48
|
+
SCOPE_LENGTH = 25
|
|
49
|
+
|
|
50
|
+
SCOPE = {"description": "Scope name",
|
|
51
|
+
"type": "string",
|
|
52
|
+
"pattern": "^[a-zA-Z_\\-.0-9]{1,%s}$" % SCOPE_LENGTH}
|
|
53
|
+
|
|
54
|
+
R_SCOPE = {"description": "Scope name",
|
|
55
|
+
"type": "string",
|
|
56
|
+
"pattern": "\\w"}
|
|
57
|
+
|
|
58
|
+
NAME_LENGTH = 250
|
|
59
|
+
|
|
60
|
+
NAME = {"description": "Data Identifier name",
|
|
61
|
+
"type": "string",
|
|
62
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9\\.\\-\\_]{1,%s}$" % NAME_LENGTH}
|
|
63
|
+
|
|
64
|
+
R_NAME = {"description": "Data Identifier name",
|
|
65
|
+
"type": "string",
|
|
66
|
+
"pattern": "\\w"}
|
|
67
|
+
|
|
68
|
+
LOCKED = {"description": "Rule locked status",
|
|
69
|
+
"type": ["boolean", "null"]}
|
|
70
|
+
|
|
71
|
+
ASK_APPROVAL = {"description": "Rule approval request",
|
|
72
|
+
"type": ["boolean", "null"]}
|
|
73
|
+
|
|
74
|
+
ASYNCHRONOUS = {"description": "Asynchronous rule creation",
|
|
75
|
+
"type": ["boolean", "null"]}
|
|
76
|
+
|
|
77
|
+
DELAY_INJECTION = {"description": "Time (in seconds) to wait before starting applying the rule. Implies asynchronous rule creation.",
|
|
78
|
+
"type": ["integer", "null"]}
|
|
79
|
+
|
|
80
|
+
PURGE_REPLICAS = {"description": "Rule purge replica status",
|
|
81
|
+
"type": "boolean"}
|
|
82
|
+
|
|
83
|
+
IGNORE_AVAILABILITY = {"description": "Rule ignore availability status",
|
|
84
|
+
"type": "boolean"}
|
|
85
|
+
|
|
86
|
+
RSE = {"description": "RSE name",
|
|
87
|
+
"type": "string",
|
|
88
|
+
"pattern": "^([A-Z0-9]+([_-][A-Z0-9]+)*)$"}
|
|
89
|
+
|
|
90
|
+
RSE_ATTRIBUTE = {"description": "RSE attribute",
|
|
91
|
+
"type": "string",
|
|
92
|
+
"pattern": r'([A-Za-z0-9\._-]+[=<>][A-Za-z0-9_-]+)'}
|
|
93
|
+
|
|
94
|
+
DEFAULT_RSE_ATTRIBUTE = {"description": "Default RSE attribute",
|
|
95
|
+
"type": "string",
|
|
96
|
+
"pattern": r'([A-Z0-9]+([_-][A-Z0-9]+)*)'}
|
|
97
|
+
|
|
98
|
+
REPLICA_STATE = {"description": "Replica state",
|
|
99
|
+
"type": "string",
|
|
100
|
+
"enum": ["AVAILABLE", "UNAVAILABLE", "COPYING", "BEING_DELETED", "BAD", "SOURCE", "A", "U", "C", "B", "D", "S"]}
|
|
101
|
+
|
|
102
|
+
DATE = {"description": "Date",
|
|
103
|
+
"type": "string",
|
|
104
|
+
"pattern": r'((Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun))[,]\s\d{2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s(0\d|1\d|2[0-3])(\:)(0\d|1\d|2\d|3\d|4\d|5\d)(\:)(0\d|1\d|2\d|3\d|4\d|5\d)\s(UTC)'}
|
|
105
|
+
|
|
106
|
+
DID_TYPE = {"description": "DID type",
|
|
107
|
+
"type": "string",
|
|
108
|
+
"enum": ["DATASET", "CONTAINER", "FILE", "F"]}
|
|
109
|
+
|
|
110
|
+
GROUPING = {"description": "Rule grouping",
|
|
111
|
+
"type": ["string", "null"],
|
|
112
|
+
"enum": ["DATASET", "NONE", "ALL", None]}
|
|
113
|
+
|
|
114
|
+
NOTIFY = {"description": "Rule notification setting",
|
|
115
|
+
"type": ["string", "null"],
|
|
116
|
+
"enum": ["Y", "C", "N", "P", None]}
|
|
117
|
+
|
|
118
|
+
COMMENT = {"description": "Rule comment",
|
|
119
|
+
"type": ["string", "null"],
|
|
120
|
+
"maxLength": 250}
|
|
121
|
+
|
|
122
|
+
METADATA = {"description": "Rule wfms metadata",
|
|
123
|
+
"type": ["string", "null"],
|
|
124
|
+
"maxLength": 3999}
|
|
125
|
+
|
|
126
|
+
BYTES = {"description": "Size in bytes",
|
|
127
|
+
"type": "integer"}
|
|
128
|
+
|
|
129
|
+
ADLER32 = {"description": "adler32",
|
|
130
|
+
"type": "string",
|
|
131
|
+
"pattern": "^[a-fA-F\\d]{8}$"}
|
|
132
|
+
|
|
133
|
+
WEIGHT = {"description": "Rule weight",
|
|
134
|
+
"type": ["string", "null"]}
|
|
135
|
+
|
|
136
|
+
MD5 = {"description": "md5",
|
|
137
|
+
"type": "string",
|
|
138
|
+
"pattern": "^[a-fA-F\\d]{32}$"}
|
|
139
|
+
|
|
140
|
+
UUID = {"description": "Universally Unique Identifier (UUID)",
|
|
141
|
+
"type": "string",
|
|
142
|
+
"pattern": '^(\\{){0,1}[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}(\\}){0,1}$'}
|
|
143
|
+
|
|
144
|
+
META = {"description": "Data Identifier(DID) metadata",
|
|
145
|
+
"type": "object",
|
|
146
|
+
"properties": {"guid": UUID},
|
|
147
|
+
"additionalProperties": True}
|
|
148
|
+
|
|
149
|
+
PFN = {"description": "Physical File Name", "type": "string"}
|
|
150
|
+
|
|
151
|
+
COPIES = {"description": "Number of replica copies", "type": "integer"}
|
|
152
|
+
|
|
153
|
+
RSE_EXPRESSION = {"description": "RSE expression", "type": "string"}
|
|
154
|
+
|
|
155
|
+
SOURCE_REPLICA_EXPRESSION = {"description": "RSE expression", "type": ["string", "null"]}
|
|
156
|
+
|
|
157
|
+
LIFETIME = {"description": "Lifetime", "type": "number"}
|
|
158
|
+
|
|
159
|
+
RULE_LIFETIME = {"description": "Rule lifetime", "type": ["number", "null"]}
|
|
160
|
+
|
|
161
|
+
SUBSCRIPTION_ID = {"description": "Rule Subscription id", "type": ["string", "null"]}
|
|
162
|
+
|
|
163
|
+
PRIORITY = {"description": "Priority of the transfers",
|
|
164
|
+
"type": "integer"}
|
|
165
|
+
|
|
166
|
+
SPLIT_CONTAINER = {"description": "Rule split container mode",
|
|
167
|
+
"type": ["boolean", "null"]}
|
|
168
|
+
|
|
169
|
+
RULE = {"description": "Replication rule",
|
|
170
|
+
"type": "object",
|
|
171
|
+
"properties": {"dids": {"type": "array"},
|
|
172
|
+
"account": ACCOUNT,
|
|
173
|
+
"copies": COPIES,
|
|
174
|
+
"rse_expression": RSE_EXPRESSION,
|
|
175
|
+
"grouping": GROUPING,
|
|
176
|
+
"weight": WEIGHT,
|
|
177
|
+
"lifetime": RULE_LIFETIME,
|
|
178
|
+
"locked": LOCKED,
|
|
179
|
+
"subscription_id": SUBSCRIPTION_ID,
|
|
180
|
+
"source_replica_expression": SOURCE_REPLICA_EXPRESSION,
|
|
181
|
+
"activity": ACTIVITY,
|
|
182
|
+
"notify": NOTIFY,
|
|
183
|
+
"purge_replicas": PURGE_REPLICAS,
|
|
184
|
+
"ignore_availability": IGNORE_AVAILABILITY,
|
|
185
|
+
"comment": COMMENT,
|
|
186
|
+
"ask_approval": ASK_APPROVAL,
|
|
187
|
+
"asynchronous": ASYNCHRONOUS,
|
|
188
|
+
"delay_injection": DELAY_INJECTION,
|
|
189
|
+
"priority": PRIORITY,
|
|
190
|
+
'split_container': SPLIT_CONTAINER,
|
|
191
|
+
'meta': METADATA},
|
|
192
|
+
"required": ["dids", "copies", "rse_expression"],
|
|
193
|
+
"additionalProperties": False}
|
|
194
|
+
|
|
195
|
+
RULES = {"description": "Array of replication rules",
|
|
196
|
+
"type": "array",
|
|
197
|
+
"items": RULE,
|
|
198
|
+
"minItems": 1,
|
|
199
|
+
"maxItems": 1000}
|
|
200
|
+
|
|
201
|
+
COLLECTION_TYPE = {"description": "Dataset or container type",
|
|
202
|
+
"type": "string",
|
|
203
|
+
"enum": ["DATASET", "CONTAINER"]}
|
|
204
|
+
|
|
205
|
+
COLLECTION = {"description": "Dataset or container",
|
|
206
|
+
"type": "object",
|
|
207
|
+
"properties": {"scope": SCOPE,
|
|
208
|
+
"name": NAME,
|
|
209
|
+
"type": COLLECTION_TYPE,
|
|
210
|
+
"meta": META,
|
|
211
|
+
"rules": RULES},
|
|
212
|
+
"required": ["scope", "name", "type"],
|
|
213
|
+
"additionalProperties": False}
|
|
214
|
+
|
|
215
|
+
COLLECTIONS = {"description": "Array of datasets or containers",
|
|
216
|
+
"type": "array",
|
|
217
|
+
"items": COLLECTION,
|
|
218
|
+
"minItems": 1,
|
|
219
|
+
"maxItems": 1000}
|
|
220
|
+
|
|
221
|
+
DID = {"description": "Data Identifier(DID)",
|
|
222
|
+
"type": "object",
|
|
223
|
+
"properties": {"scope": SCOPE,
|
|
224
|
+
"name": NAME,
|
|
225
|
+
"type": DID_TYPE,
|
|
226
|
+
"meta": META,
|
|
227
|
+
"rules": RULES,
|
|
228
|
+
"bytes": BYTES,
|
|
229
|
+
"adler32": ADLER32,
|
|
230
|
+
"md5": MD5,
|
|
231
|
+
"state": REPLICA_STATE,
|
|
232
|
+
"pfn": PFN},
|
|
233
|
+
"required": ["scope", "name"],
|
|
234
|
+
"additionalProperties": False}
|
|
235
|
+
|
|
236
|
+
DID_FILTERS = {"description": "Array to filter DIDs by metadata",
|
|
237
|
+
"type": "array",
|
|
238
|
+
"additionalProperties": True}
|
|
239
|
+
|
|
240
|
+
R_DID = {"description": "Data Identifier(DID)",
|
|
241
|
+
"type": "object",
|
|
242
|
+
"properties": {"scope": R_SCOPE,
|
|
243
|
+
"name": R_NAME,
|
|
244
|
+
"type": DID_TYPE,
|
|
245
|
+
"meta": META,
|
|
246
|
+
"rules": RULES,
|
|
247
|
+
"bytes": BYTES,
|
|
248
|
+
"adler32": ADLER32,
|
|
249
|
+
"md5": MD5,
|
|
250
|
+
"state": REPLICA_STATE,
|
|
251
|
+
"pfn": PFN},
|
|
252
|
+
"required": ["scope", "name"],
|
|
253
|
+
"additionalProperties": False}
|
|
254
|
+
|
|
255
|
+
DIDS = {"description": "Array of Data Identifiers(DIDs)",
|
|
256
|
+
"type": "array",
|
|
257
|
+
"items": DID,
|
|
258
|
+
"minItems": 1,
|
|
259
|
+
"maxItems": 1000}
|
|
260
|
+
|
|
261
|
+
R_DIDS = {"description": "Array of Data Identifiers(DIDs)",
|
|
262
|
+
"type": "array",
|
|
263
|
+
"items": R_DID,
|
|
264
|
+
"minItems": 1,
|
|
265
|
+
"maxItems": 1000}
|
|
266
|
+
|
|
267
|
+
ATTACHMENT = {"description": "Attachement",
|
|
268
|
+
"type": "object",
|
|
269
|
+
"properties": {"scope": SCOPE,
|
|
270
|
+
"name": NAME,
|
|
271
|
+
"rse": {"description": "RSE name",
|
|
272
|
+
"type": ["string", "null"],
|
|
273
|
+
"pattern": "^([A-Z0-9]+([_-][A-Z0-9]+)*)$"},
|
|
274
|
+
"dids": DIDS},
|
|
275
|
+
"required": ["dids"],
|
|
276
|
+
"additionalProperties": False}
|
|
277
|
+
|
|
278
|
+
ATTACHMENTS = {"description": "Array of attachments",
|
|
279
|
+
"type": "array",
|
|
280
|
+
"items": ATTACHMENT,
|
|
281
|
+
"minItems": 1,
|
|
282
|
+
"maxItems": 1000}
|
|
283
|
+
|
|
284
|
+
SUBSCRIPTION_FILTER = {"type": "object",
|
|
285
|
+
"properties": {"datatype": {"type": "array"},
|
|
286
|
+
"prod_step": {"type": "array"},
|
|
287
|
+
"stream_name": {"type": "array"},
|
|
288
|
+
"project": {"type": "array"},
|
|
289
|
+
"scope": {"type": "array"},
|
|
290
|
+
"pattern": {"type": "string"},
|
|
291
|
+
"excluded_pattern": {"type": "string"},
|
|
292
|
+
"group": {"type": "string"},
|
|
293
|
+
"provenance": {"type": "string"},
|
|
294
|
+
"account": ACCOUNTS,
|
|
295
|
+
"grouping": {"type": "string"},
|
|
296
|
+
"split_rule": {"type": "boolean"}}}
|
|
297
|
+
|
|
298
|
+
ADD_REPLICA_FILE = {"description": "add replica file",
|
|
299
|
+
"type": "object",
|
|
300
|
+
"properties": {"scope": SCOPE,
|
|
301
|
+
"name": NAME,
|
|
302
|
+
"bytes": BYTES,
|
|
303
|
+
"adler32": ADLER32},
|
|
304
|
+
"required": ["scope", "name", "bytes", "adler32"]}
|
|
305
|
+
|
|
306
|
+
ADD_REPLICA_FILES = {"description": "add replica files",
|
|
307
|
+
"type": "array",
|
|
308
|
+
"items": ADD_REPLICA_FILE,
|
|
309
|
+
"minItems": 1,
|
|
310
|
+
"maxItems": 1000}
|
|
311
|
+
|
|
312
|
+
CACHE_ADD_REPLICAS = {"description": "rucio cache add replicas",
|
|
313
|
+
"type": "object",
|
|
314
|
+
"properties": {"files": ADD_REPLICA_FILES,
|
|
315
|
+
"rse": RSE,
|
|
316
|
+
"lifetime": LIFETIME,
|
|
317
|
+
"operation": {"enum": ["add_replicas"]}},
|
|
318
|
+
"required": ['files', 'rse', 'lifetime', 'operation']}
|
|
319
|
+
|
|
320
|
+
DELETE_REPLICA_FILE = {"description": "delete replica file",
|
|
321
|
+
"type": "object",
|
|
322
|
+
"properties": {"scope": SCOPE,
|
|
323
|
+
"name": NAME},
|
|
324
|
+
"required": ["scope", "name"]}
|
|
325
|
+
|
|
326
|
+
DELETE_REPLICA_FILES = {"description": "delete replica files",
|
|
327
|
+
"type": "array",
|
|
328
|
+
"items": DELETE_REPLICA_FILE,
|
|
329
|
+
"minItems": 1,
|
|
330
|
+
"maxItems": 1000}
|
|
331
|
+
|
|
332
|
+
CACHE_DELETE_REPLICAS = {"description": "rucio cache delete replicas",
|
|
333
|
+
"type": "object",
|
|
334
|
+
"properties": {"files": DELETE_REPLICA_FILES,
|
|
335
|
+
"rse": RSE,
|
|
336
|
+
"operation": {"enum": ["delete_replicas"]}},
|
|
337
|
+
"required": ['files', 'rse', 'operation']}
|
|
338
|
+
|
|
339
|
+
MESSAGE_OPERATION = {"type": "object",
|
|
340
|
+
"properties": {'operation': {"enum": ["add_replicas", "delete_replicas"]}}}
|
|
341
|
+
|
|
342
|
+
ACCOUNT_ATTRIBUTE = {"description": "Account attribute",
|
|
343
|
+
"type": "string",
|
|
344
|
+
"pattern": r'^[a-zA-Z0-9-_\\/\\.]{1,30}$'}
|
|
345
|
+
|
|
346
|
+
SCOPE_NAME_REGEXP = '/(.*)/(.*)'
|
|
347
|
+
|
|
348
|
+
DISTANCE = {"description": "RSE distance",
|
|
349
|
+
"type": "object",
|
|
350
|
+
"properties": {
|
|
351
|
+
"src_rse_id": {"type": "string"},
|
|
352
|
+
"dest_rse_id": {"type": "string"},
|
|
353
|
+
"ranking": {"type": "integer"}
|
|
354
|
+
},
|
|
355
|
+
"required": ["src_rse_id", "dest_rse_id", "ranking"],
|
|
356
|
+
"additionalProperties": True}
|
|
357
|
+
|
|
358
|
+
IMPORT = {"description": "import data into rucio.",
|
|
359
|
+
"type": "object",
|
|
360
|
+
"properties": {
|
|
361
|
+
"rses": {
|
|
362
|
+
"type": "object"
|
|
363
|
+
},
|
|
364
|
+
"distances": {
|
|
365
|
+
"type": "object"
|
|
366
|
+
}
|
|
367
|
+
}}
|
|
368
|
+
|
|
369
|
+
VO = {"description": "VO tag",
|
|
370
|
+
"type": "string",
|
|
371
|
+
"pattern": "^([a-zA-Z_\\-.0-9]{3})?$"}
|
|
372
|
+
|
|
373
|
+
SCHEMAS = {'account': ACCOUNT,
|
|
374
|
+
'account_type': ACCOUNT_TYPE,
|
|
375
|
+
'activity': ACTIVITY,
|
|
376
|
+
'name': NAME,
|
|
377
|
+
'r_name': R_NAME,
|
|
378
|
+
'rse': RSE,
|
|
379
|
+
'rse_attribute': RSE_ATTRIBUTE,
|
|
380
|
+
'scope': SCOPE,
|
|
381
|
+
'r_scope': R_SCOPE,
|
|
382
|
+
'did': DID,
|
|
383
|
+
'did_filters': DID_FILTERS,
|
|
384
|
+
'r_did': R_DID,
|
|
385
|
+
'dids': DIDS,
|
|
386
|
+
'rule': RULE,
|
|
387
|
+
'r_dids': R_DIDS,
|
|
388
|
+
'collection': COLLECTION,
|
|
389
|
+
'collections': COLLECTIONS,
|
|
390
|
+
'attachment': ATTACHMENT,
|
|
391
|
+
'attachments': ATTACHMENTS,
|
|
392
|
+
'subscription_filter': SUBSCRIPTION_FILTER,
|
|
393
|
+
'cache_add_replicas': CACHE_ADD_REPLICAS,
|
|
394
|
+
'cache_delete_replicas': CACHE_DELETE_REPLICAS,
|
|
395
|
+
'account_attribute': ACCOUNT_ATTRIBUTE,
|
|
396
|
+
'import': IMPORT,
|
|
397
|
+
'vo': VO}
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
def validate_schema(name, obj):
|
|
401
|
+
"""
|
|
402
|
+
Validate object against json schema
|
|
403
|
+
|
|
404
|
+
:param name: The json schema name.
|
|
405
|
+
:param obj: The object to validate.
|
|
406
|
+
"""
|
|
407
|
+
try:
|
|
408
|
+
if obj:
|
|
409
|
+
validate(obj, SCHEMAS.get(name, {}))
|
|
410
|
+
except ValidationError as error: # NOQA, pylint: disable=W0612
|
|
411
|
+
raise InvalidObject(f'Problem validating {name}: {error}')
|