rucio 38.3.0__py3-none-any.whl → 38.4.0__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 might be problematic. Click here for more details.
- rucio/cli/did.py +1 -1
- rucio/cli/opendata.py +19 -2
- rucio/client/accountclient.py +20 -19
- rucio/client/accountlimitclient.py +5 -4
- rucio/client/baseclient.py +25 -25
- rucio/client/configclient.py +7 -6
- rucio/client/credentialclient.py +2 -1
- rucio/client/didclient.py +33 -32
- rucio/client/diracclient.py +2 -1
- rucio/client/exportclient.py +2 -1
- rucio/client/importclient.py +2 -1
- rucio/client/lifetimeclient.py +3 -2
- rucio/client/lockclient.py +4 -3
- rucio/client/metaconventionsclient.py +5 -4
- rucio/client/opendataclient.py +8 -7
- rucio/client/pingclient.py +2 -1
- rucio/client/replicaclient.py +27 -26
- rucio/client/requestclient.py +8 -8
- rucio/client/rseclient.py +31 -28
- rucio/client/ruleclient.py +13 -12
- rucio/client/scopeclient.py +4 -3
- rucio/client/subscriptionclient.py +6 -5
- rucio/common/constants.py +18 -0
- rucio/common/exception.py +20 -0
- rucio/common/plugins.py +9 -7
- rucio/core/credential.py +19 -26
- rucio/core/did.py +1 -1
- rucio/core/opendata.py +150 -8
- rucio/core/rule_grouping.py +3 -3
- rucio/gateway/account.py +8 -7
- rucio/gateway/opendata.py +2 -2
- rucio/gateway/request.py +2 -117
- rucio/rse/protocols/webdav.py +5 -2
- rucio/transfertool/fts3.py +0 -19
- rucio/vcsversion.py +3 -3
- rucio/web/rest/flaskapi/v1/accountlimits.py +4 -3
- rucio/web/rest/flaskapi/v1/accounts.py +26 -25
- rucio/web/rest/flaskapi/v1/archives.py +2 -2
- rucio/web/rest/flaskapi/v1/auth.py +15 -14
- rucio/web/rest/flaskapi/v1/common.py +4 -4
- rucio/web/rest/flaskapi/v1/config.py +6 -4
- rucio/web/rest/flaskapi/v1/credentials.py +3 -3
- rucio/web/rest/flaskapi/v1/dids.py +25 -24
- rucio/web/rest/flaskapi/v1/dirac.py +3 -2
- rucio/web/rest/flaskapi/v1/export.py +4 -2
- rucio/web/rest/flaskapi/v1/heartbeats.py +2 -1
- rucio/web/rest/flaskapi/v1/identities.py +5 -4
- rucio/web/rest/flaskapi/v1/import.py +3 -2
- rucio/web/rest/flaskapi/v1/lifetime_exceptions.py +3 -2
- rucio/web/rest/flaskapi/v1/locks.py +4 -3
- rucio/web/rest/flaskapi/v1/meta_conventions.py +4 -3
- rucio/web/rest/flaskapi/v1/metrics.py +2 -1
- rucio/web/rest/flaskapi/v1/nongrid_traces.py +2 -1
- rucio/web/rest/flaskapi/v1/opendata.py +7 -6
- rucio/web/rest/flaskapi/v1/opendata_public.py +6 -5
- rucio/web/rest/flaskapi/v1/ping.py +3 -2
- rucio/web/rest/flaskapi/v1/redirect.py +4 -3
- rucio/web/rest/flaskapi/v1/replicas.py +31 -31
- rucio/web/rest/flaskapi/v1/requests.py +7 -7
- rucio/web/rest/flaskapi/v1/rses.py +23 -16
- rucio/web/rest/flaskapi/v1/rules.py +9 -8
- rucio/web/rest/flaskapi/v1/scopes.py +4 -3
- rucio/web/rest/flaskapi/v1/subscriptions.py +9 -8
- rucio/web/rest/flaskapi/v1/traces.py +2 -1
- rucio/web/rest/flaskapi/v1/vos.py +4 -3
- {rucio-38.3.0.dist-info → rucio-38.4.0.dist-info}/METADATA +1 -1
- {rucio-38.3.0.dist-info → rucio-38.4.0.dist-info}/RECORD +126 -126
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/alembic.ini.template +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/alembic_offline.ini.template +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/globus-config.yml.template +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/ldap.cfg.template +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/mail_templates/rule_approval_request.tmpl +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/mail_templates/rule_approved_admin.tmpl +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/mail_templates/rule_approved_user.tmpl +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/mail_templates/rule_denied_admin.tmpl +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/mail_templates/rule_denied_user.tmpl +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/mail_templates/rule_ok_notification.tmpl +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/rse-accounts.cfg.template +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/rucio.cfg.atlas.client.template +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/rucio.cfg.template +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/etc/rucio_multi_vo.cfg.template +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/requirements.server.txt +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/tools/bootstrap.py +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/tools/merge_rucio_configs.py +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/data/rucio/tools/reset_database.py +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-abacus-account +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-abacus-collection-replica +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-abacus-rse +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-admin +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-atropos +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-auditor +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-automatix +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-bb8 +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-cache-client +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-cache-consumer +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-conveyor-finisher +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-conveyor-poller +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-conveyor-preparer +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-conveyor-receiver +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-conveyor-stager +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-conveyor-submitter +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-conveyor-throttler +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-dark-reaper +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-dumper +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-follower +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-hermes +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-judge-cleaner +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-judge-evaluator +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-judge-injector +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-judge-repairer +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-kronos +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-minos +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-minos-temporary-expiration +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-necromancer +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-oauth-manager +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-reaper +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-replica-recoverer +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-rse-decommissioner +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-storage-consistency-actions +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-transmogrifier +0 -0
- {rucio-38.3.0.data → rucio-38.4.0.data}/scripts/rucio-undertaker +0 -0
- {rucio-38.3.0.dist-info → rucio-38.4.0.dist-info}/WHEEL +0 -0
- {rucio-38.3.0.dist-info → rucio-38.4.0.dist-info}/licenses/AUTHORS.rst +0 -0
- {rucio-38.3.0.dist-info → rucio-38.4.0.dist-info}/licenses/LICENSE +0 -0
- {rucio-38.3.0.dist-info → rucio-38.4.0.dist-info}/top_level.txt +0 -0
|
@@ -18,6 +18,7 @@ from typing import TYPE_CHECKING, Any, Literal, Optional, Union
|
|
|
18
18
|
from requests.status_codes import codes
|
|
19
19
|
|
|
20
20
|
from rucio.client.baseclient import BaseClient, choice
|
|
21
|
+
from rucio.common.constants import HTTPMethod
|
|
21
22
|
from rucio.common.utils import build_url
|
|
22
23
|
|
|
23
24
|
if TYPE_CHECKING:
|
|
@@ -78,7 +79,7 @@ class SubscriptionClient(BaseClient):
|
|
|
78
79
|
raise TypeError('replication_rules should be a list')
|
|
79
80
|
data = dumps({'options': {'filter': filter_, 'replication_rules': replication_rules, 'comments': comments,
|
|
80
81
|
'lifetime': lifetime, 'retroactive': retroactive, 'dry_run': dry_run, 'priority': priority}})
|
|
81
|
-
result = self._send_request(url,
|
|
82
|
+
result = self._send_request(url, method=HTTPMethod.POST, data=data)
|
|
82
83
|
if result.status_code == codes.created: # pylint: disable=no-member
|
|
83
84
|
return result.text
|
|
84
85
|
else:
|
|
@@ -120,7 +121,7 @@ class SubscriptionClient(BaseClient):
|
|
|
120
121
|
else:
|
|
121
122
|
path += '/'
|
|
122
123
|
url = build_url(choice(self.list_hosts), path=path)
|
|
123
|
-
result = self._send_request(url,
|
|
124
|
+
result = self._send_request(url, method=HTTPMethod.GET)
|
|
124
125
|
if result.status_code == codes.ok: # pylint: disable=no-member
|
|
125
126
|
return self._load_json_data(result)
|
|
126
127
|
if result.status_code == codes.not_found:
|
|
@@ -173,7 +174,7 @@ class SubscriptionClient(BaseClient):
|
|
|
173
174
|
raise TypeError('replication_rules should be a list')
|
|
174
175
|
data = dumps({'options': {'filter': filter_, 'replication_rules': replication_rules, 'comments': comments,
|
|
175
176
|
'lifetime': lifetime, 'retroactive': retroactive, 'dry_run': dry_run, 'priority': priority}})
|
|
176
|
-
result = self._send_request(url,
|
|
177
|
+
result = self._send_request(url, method=HTTPMethod.PUT, data=data)
|
|
177
178
|
if result.status_code == codes.created: # pylint: disable=no-member
|
|
178
179
|
return True
|
|
179
180
|
else:
|
|
@@ -203,7 +204,7 @@ class SubscriptionClient(BaseClient):
|
|
|
203
204
|
path = self.SUB_BASEURL + '/' + account + '/' + name # type: ignore
|
|
204
205
|
url = build_url(choice(self.list_hosts), path=path)
|
|
205
206
|
data = dumps({'options': {'state': 'I'}})
|
|
206
|
-
result = self._send_request(url,
|
|
207
|
+
result = self._send_request(url, method=HTTPMethod.PUT, data=data)
|
|
207
208
|
if result.status_code == codes.created: # pylint: disable=no-member
|
|
208
209
|
return True
|
|
209
210
|
else:
|
|
@@ -228,7 +229,7 @@ class SubscriptionClient(BaseClient):
|
|
|
228
229
|
|
|
229
230
|
path = '/'.join([self.SUB_BASEURL, account, name, 'rules'])
|
|
230
231
|
url = build_url(choice(self.list_hosts), path=path)
|
|
231
|
-
result = self._send_request(url,
|
|
232
|
+
result = self._send_request(url, method=HTTPMethod.GET)
|
|
232
233
|
if result.status_code == codes.ok: # pylint: disable=no-member
|
|
233
234
|
return self._load_json_data(result)
|
|
234
235
|
else:
|
rucio/common/constants.py
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
import enum
|
|
16
|
+
import sys
|
|
16
17
|
from collections import namedtuple
|
|
17
18
|
from typing import Literal, get_args
|
|
18
19
|
|
|
@@ -224,3 +225,20 @@ OPENDATA_DID_STATE_LITERAL_LIST = list(get_args(OPENDATA_DID_STATE_LITERAL))
|
|
|
224
225
|
|
|
225
226
|
POLICY_ALGORITHM_TYPES_LITERAL = Literal['non_deterministic_pfn', 'scope', 'lfn2pfn', 'pfn2lfn', 'fts3_tape_metadata_plugins', 'fts3_plugins_init', 'auto_approve']
|
|
226
227
|
POLICY_ALGORITHM_TYPES = list(get_args(POLICY_ALGORITHM_TYPES_LITERAL))
|
|
228
|
+
|
|
229
|
+
# https://github.com/rucio/rucio/issues/7958
|
|
230
|
+
# When Python 3.11 is the minimum supported version, we can use the standard library enum and remove this logic
|
|
231
|
+
if sys.version_info >= (3, 11):
|
|
232
|
+
from http import HTTPMethod
|
|
233
|
+
else:
|
|
234
|
+
@enum.unique
|
|
235
|
+
class HTTPMethod(str, enum.Enum):
|
|
236
|
+
"""HTTP verbs used in Rucio requests."""
|
|
237
|
+
|
|
238
|
+
HEAD = "HEAD"
|
|
239
|
+
OPTIONS = "OPTIONS"
|
|
240
|
+
PATCH = "PATCH"
|
|
241
|
+
GET = "GET"
|
|
242
|
+
POST = "POST"
|
|
243
|
+
PUT = "PUT"
|
|
244
|
+
DELETE = "DELETE"
|
rucio/common/exception.py
CHANGED
|
@@ -1271,3 +1271,23 @@ class InvalidPolicyPackageAlgorithmType(RucioException):
|
|
|
1271
1271
|
super(InvalidPolicyPackageAlgorithmType, self).__init__(*args)
|
|
1272
1272
|
self._message = f"Invalid policy package algorithm type '{param}'."
|
|
1273
1273
|
self.error_code = 120
|
|
1274
|
+
|
|
1275
|
+
|
|
1276
|
+
class InvalidAccountType(RucioException):
|
|
1277
|
+
"""
|
|
1278
|
+
Thrown when an account is created with an invalid type
|
|
1279
|
+
"""
|
|
1280
|
+
def __init__(self, *args):
|
|
1281
|
+
super(InvalidAccountType, self).__init__(*args)
|
|
1282
|
+
self._message = "Cannot create an account with an invalid type."
|
|
1283
|
+
self.error_code = 121
|
|
1284
|
+
|
|
1285
|
+
class OpenDataDuplicateDOI(OpenDataError):
|
|
1286
|
+
"""
|
|
1287
|
+
Throws when a data identifier with the same DOI already exists in the open data catalog.
|
|
1288
|
+
"""
|
|
1289
|
+
|
|
1290
|
+
def __init__(self, doi: str, *args):
|
|
1291
|
+
super(OpenDataDuplicateDOI, self).__init__(*args)
|
|
1292
|
+
self._message = f"Data identifier with the same DOI ({doi}) already exists in the open data catalog."
|
|
1293
|
+
self.error_code = 122
|
rucio/common/plugins.py
CHANGED
|
@@ -77,7 +77,7 @@ class PolicyPackageAlgorithms:
|
|
|
77
77
|
"""
|
|
78
78
|
_ALGORITHMS: dict[POLICY_ALGORITHM_TYPES_LITERAL, dict[str, 'Callable[..., Any]']] = {}
|
|
79
79
|
_loaded_policy_modules = False
|
|
80
|
-
_default_algorithms: dict[str, 'Callable[..., Any]'] = {}
|
|
80
|
+
_default_algorithms: dict[str, Optional['Callable[..., Any]']] = {}
|
|
81
81
|
|
|
82
82
|
def __init__(self) -> None:
|
|
83
83
|
if not self._loaded_policy_modules:
|
|
@@ -105,17 +105,23 @@ class PolicyPackageAlgorithms:
|
|
|
105
105
|
vo = ''
|
|
106
106
|
package = cls._get_policy_package_name(vo)
|
|
107
107
|
except (NoOptionError, NoSectionError):
|
|
108
|
+
cls._default_algorithms[type_for_vo] = default_algorithm
|
|
108
109
|
return default_algorithm
|
|
109
110
|
|
|
110
111
|
module_name = package + "." + algorithm_type
|
|
112
|
+
LOGGER.info('Attempting to find algorithm %s in default location %s...' % (algorithm_type, module_name))
|
|
111
113
|
try:
|
|
112
114
|
module = importlib.import_module(module_name)
|
|
113
115
|
|
|
114
116
|
if hasattr(module, algorithm_type):
|
|
115
117
|
default_algorithm = getattr(module, algorithm_type)
|
|
116
|
-
|
|
118
|
+
except ModuleNotFoundError:
|
|
119
|
+
LOGGER.info('Algorithm %s not found in default location %s' % (algorithm_type, module_name))
|
|
117
120
|
except ImportError:
|
|
118
|
-
LOGGER.info('
|
|
121
|
+
LOGGER.info('Algorithm %s found in default location %s, but could not be loaded' % (algorithm_type, module_name))
|
|
122
|
+
# if the default algorithm is not present, this will store None and we will
|
|
123
|
+
# not attempt to load the same algorithm again
|
|
124
|
+
cls._default_algorithms[type_for_vo] = default_algorithm
|
|
119
125
|
return default_algorithm
|
|
120
126
|
|
|
121
127
|
@classmethod
|
|
@@ -212,10 +218,6 @@ class PolicyPackageAlgorithms:
|
|
|
212
218
|
if hasattr(module, 'get_algorithms'):
|
|
213
219
|
all_algorithms = module.get_algorithms()
|
|
214
220
|
|
|
215
|
-
# for backward compatibility, rename 'surl' to 'non_deterministic_pfn' here
|
|
216
|
-
if 'surl' in all_algorithms:
|
|
217
|
-
all_algorithms['non_deterministic_pfn'] = all_algorithms['surl']
|
|
218
|
-
|
|
219
221
|
# check that the names are correctly prefixed for multi-VO
|
|
220
222
|
if vo:
|
|
221
223
|
for _, algorithms in all_algorithms.items():
|
rucio/core/credential.py
CHANGED
|
@@ -27,7 +27,7 @@ from google.oauth2.service_account import Credentials
|
|
|
27
27
|
|
|
28
28
|
from rucio.common.cache import MemcacheRegion
|
|
29
29
|
from rucio.common.config import config_get, get_rse_credentials
|
|
30
|
-
from rucio.common.constants import RSE_BASE_SUPPORTED_PROTOCOL_OPERATIONS, RSE_BASE_SUPPORTED_PROTOCOL_OPERATIONS_LITERAL, SUPPORTED_SIGN_URL_SERVICES, SUPPORTED_SIGN_URL_SERVICES_LITERAL, RseAttr
|
|
30
|
+
from rucio.common.constants import RSE_BASE_SUPPORTED_PROTOCOL_OPERATIONS, RSE_BASE_SUPPORTED_PROTOCOL_OPERATIONS_LITERAL, SUPPORTED_SIGN_URL_SERVICES, SUPPORTED_SIGN_URL_SERVICES_LITERAL, HTTPMethod, RseAttr
|
|
31
31
|
from rucio.common.exception import UnsupportedOperation
|
|
32
32
|
from rucio.core.monitor import MetricManager
|
|
33
33
|
from rucio.core.rse import get_rse_attribute
|
|
@@ -51,7 +51,7 @@ def get_signed_url(
|
|
|
51
51
|
The signed URL will be valid for 1 hour but can be overridden.
|
|
52
52
|
|
|
53
53
|
:param rse_id: The ID of the RSE that the URL points to.
|
|
54
|
-
:param service: The service to
|
|
54
|
+
:param service: The service to authorize, either 'gcs', 's3' or 'swift'.
|
|
55
55
|
:param operation: The operation to sign, either 'read', 'write', or 'delete'.
|
|
56
56
|
:param url: The URL to sign.
|
|
57
57
|
:param lifetime: Lifetime of the signed URL in seconds.
|
|
@@ -69,6 +69,8 @@ def get_signed_url(
|
|
|
69
69
|
if url is None or url == '':
|
|
70
70
|
raise UnsupportedOperation('URL must not be empty')
|
|
71
71
|
|
|
72
|
+
operations_map = {'read': HTTPMethod.GET.value, 'write': HTTPMethod.PUT.value, 'delete': HTTPMethod.DELETE.value}
|
|
73
|
+
|
|
72
74
|
if lifetime:
|
|
73
75
|
if not isinstance(lifetime, int):
|
|
74
76
|
try:
|
|
@@ -88,25 +90,21 @@ def get_signed_url(
|
|
|
88
90
|
if lifetime is None:
|
|
89
91
|
lifetime = 0
|
|
90
92
|
else:
|
|
91
|
-
# GCS is timezone-sensitive, don't use UTC
|
|
92
|
-
# has to be converted to Unixtime
|
|
93
|
+
# GCS is timezone-sensitive, don't use UTC. Has to be converted to Unix time
|
|
93
94
|
lifetime_datetime = datetime.datetime.now() + datetime.timedelta(seconds=lifetime)
|
|
94
95
|
lifetime = int(time.mktime(lifetime_datetime.timetuple()))
|
|
95
96
|
|
|
96
97
|
# sign the path only
|
|
97
98
|
path = components.path
|
|
98
99
|
|
|
99
|
-
#
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
# assemble message to sign
|
|
103
|
-
to_sign = "%s\n\n\n%s\n%s" % (operations[operation], lifetime, path)
|
|
100
|
+
# assemble a message to sign
|
|
101
|
+
to_sign = "%s\n\n\n%s\n%s" % (operations_map[operation], lifetime, path)
|
|
104
102
|
|
|
105
103
|
# create URL-capable signature
|
|
106
104
|
# first character is always a '=', remove it
|
|
107
105
|
signature = urlencode({'': base64.b64encode(CREDS_GCS.sign_bytes(to_sign))})[1:]
|
|
108
106
|
|
|
109
|
-
# assemble final signed URL
|
|
107
|
+
# assemble the final signed URL
|
|
110
108
|
signed_url = (
|
|
111
109
|
f'https://{host}{path}'
|
|
112
110
|
f'?GoogleAccessId={CREDS_GCS.service_account_email}'
|
|
@@ -127,18 +125,18 @@ def get_signed_url(
|
|
|
127
125
|
# split URL to get hostname, bucket and key
|
|
128
126
|
components = urlparse(url)
|
|
129
127
|
host = components.netloc
|
|
130
|
-
|
|
128
|
+
path_components = components.path.split('/')
|
|
131
129
|
if s3_url_style == "path":
|
|
132
|
-
if len(
|
|
130
|
+
if len(path_components) < 3:
|
|
133
131
|
raise UnsupportedOperation('Not a valid Path-Style S3 URL')
|
|
134
|
-
bucket =
|
|
135
|
-
key = '/'.join(
|
|
132
|
+
bucket = path_components[1]
|
|
133
|
+
key = '/'.join(path_components[2:])
|
|
136
134
|
elif s3_url_style == "host":
|
|
137
|
-
|
|
138
|
-
bucket =
|
|
139
|
-
if len(
|
|
135
|
+
host_components = host.split('.')
|
|
136
|
+
bucket = host_components[0]
|
|
137
|
+
if len(path_components) < 2:
|
|
140
138
|
raise UnsupportedOperation('Not a valid Host-Style S3 URL')
|
|
141
|
-
key = '/'.join(
|
|
139
|
+
key = '/'.join(path_components[1:])
|
|
142
140
|
else:
|
|
143
141
|
raise UnsupportedOperation('Not a valid RSE S3 URL style (allowed values: path|host)')
|
|
144
142
|
|
|
@@ -185,7 +183,7 @@ def get_signed_url(
|
|
|
185
183
|
s3op, Params={'Bucket': bucket, 'Key': key}, ExpiresIn=lifetime)
|
|
186
184
|
|
|
187
185
|
else: # service == 'swift'
|
|
188
|
-
# split URL to get hostname and path
|
|
186
|
+
# split URL to get the hostname and path
|
|
189
187
|
components = urlparse(url)
|
|
190
188
|
host = components.netloc
|
|
191
189
|
|
|
@@ -194,7 +192,7 @@ def get_signed_url(
|
|
|
194
192
|
if colon >= 0:
|
|
195
193
|
host = host[:colon]
|
|
196
194
|
|
|
197
|
-
# use RSE ID to look up key
|
|
195
|
+
# use RSE ID to look up the key
|
|
198
196
|
cred_name = rse_id
|
|
199
197
|
|
|
200
198
|
# look up tempurl signing key
|
|
@@ -205,12 +203,7 @@ def get_signed_url(
|
|
|
205
203
|
REGION.set('swift-%s' % cred_name, cred)
|
|
206
204
|
tempurl_key = cred['tempurl_key']
|
|
207
205
|
|
|
208
|
-
|
|
209
|
-
swiftop = 'GET'
|
|
210
|
-
elif operation == 'write':
|
|
211
|
-
swiftop = 'PUT'
|
|
212
|
-
else:
|
|
213
|
-
swiftop = 'DELETE'
|
|
206
|
+
swiftop = operations_map[operation]
|
|
214
207
|
|
|
215
208
|
expires = int(time.time() + lifetime) # type: ignore (lifetime could be None)
|
|
216
209
|
|
rucio/core/did.py
CHANGED
|
@@ -724,7 +724,7 @@ def __add_collections_to_container(
|
|
|
724
724
|
for row in session.execute(stmt):
|
|
725
725
|
|
|
726
726
|
if row.did_scope is None:
|
|
727
|
-
raise exception.DataIdentifierNotFound("Data identifier '
|
|
727
|
+
raise exception.DataIdentifierNotFound(f"Data identifier '{row.scope}:{row.name}' not found")
|
|
728
728
|
|
|
729
729
|
if row.did_type == DIDType.FILE:
|
|
730
730
|
raise exception.UnsupportedOperation("Adding a file (%s:%s) to a container (%s:%s) is forbidden" % (row.scope, row.name, parent_did.scope, parent_did.name))
|
rucio/core/opendata.py
CHANGED
|
@@ -21,10 +21,14 @@ from sqlalchemy.exc import DataError, IntegrityError
|
|
|
21
21
|
from sqlalchemy.sql.expression import bindparam, select
|
|
22
22
|
|
|
23
23
|
from rucio.common import exception
|
|
24
|
+
from rucio.common.config import config_get, config_get_bool, config_get_int
|
|
25
|
+
from rucio.common.constants import DEFAULT_VO
|
|
24
26
|
from rucio.common.exception import OpenDataError, OpenDataInvalidStateUpdate
|
|
27
|
+
from rucio.common.types import InternalAccount
|
|
25
28
|
from rucio.core.did import list_files
|
|
26
29
|
from rucio.core.monitor import MetricManager
|
|
27
30
|
from rucio.core.replica import list_replicas
|
|
31
|
+
from rucio.core.rule import add_rule
|
|
28
32
|
from rucio.db.sqla import models
|
|
29
33
|
from rucio.db.sqla.constants import DIDType, OpenDataDIDState
|
|
30
34
|
|
|
@@ -300,6 +304,7 @@ def get_opendata_did(
|
|
|
300
304
|
include_files: bool = True,
|
|
301
305
|
include_metadata: bool = False,
|
|
302
306
|
include_doi: bool = True,
|
|
307
|
+
include_rule: bool = True,
|
|
303
308
|
session: "Session",
|
|
304
309
|
) -> dict[str, Any]:
|
|
305
310
|
"""
|
|
@@ -312,10 +317,11 @@ def get_opendata_did(
|
|
|
312
317
|
include_files: If True, include a list of associated files. Defaults to True.
|
|
313
318
|
include_metadata: If True, include extended metadata. Defaults to False.
|
|
314
319
|
include_doi: If True, include DOI (Digital Object Identifier) information. Defaults to True.
|
|
320
|
+
include_rule: If True, include the Opendata replication rule. Defaults to True.
|
|
315
321
|
session: SQLAlchemy session to use for the query.
|
|
316
322
|
|
|
317
323
|
Returns:
|
|
318
|
-
A dictionary containing
|
|
324
|
+
A dictionary containing info about the specified DID which include "scope", "name", "state", "meta" (if requested), etc.
|
|
319
325
|
"""
|
|
320
326
|
|
|
321
327
|
query = select(
|
|
@@ -345,6 +351,8 @@ def get_opendata_did(
|
|
|
345
351
|
result["doi"] = get_opendata_doi(scope=scope, name=name, session=session)
|
|
346
352
|
if include_metadata:
|
|
347
353
|
result["meta"] = get_opendata_meta(scope=scope, name=name, session=session)
|
|
354
|
+
if include_rule:
|
|
355
|
+
result["rule"] = _fetch_opendata_rule(scope=scope, name=name, session=session)
|
|
348
356
|
if include_files:
|
|
349
357
|
opendata_files = get_opendata_did_files(scope=scope, name=name, session=session)
|
|
350
358
|
result["files"] = opendata_files
|
|
@@ -508,7 +516,7 @@ def update_opendata_did(
|
|
|
508
516
|
meta: Optional[Union[dict, str]] = None,
|
|
509
517
|
doi: Optional[str] = None,
|
|
510
518
|
session: "Session",
|
|
511
|
-
) ->
|
|
519
|
+
) -> dict[str, Any]:
|
|
512
520
|
"""
|
|
513
521
|
Update an existing Opendata DID in the catalog.
|
|
514
522
|
|
|
@@ -520,6 +528,9 @@ def update_opendata_did(
|
|
|
520
528
|
doi: DOI to associate with the DID. Must be a valid DOI string (e.g., "10.1234/foo.bar").
|
|
521
529
|
session: SQLAlchemy session to use for the operation.
|
|
522
530
|
|
|
531
|
+
Returns:
|
|
532
|
+
A dictionary containing the scope and name of the DID and details of the updates performed. (e.g., new/old state, new/old DOI, etc.)
|
|
533
|
+
|
|
523
534
|
Raises:
|
|
524
535
|
InputValidationError: If none of 'state', 'meta', or 'doi' are provided, or if the provided data is invalid.
|
|
525
536
|
OpenDataDataIdentifierNotFound: If the Opendata DID does not exist.
|
|
@@ -533,14 +544,18 @@ def update_opendata_did(
|
|
|
533
544
|
if not _check_opendata_did_exists(scope=scope, name=name, session=session):
|
|
534
545
|
raise exception.OpenDataDataIdentifierNotFound(f"OpenData DID '{scope}:{name}' not found.")
|
|
535
546
|
|
|
547
|
+
result = {}
|
|
548
|
+
|
|
536
549
|
if state is not None:
|
|
537
|
-
update_opendata_state(scope=scope, name=name, state=state, session=session)
|
|
550
|
+
result |= update_opendata_state(scope=scope, name=name, state=state, session=session)
|
|
538
551
|
|
|
539
552
|
if meta is not None:
|
|
540
|
-
update_opendata_meta(scope=scope, name=name, meta=meta, session=session)
|
|
553
|
+
result |= update_opendata_meta(scope=scope, name=name, meta=meta, session=session)
|
|
541
554
|
|
|
542
555
|
if doi is not None:
|
|
543
|
-
update_opendata_doi(scope=scope, name=name, doi=doi, session=session)
|
|
556
|
+
result |= update_opendata_doi(scope=scope, name=name, doi=doi, session=session)
|
|
557
|
+
|
|
558
|
+
return result
|
|
544
559
|
|
|
545
560
|
|
|
546
561
|
def update_opendata_meta(
|
|
@@ -549,7 +564,7 @@ def update_opendata_meta(
|
|
|
549
564
|
name: str,
|
|
550
565
|
meta: Union[dict, str],
|
|
551
566
|
session: "Session",
|
|
552
|
-
) ->
|
|
567
|
+
) -> dict[str, Any]:
|
|
553
568
|
"""
|
|
554
569
|
Update the metadata associated with an Opendata DID.
|
|
555
570
|
|
|
@@ -559,6 +574,9 @@ def update_opendata_meta(
|
|
|
559
574
|
meta: Metadata to update for the DID. Must be a valid JSON object or string.
|
|
560
575
|
session: SQLAlchemy session to use for the operation.
|
|
561
576
|
|
|
577
|
+
Returns:
|
|
578
|
+
A dictionary containing the scope, name, and updated metadata of the Opendata DID.
|
|
579
|
+
|
|
562
580
|
Raises:
|
|
563
581
|
InputValidationError: If 'meta' is not a dictionary or a valid JSON string.
|
|
564
582
|
OpenDataDataIdentifierNotFound: If the Opendata DID does not exist.
|
|
@@ -598,6 +616,93 @@ def update_opendata_meta(
|
|
|
598
616
|
except DataError as error:
|
|
599
617
|
raise exception.InputValidationError(f"Invalid data: {error}")
|
|
600
618
|
|
|
619
|
+
return {"scope": scope, "name": name, "meta_new": meta}
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
def _fetch_opendata_rule(scope: "InternalScope",
|
|
623
|
+
name: str,
|
|
624
|
+
session: "Session"
|
|
625
|
+
) -> Optional[str]:
|
|
626
|
+
"""
|
|
627
|
+
Retrieves the replication rule ID associated with an Opendata DID, if it exists.
|
|
628
|
+
The rule is searched for in the rules table by matching the scope, name, account (root), rse_expression,
|
|
629
|
+
and copies (1) based on the configuration used for creating the rule.
|
|
630
|
+
|
|
631
|
+
Parameters:
|
|
632
|
+
scope: The scope under which the Opendata DID is registered.
|
|
633
|
+
name: The name of the Opendata DID.
|
|
634
|
+
session: SQLAlchemy session to use for the query.
|
|
635
|
+
Returns:
|
|
636
|
+
The replication rule ID if it exists, otherwise None.
|
|
637
|
+
"""
|
|
638
|
+
|
|
639
|
+
rule_rse_expression = config_get("opendata", "rule_rse_expression", raise_exception=False, default=None)
|
|
640
|
+
if not rule_rse_expression:
|
|
641
|
+
return None
|
|
642
|
+
|
|
643
|
+
rule_account = config_get("opendata", "rule_account", raise_exception=False, default="root")
|
|
644
|
+
rule_vo = config_get("opendata", "rule_vo", raise_exception=False, default=DEFAULT_VO)
|
|
645
|
+
rule_copies = config_get_int("opendata", "rule_copies", raise_exception=False, default=1)
|
|
646
|
+
|
|
647
|
+
return session.execute(
|
|
648
|
+
select(models.ReplicationRule.id).where(
|
|
649
|
+
and_(
|
|
650
|
+
models.ReplicationRule.scope == scope,
|
|
651
|
+
models.ReplicationRule.name == name,
|
|
652
|
+
models.ReplicationRule.account == InternalAccount(account=rule_account, vo=rule_vo),
|
|
653
|
+
models.ReplicationRule.rse_expression == rule_rse_expression,
|
|
654
|
+
models.ReplicationRule.copies == rule_copies,
|
|
655
|
+
)
|
|
656
|
+
)
|
|
657
|
+
).scalar()
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
def _add_opendata_rule(
|
|
661
|
+
scope: "InternalScope",
|
|
662
|
+
name: str,
|
|
663
|
+
session: "Session"
|
|
664
|
+
) -> str:
|
|
665
|
+
"""
|
|
666
|
+
Create a replication rule for an Opendata DID.
|
|
667
|
+
The rule is created with parameters defined in the configuration file under the [opendata] section.
|
|
668
|
+
|
|
669
|
+
Parameters:
|
|
670
|
+
scope: The scope under which the Opendata DID is registered.
|
|
671
|
+
name: The name of the Opendata DID.
|
|
672
|
+
session: SQLAlchemy session to use for the operation.
|
|
673
|
+
Returns:
|
|
674
|
+
The ID of the created replication rule.
|
|
675
|
+
Raises:
|
|
676
|
+
ValueError: If there is an error during the rule creation process.
|
|
677
|
+
"""
|
|
678
|
+
|
|
679
|
+
rule_asynchronous = config_get_bool("opendata", "rule_asynchronous", raise_exception=False, default=False)
|
|
680
|
+
rule_activity = config_get("opendata", "rule_activity", raise_exception=False, default=None)
|
|
681
|
+
rule_rse_expression = config_get("opendata", "rule_rse_expression", raise_exception=True)
|
|
682
|
+
rule_account = config_get("opendata", "rule_account", raise_exception=False, default="root")
|
|
683
|
+
rule_vo = config_get("opendata", "rule_vo", raise_exception=False, default=DEFAULT_VO)
|
|
684
|
+
rule_copies = config_get_int("opendata", "rule_copies", raise_exception=False, default=1)
|
|
685
|
+
|
|
686
|
+
add_rule_result = add_rule(
|
|
687
|
+
dids=[{"scope": scope, "name": name}],
|
|
688
|
+
# We need an account, perhaps we should pass the issuer argument around like in other methods with account
|
|
689
|
+
account=InternalAccount(account=rule_account, vo=rule_vo),
|
|
690
|
+
copies=rule_copies,
|
|
691
|
+
rse_expression=rule_rse_expression,
|
|
692
|
+
grouping="DATASET",
|
|
693
|
+
weight=None,
|
|
694
|
+
lifetime=None,
|
|
695
|
+
locked=False,
|
|
696
|
+
subscription_id=None,
|
|
697
|
+
activity=rule_activity,
|
|
698
|
+
asynchronous=rule_asynchronous,
|
|
699
|
+
session=session,
|
|
700
|
+
)
|
|
701
|
+
if len(add_rule_result) != 1:
|
|
702
|
+
raise ValueError(f"Error adding Open Data rule: {add_rule_result}")
|
|
703
|
+
|
|
704
|
+
return add_rule_result[0]
|
|
705
|
+
|
|
601
706
|
|
|
602
707
|
def update_opendata_state(
|
|
603
708
|
*,
|
|
@@ -605,9 +710,10 @@ def update_opendata_state(
|
|
|
605
710
|
name: str,
|
|
606
711
|
state: OpenDataDIDState,
|
|
607
712
|
session: "Session",
|
|
608
|
-
) ->
|
|
713
|
+
) -> dict[str, Any]:
|
|
609
714
|
"""
|
|
610
715
|
Update the state of an Opendata DID.
|
|
716
|
+
If the new state is PUBLIC, a replication rule may be created based on configuration.
|
|
611
717
|
|
|
612
718
|
Parameters:
|
|
613
719
|
scope: The scope under which the Opendata DID is registered.
|
|
@@ -615,6 +721,9 @@ def update_opendata_state(
|
|
|
615
721
|
state: The new state to set for the Opendata DID.
|
|
616
722
|
session: SQLAlchemy session to use for the operation.
|
|
617
723
|
|
|
724
|
+
Returns:
|
|
725
|
+
A dictionary with the scope and name of the DID and the rule id if a rule was created and the old and new state.
|
|
726
|
+
|
|
618
727
|
Raises:
|
|
619
728
|
InputValidationError: If the provided state is not a valid OpenDataDIDState.
|
|
620
729
|
OpenDataDataIdentifierNotFound: If the Opendata DID does not exist.
|
|
@@ -676,15 +785,30 @@ def update_opendata_state(
|
|
|
676
785
|
if state_before == OpenDataDIDState.DRAFT:
|
|
677
786
|
raise OpenDataInvalidStateUpdate("Cannot set state to SUSPENDED from DRAFT. First set it to PUBLIC.")
|
|
678
787
|
|
|
788
|
+
output = {"scope": scope, "name": name, "state_old": state_before, "state_new": state}
|
|
789
|
+
|
|
679
790
|
try:
|
|
680
791
|
result = session.execute(update_query)
|
|
681
792
|
|
|
682
793
|
if result.rowcount == 0:
|
|
683
794
|
raise ValueError(f"Error updating Opendata state for DID '{scope}:{name}'.")
|
|
684
795
|
|
|
796
|
+
if state == OpenDataDIDState.PUBLIC:
|
|
797
|
+
rule_enable = config_get_bool("opendata", "rule_enable", raise_exception=False, default=False)
|
|
798
|
+
if rule_enable:
|
|
799
|
+
rule_id = _fetch_opendata_rule(scope=scope, name=name, session=session)
|
|
800
|
+
if rule_id:
|
|
801
|
+
output["rule"] = rule_id
|
|
802
|
+
output["comments"] = "Replication rule already exists"
|
|
803
|
+
else:
|
|
804
|
+
output["rule"] = _add_opendata_rule(scope=scope, name=name, session=session)
|
|
805
|
+
output["comments"] = "Replication rule created"
|
|
806
|
+
|
|
685
807
|
except DataError as error:
|
|
686
808
|
raise exception.InputValidationError(f"Invalid data: {error}")
|
|
687
809
|
|
|
810
|
+
return output
|
|
811
|
+
|
|
688
812
|
|
|
689
813
|
def update_opendata_doi(
|
|
690
814
|
*,
|
|
@@ -692,7 +816,7 @@ def update_opendata_doi(
|
|
|
692
816
|
name: str,
|
|
693
817
|
doi: str,
|
|
694
818
|
session: "Session",
|
|
695
|
-
) ->
|
|
819
|
+
) -> dict[str, Any]:
|
|
696
820
|
"""
|
|
697
821
|
Update the DOI (Digital Object Identifier) associated with an Opendata DID.
|
|
698
822
|
|
|
@@ -702,6 +826,9 @@ def update_opendata_doi(
|
|
|
702
826
|
doi: The new DOI to associate with the Opendata DID. Must be a valid DOI string.
|
|
703
827
|
session: SQLAlchemy session to use for the operation.
|
|
704
828
|
|
|
829
|
+
Returns:
|
|
830
|
+
A dictionary containing the scope, name, new DOI, and previous DOI of the Opendata DID.
|
|
831
|
+
|
|
705
832
|
Raises:
|
|
706
833
|
InputValidationError: If the provided DOI is not a valid string or does not match the expected format.
|
|
707
834
|
OpenDataDataIdentifierNotFound: If the Opendata DID does not exist.
|
|
@@ -740,5 +867,20 @@ def update_opendata_doi(
|
|
|
740
867
|
if result.rowcount == 0:
|
|
741
868
|
raise ValueError(f"Error updating Opendata DOI for DID '{scope}:{name}'.")
|
|
742
869
|
|
|
870
|
+
except IntegrityError as error:
|
|
871
|
+
msg = str(error)
|
|
872
|
+
|
|
873
|
+
if (
|
|
874
|
+
search(r'ORA-00001: unique constraint \([^)]+\) violated', msg)
|
|
875
|
+
or search(r'UNIQUE constraint failed: dids_opendata_doi\.doi', msg)
|
|
876
|
+
or search(r'1062.*Duplicate entry.*for key', msg)
|
|
877
|
+
or search(r'duplicate key value violates unique constraint', msg)
|
|
878
|
+
or search(r'columns?.*not unique', msg)
|
|
879
|
+
):
|
|
880
|
+
raise exception.OpenDataDuplicateDOI(doi=doi)
|
|
881
|
+
|
|
882
|
+
raise exception.OpenDataError()
|
|
743
883
|
except DataError as error:
|
|
744
884
|
raise exception.InputValidationError(f"Invalid data: {error}")
|
|
885
|
+
|
|
886
|
+
return {"scope": scope, "name": name, "doi_new": doi, "doi_old": doi_before}
|
rucio/core/rule_grouping.py
CHANGED
|
@@ -690,7 +690,7 @@ def __repair_stuck_locks_with_none_grouping(datasetfiles, locks, replicas, sourc
|
|
|
690
690
|
associated_replica.lock_cnt = session.execute(stmt).scalar_one()
|
|
691
691
|
continue
|
|
692
692
|
# Check if this is a STUCK lock due to source_replica filtering
|
|
693
|
-
if source_rses:
|
|
693
|
+
if source_rses and not lock.repair_cnt:
|
|
694
694
|
associated_replica = [replica for replica in replicas[(file['scope'], file['name'])] if replica.rse_id == lock.rse_id][0]
|
|
695
695
|
# Check if there is an eligible source replica for this lock
|
|
696
696
|
if set(source_replicas.get((file['scope'], file['name']), [])).intersection(source_rses) and (selector_rse_dict.get(lock.rse_id, {}).get('availability_write', True) or rule.ignore_availability):
|
|
@@ -806,7 +806,7 @@ def __repair_stuck_locks_with_all_grouping(datasetfiles, locks, replicas, source
|
|
|
806
806
|
associated_replica.lock_cnt = session.execute(stmt).scalar_one()
|
|
807
807
|
continue
|
|
808
808
|
# Check if this is a STUCK lock due to source_replica filtering
|
|
809
|
-
if source_rses:
|
|
809
|
+
if source_rses and not lock.repair_cnt:
|
|
810
810
|
associated_replica = [replica for replica in replicas[(file['scope'], file['name'])] if replica.rse_id == lock.rse_id][0]
|
|
811
811
|
# Check if there is an eligible source replica for this lock
|
|
812
812
|
if set(source_replicas.get((file['scope'], file['name']), [])).intersection(source_rses) and (selector_rse_dict.get(lock.rse_id, {}).get('availability_write', True) or rule.ignore_availability):
|
|
@@ -891,7 +891,7 @@ def __repair_stuck_locks_with_dataset_grouping(datasetfiles, locks, replicas, so
|
|
|
891
891
|
associated_replica.lock_cnt = session.execute(stmt).scalar_one()
|
|
892
892
|
continue
|
|
893
893
|
# Check if this is a STUCK lock due to source_replica filtering
|
|
894
|
-
if source_rses:
|
|
894
|
+
if source_rses and not lock.repair_cnt:
|
|
895
895
|
associated_replica = [replica for replica in replicas[(file['scope'], file['name'])] if replica.rse_id == lock.rse_id][0]
|
|
896
896
|
# Check if there is an eligible source replica for this lock
|
|
897
897
|
if set(source_replicas.get((file['scope'], file['name']), [])).intersection(source_rses) and (selector_rse_dict.get(lock.rse_id, {}).get('availability_write', True) or rule.ignore_availability):
|
rucio/gateway/account.py
CHANGED
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
from typing import TYPE_CHECKING, Any, Optional
|
|
16
16
|
|
|
17
|
-
import rucio.common.exception
|
|
18
|
-
import rucio.core.identity
|
|
19
17
|
import rucio.gateway.permission
|
|
20
18
|
from rucio.common.constants import DEFAULT_VO
|
|
19
|
+
from rucio.common.exception import AccessDenied, InvalidAccountType
|
|
21
20
|
from rucio.common.schema import validate_schema
|
|
22
21
|
from rucio.common.types import InternalAccount
|
|
23
22
|
from rucio.common.utils import gateway_update_return_dict
|
|
@@ -55,11 +54,13 @@ def add_account(
|
|
|
55
54
|
validate_schema(name='account', obj=account, vo=vo)
|
|
56
55
|
|
|
57
56
|
kwargs = {'account': account, 'type': type_}
|
|
57
|
+
if type_.upper() not in AccountType._member_names_:
|
|
58
|
+
raise InvalidAccountType(f"{type_} is an invalid account type. Choose from {AccountType._member_names_}")
|
|
58
59
|
|
|
59
60
|
with db_session(DatabaseOperationType.WRITE) as session:
|
|
60
61
|
auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='add_account', kwargs=kwargs, session=session)
|
|
61
62
|
if not auth_result.allowed:
|
|
62
|
-
raise
|
|
63
|
+
raise AccessDenied('Account %s can not add account. %s' % (issuer, auth_result.message))
|
|
63
64
|
|
|
64
65
|
internal_account = InternalAccount(account, vo=vo)
|
|
65
66
|
|
|
@@ -83,7 +84,7 @@ def del_account(
|
|
|
83
84
|
with db_session(DatabaseOperationType.WRITE) as session:
|
|
84
85
|
auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='del_account', kwargs=kwargs, session=session)
|
|
85
86
|
if not auth_result.allowed:
|
|
86
|
-
raise
|
|
87
|
+
raise AccessDenied('Account %s can not delete account. %s' % (issuer, auth_result.message))
|
|
87
88
|
|
|
88
89
|
internal_account = InternalAccount(account, vo=vo)
|
|
89
90
|
|
|
@@ -132,7 +133,7 @@ def update_account(
|
|
|
132
133
|
with db_session(DatabaseOperationType.WRITE) as session:
|
|
133
134
|
auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='update_account', kwargs=kwargs, session=session)
|
|
134
135
|
if not auth_result.allowed:
|
|
135
|
-
raise
|
|
136
|
+
raise AccessDenied('Account %s can not change %s of the account. %s' % (issuer, key, auth_result.message))
|
|
136
137
|
|
|
137
138
|
internal_account = InternalAccount(account, vo=vo)
|
|
138
139
|
|
|
@@ -242,7 +243,7 @@ def add_account_attribute(
|
|
|
242
243
|
with db_session(DatabaseOperationType.WRITE) as session:
|
|
243
244
|
auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='add_attribute', kwargs=kwargs, session=session)
|
|
244
245
|
if not auth_result.allowed:
|
|
245
|
-
raise
|
|
246
|
+
raise AccessDenied('Account %s can not add attributes. %s' % (issuer, auth_result.message))
|
|
246
247
|
|
|
247
248
|
internal_account = InternalAccount(account, vo=vo)
|
|
248
249
|
|
|
@@ -268,7 +269,7 @@ def del_account_attribute(
|
|
|
268
269
|
with db_session(DatabaseOperationType.WRITE) as session:
|
|
269
270
|
auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='del_attribute', kwargs=kwargs, session=session)
|
|
270
271
|
if not auth_result.allowed:
|
|
271
|
-
raise
|
|
272
|
+
raise AccessDenied('Account %s can not delete attribute. %s' % (issuer, auth_result.message))
|
|
272
273
|
|
|
273
274
|
internal_account = InternalAccount(account, vo=vo)
|
|
274
275
|
|