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.
Files changed (88) hide show
  1. rucio/__init__.py +17 -0
  2. rucio/alembicrevision.py +15 -0
  3. rucio/client/__init__.py +15 -0
  4. rucio/client/accountclient.py +433 -0
  5. rucio/client/accountlimitclient.py +183 -0
  6. rucio/client/baseclient.py +974 -0
  7. rucio/client/client.py +76 -0
  8. rucio/client/configclient.py +126 -0
  9. rucio/client/credentialclient.py +59 -0
  10. rucio/client/didclient.py +866 -0
  11. rucio/client/diracclient.py +56 -0
  12. rucio/client/downloadclient.py +1785 -0
  13. rucio/client/exportclient.py +44 -0
  14. rucio/client/fileclient.py +50 -0
  15. rucio/client/importclient.py +42 -0
  16. rucio/client/lifetimeclient.py +90 -0
  17. rucio/client/lockclient.py +109 -0
  18. rucio/client/metaconventionsclient.py +140 -0
  19. rucio/client/pingclient.py +44 -0
  20. rucio/client/replicaclient.py +454 -0
  21. rucio/client/requestclient.py +125 -0
  22. rucio/client/rseclient.py +746 -0
  23. rucio/client/ruleclient.py +294 -0
  24. rucio/client/scopeclient.py +90 -0
  25. rucio/client/subscriptionclient.py +173 -0
  26. rucio/client/touchclient.py +82 -0
  27. rucio/client/uploadclient.py +955 -0
  28. rucio/common/__init__.py +13 -0
  29. rucio/common/cache.py +74 -0
  30. rucio/common/config.py +801 -0
  31. rucio/common/constants.py +159 -0
  32. rucio/common/constraints.py +17 -0
  33. rucio/common/didtype.py +189 -0
  34. rucio/common/exception.py +1151 -0
  35. rucio/common/extra.py +36 -0
  36. rucio/common/logging.py +420 -0
  37. rucio/common/pcache.py +1408 -0
  38. rucio/common/plugins.py +153 -0
  39. rucio/common/policy.py +84 -0
  40. rucio/common/schema/__init__.py +150 -0
  41. rucio/common/schema/atlas.py +413 -0
  42. rucio/common/schema/belleii.py +408 -0
  43. rucio/common/schema/domatpc.py +401 -0
  44. rucio/common/schema/escape.py +426 -0
  45. rucio/common/schema/generic.py +433 -0
  46. rucio/common/schema/generic_multi_vo.py +412 -0
  47. rucio/common/schema/icecube.py +406 -0
  48. rucio/common/stomp_utils.py +159 -0
  49. rucio/common/stopwatch.py +55 -0
  50. rucio/common/test_rucio_server.py +148 -0
  51. rucio/common/types.py +403 -0
  52. rucio/common/utils.py +2238 -0
  53. rucio/rse/__init__.py +96 -0
  54. rucio/rse/protocols/__init__.py +13 -0
  55. rucio/rse/protocols/bittorrent.py +184 -0
  56. rucio/rse/protocols/cache.py +122 -0
  57. rucio/rse/protocols/dummy.py +111 -0
  58. rucio/rse/protocols/gfal.py +703 -0
  59. rucio/rse/protocols/globus.py +243 -0
  60. rucio/rse/protocols/gsiftp.py +92 -0
  61. rucio/rse/protocols/http_cache.py +82 -0
  62. rucio/rse/protocols/mock.py +123 -0
  63. rucio/rse/protocols/ngarc.py +209 -0
  64. rucio/rse/protocols/posix.py +250 -0
  65. rucio/rse/protocols/protocol.py +594 -0
  66. rucio/rse/protocols/rclone.py +364 -0
  67. rucio/rse/protocols/rfio.py +136 -0
  68. rucio/rse/protocols/srm.py +338 -0
  69. rucio/rse/protocols/ssh.py +413 -0
  70. rucio/rse/protocols/storm.py +206 -0
  71. rucio/rse/protocols/webdav.py +550 -0
  72. rucio/rse/protocols/xrootd.py +301 -0
  73. rucio/rse/rsemanager.py +764 -0
  74. rucio/vcsversion.py +11 -0
  75. rucio/version.py +38 -0
  76. rucio_clients-35.8.2.data/data/etc/rse-accounts.cfg.template +25 -0
  77. rucio_clients-35.8.2.data/data/etc/rucio.cfg.atlas.client.template +42 -0
  78. rucio_clients-35.8.2.data/data/etc/rucio.cfg.template +257 -0
  79. rucio_clients-35.8.2.data/data/requirements.client.txt +15 -0
  80. rucio_clients-35.8.2.data/data/rucio_client/merge_rucio_configs.py +144 -0
  81. rucio_clients-35.8.2.data/scripts/rucio +2542 -0
  82. rucio_clients-35.8.2.data/scripts/rucio-admin +2447 -0
  83. rucio_clients-35.8.2.dist-info/METADATA +50 -0
  84. rucio_clients-35.8.2.dist-info/RECORD +88 -0
  85. rucio_clients-35.8.2.dist-info/WHEEL +5 -0
  86. rucio_clients-35.8.2.dist-info/licenses/AUTHORS.rst +97 -0
  87. rucio_clients-35.8.2.dist-info/licenses/LICENSE +201 -0
  88. rucio_clients-35.8.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,148 @@
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 unittest
16
+ from os import remove
17
+ from os.path import basename
18
+
19
+ from rucio.common.utils import execute
20
+ from rucio.common.utils import generate_uuid as uuid
21
+
22
+
23
+ def file_generator(size=2048, namelen=10):
24
+ """ Create a bogus file and returns it's name.
25
+ :param size: size in bytes
26
+ :returns: The name of the generated file.
27
+ """
28
+ fn = '/tmp/rucio_testfile_' + uuid()
29
+ execute('dd if=/dev/urandom of={0} count={1} bs=1'.format(fn, size))
30
+ return fn
31
+
32
+
33
+ def get_scope_and_rses():
34
+ """
35
+ Check if xrd containers rses for xrootd are available in the testing environment.
36
+
37
+ :return: A tuple (scope, rses) for the rucio client where scope is mock/test and rses is a list or (None, [None]) if no suitable rse exists.
38
+ """
39
+ cmd = "rucio list-rses --rses 'test_container_xrd=True'"
40
+ print(cmd)
41
+ exitcode, out, err = execute(cmd)
42
+ print(out, err)
43
+ rses = out.split()
44
+ if len(rses) == 0:
45
+ return None, [None]
46
+ return 'test', rses
47
+
48
+
49
+ def delete_rules(did):
50
+ # get the rules for the file
51
+ print('Deleting rules')
52
+ cmd = "rucio list-rules {0} | grep {0} | cut -f1 -d\\ ".format(did)
53
+ print(cmd)
54
+ exitcode, out, err = execute(cmd)
55
+ print(out, err)
56
+ rules = out.split()
57
+ # delete the rules for the file
58
+ for rule in rules:
59
+ cmd = "rucio delete-rule {0}".format(rule)
60
+ print(cmd)
61
+ exitcode, out, err = execute(cmd)
62
+
63
+
64
+ class TestRucioServer(unittest.TestCase):
65
+
66
+ def setUp(self):
67
+ self.marker = '$ > '
68
+ self.scope, self.rses = get_scope_and_rses()
69
+ self.rse = self.rses[0]
70
+ self.generated_dids = []
71
+
72
+ def tearDown(self):
73
+ for did in self.generated_dids:
74
+ delete_rules(did)
75
+ self.generated_dids = []
76
+
77
+ def test_ping(self):
78
+ """CLIENT (USER): rucio ping"""
79
+ cmd = 'rucio ping'
80
+ print(self.marker + cmd)
81
+ exitcode, out, err = execute(cmd)
82
+ print(out, err)
83
+ self.assertEqual(exitcode, 0)
84
+
85
+ def test_whoami(self):
86
+ """CLIENT (USER): rucio whoami"""
87
+ cmd = 'rucio whoami'
88
+ print(self.marker + cmd)
89
+ exitcode, out, err = execute(cmd)
90
+ print(out, err)
91
+ self.assertEqual(exitcode, 0)
92
+
93
+ def test_upload_download(self):
94
+ """CLIENT(USER): rucio upload files to dataset/download dataset"""
95
+ if self.rse is None:
96
+ return
97
+
98
+ tmp_file1 = file_generator()
99
+ tmp_file2 = file_generator()
100
+ tmp_file3 = file_generator()
101
+ tmp_dsn = 'tests.rucio_client_test_server_' + uuid()
102
+
103
+ # Adding files to a new dataset
104
+ cmd = 'rucio upload --rse {0} --scope {1} {2} {3} {4} {1}:{5}'.format(self.rse, self.scope, tmp_file1, tmp_file2, tmp_file3, tmp_dsn)
105
+ print(self.marker + cmd)
106
+ exitcode, out, err = execute(cmd)
107
+ print(out)
108
+ print(err)
109
+ remove(tmp_file1)
110
+ remove(tmp_file2)
111
+ remove(tmp_file3)
112
+ self.assertEqual(exitcode, 0)
113
+
114
+ # List the files
115
+ cmd = 'rucio list-files {0}:{1}'.format(self.scope, tmp_dsn)
116
+ print(self.marker + cmd)
117
+ exitcode, out, err = execute(cmd)
118
+ print(out)
119
+ print(err)
120
+ self.assertEqual(exitcode, 0)
121
+
122
+ # List the replicas
123
+ cmd = 'rucio list-file-replicas {0}:{1}'.format(self.scope, tmp_dsn)
124
+ print(self.marker + cmd)
125
+ exitcode, out, err = execute(cmd)
126
+ print(out)
127
+ print(err)
128
+ self.assertEqual(exitcode, 0)
129
+
130
+ # Downloading dataset
131
+ cmd = 'rucio download --dir /tmp/ {0}:{1}'.format(self.scope, tmp_dsn)
132
+ print(self.marker + cmd)
133
+ exitcode, out, err = execute(cmd)
134
+ print(out)
135
+ print(err)
136
+ # The files should be there
137
+ cmd = 'ls /tmp/{0}/rucio_testfile_*'.format(tmp_dsn)
138
+ print(self.marker + cmd)
139
+ exitcode, out, err = execute(cmd)
140
+ print(err, out)
141
+ self.assertEqual(exitcode, 0)
142
+
143
+ # cleaning
144
+ remove('/tmp/{0}/'.format(tmp_dsn) + basename(tmp_file1))
145
+ remove('/tmp/{0}/'.format(tmp_dsn) + basename(tmp_file2))
146
+ remove('/tmp/{0}/'.format(tmp_dsn) + basename(tmp_file3))
147
+ added_dids = ['{0}:{1}'.format(self.scope, did) for did in (basename(tmp_file1), basename(tmp_file2), basename(tmp_file3), tmp_dsn)]
148
+ self.generated_dids += added_dids
rucio/common/types.py ADDED
@@ -0,0 +1,403 @@
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 sys
16
+ from collections.abc import Callable
17
+ from datetime import datetime
18
+ from os import PathLike
19
+
20
+ if sys.version_info < (3, 11):
21
+ from typing_extensions import TYPE_CHECKING, Any, Literal, NotRequired, Optional, TypedDict, Union # noqa: UP035
22
+ PathTypeAlias = Union[PathLike, str]
23
+ else:
24
+ from typing import TYPE_CHECKING, Any, Literal, NotRequired, Optional, TypedDict, Union
25
+ PathTypeAlias = PathLike
26
+
27
+
28
+ if TYPE_CHECKING:
29
+ from rucio.common.constants import SUPPORTED_PROTOCOLS_LITERAL
30
+ from rucio.db.sqla.constants import AccountType, IdentityType, RequestState, RequestType
31
+
32
+
33
+ class InternalType:
34
+ '''
35
+ Base for Internal representations of string types
36
+ '''
37
+ def __init__(self, value: Optional[str], vo: str = 'def', fromExternal: bool = True):
38
+ if value is None:
39
+ self.external = None
40
+ self.internal = None
41
+ self.vo = vo
42
+ elif not isinstance(value, str):
43
+ raise TypeError('Expected value to be string type, got %s' % type(value))
44
+ elif fromExternal:
45
+ self.external = value
46
+ self.vo = vo
47
+ self.internal = self._calc_internal()
48
+ else:
49
+ self.internal = value
50
+ vo, external = self._calc_external()
51
+ self.external = external
52
+ self.vo = vo
53
+
54
+ def __repr__(self):
55
+ return self.internal
56
+
57
+ def __str__(self):
58
+ return self.external
59
+
60
+ def __eq__(self, other):
61
+ if isinstance(other, self.__class__):
62
+ return self.internal == other.internal
63
+ return NotImplemented
64
+
65
+ def __ne__(self, other):
66
+ val = self == other
67
+ if val is NotImplemented:
68
+ return NotImplemented
69
+ return not val
70
+
71
+ def __le__(self, other):
72
+ val = self.external <= other.external
73
+ if val is NotImplemented:
74
+ return NotImplemented
75
+ return val
76
+
77
+ def __lt__(self, other):
78
+ val = self.external < other.external
79
+ if val is NotImplemented:
80
+ return NotImplemented
81
+ return val
82
+
83
+ def __hash__(self):
84
+ return hash(self.internal)
85
+
86
+ def _calc_external(self) -> tuple[str, str]:
87
+ ''' Utility to convert between internal and external representations'''
88
+ if isinstance(self.internal, str):
89
+ split = self.internal.split('@', 1)
90
+ if len(split) == 1: # if cannot convert, vo is '' and this is single vo
91
+ vo = 'def'
92
+ external = split[0]
93
+ else:
94
+ vo = split[1]
95
+ external = split[0]
96
+ return vo, external
97
+ return '', ''
98
+
99
+ def _calc_internal(self) -> str:
100
+ ''' Utility to convert between internal and external representations'''
101
+ if self.vo == 'def' and self.external is not None:
102
+ return self.external
103
+ internal = '{}@{}'.format(self.external, self.vo)
104
+ return internal
105
+
106
+
107
+ class InternalAccount(InternalType):
108
+ '''
109
+ Internal representation of an account
110
+ '''
111
+ def __init__(self, account: Optional[str], vo: str = 'def', fromExternal: bool = True):
112
+ super(InternalAccount, self).__init__(value=account, vo=vo, fromExternal=fromExternal)
113
+
114
+
115
+ class InternalScope(InternalType):
116
+ '''
117
+ Internal representation of a scope
118
+ '''
119
+ def __init__(self, scope: Optional[str], vo: str = 'def', fromExternal: bool = True):
120
+ super(InternalScope, self).__init__(value=scope, vo=vo, fromExternal=fromExternal)
121
+
122
+
123
+ LoggerFunction = Callable[..., Any]
124
+
125
+
126
+ class RSEDomainLANDict(TypedDict):
127
+ read: Optional[int]
128
+ write: Optional[int]
129
+ delete: Optional[int]
130
+
131
+
132
+ class RSEDomainWANDict(TypedDict):
133
+ read: Optional[int]
134
+ write: Optional[int]
135
+ delete: Optional[int]
136
+ third_party_copy_read: Optional[int]
137
+ third_party_copy_write: Optional[int]
138
+
139
+
140
+ class RSEDomainsDict(TypedDict):
141
+ lan: RSEDomainLANDict
142
+ wan: RSEDomainWANDict
143
+
144
+
145
+ class RSEProtocolDict(TypedDict):
146
+ auth_token: Optional[str] # FIXME: typing.NotRequired
147
+ hostname: str
148
+ scheme: str
149
+ port: int
150
+ prefix: str
151
+ impl: str
152
+ domains: RSEDomainsDict
153
+ extended_attributes: Optional[Union[str, dict[str, Any]]]
154
+
155
+
156
+ class RSESettingsDict(TypedDict):
157
+ availability_delete: bool
158
+ availability_read: bool
159
+ availability_write: bool
160
+ credentials: Optional[dict[str, Any]]
161
+ lfn2pfn_algorithm: str
162
+ qos_class: Optional[str]
163
+ staging_area: bool
164
+ rse_type: str
165
+ sign_url: Optional[str]
166
+ read_protocol: int
167
+ write_protocol: int
168
+ delete_protocol: int
169
+ third_party_copy_read_protocol: int
170
+ third_party_copy_write_protocol: int
171
+ id: str
172
+ rse: str
173
+ volatile: bool
174
+ verify_checksum: bool
175
+ deterministic: bool
176
+ domain: list[str]
177
+ protocols: list[RSEProtocolDict]
178
+
179
+
180
+ class RSEAccountCounterDict(TypedDict):
181
+ account: InternalAccount
182
+ rse_id: str
183
+
184
+
185
+ class RuleDict(TypedDict):
186
+ account: InternalAccount
187
+ copies: int
188
+ rse_expression: str
189
+ grouping: Literal['ALL', 'DATASET', 'NONE']
190
+ weight: Optional[str]
191
+ lifetime: Optional[int]
192
+ locked: bool
193
+ subscription_id: Optional[str]
194
+ source_replica_expression: Optional[str]
195
+ activity: str
196
+ notify: Optional[Literal['Y', 'N', 'C', 'P']]
197
+ purge_replicas: bool
198
+
199
+
200
+ class DIDDict(TypedDict):
201
+ name: str
202
+ scope: InternalScope
203
+
204
+
205
+ class DIDStringDict(TypedDict):
206
+ name: str
207
+ scope: str
208
+
209
+
210
+ class DatasetDict(DIDStringDict):
211
+ rse: str
212
+
213
+
214
+ class AttachDict(DatasetDict):
215
+ did: DIDStringDict
216
+
217
+
218
+ class HopDict(TypedDict):
219
+ source_rse_id: str
220
+ source_scheme: "SUPPORTED_PROTOCOLS_LITERAL"
221
+ source_scheme_priority: int
222
+ dest_rse_id: str
223
+ dest_scheme: "SUPPORTED_PROTOCOLS_LITERAL"
224
+ dest_scheme_priority: int
225
+
226
+
227
+ class TokenDict(TypedDict):
228
+ token: str
229
+ expires_at: datetime
230
+
231
+
232
+ class TokenValidationDict(TypedDict):
233
+ account: Optional[InternalAccount]
234
+ identity: Optional[str]
235
+ lifetime: datetime
236
+ audience: Optional[str]
237
+ authz_scope: Optional[str]
238
+
239
+
240
+ class IPDict(TypedDict):
241
+ ip: str
242
+ fqdn: str
243
+ site: str
244
+ latitude: Optional[float]
245
+ longitude: Optional[float]
246
+
247
+
248
+ class AccountDict(TypedDict):
249
+ account: InternalAccount
250
+ type: "AccountType"
251
+ email: str
252
+
253
+
254
+ class AccountAttributesDict(TypedDict):
255
+ key: str
256
+ value: Union[bool, str]
257
+
258
+
259
+ class IdentityDict(TypedDict):
260
+ type: "IdentityType"
261
+ identity: str
262
+ email: str
263
+
264
+
265
+ class UsageDict(TypedDict):
266
+ bytes: int
267
+ files: int
268
+ updated_at: Optional[datetime]
269
+
270
+
271
+ class AccountUsageModelDict(TypedDict):
272
+ account: InternalAccount
273
+ rse_id: str
274
+ files: int
275
+ bytes: int
276
+
277
+
278
+ class TraceBaseDict(TypedDict):
279
+ hostname: str
280
+ account: str
281
+ eventType: str
282
+ eventVersion: str
283
+ vo: Optional[str]
284
+ uuid: NotRequired[str]
285
+ scope: NotRequired[str]
286
+ datasetScope: NotRequired[str]
287
+ dataset: NotRequired[str]
288
+ remoteSite: NotRequired[str]
289
+ filesize: NotRequired[int]
290
+ stateReason: NotRequired[str]
291
+ protocol: NotRequired[str]
292
+ clientState: NotRequired[str]
293
+ transferStart: NotRequired[float]
294
+ transferEnd: NotRequired[float]
295
+
296
+
297
+ class TraceDict(TraceBaseDict):
298
+ uuid: str
299
+ scope: str
300
+ datasetScope: str
301
+ dataset: str
302
+ remoteSite: str
303
+ filesize: int
304
+ stateReason: str
305
+ protocol: str
306
+ clientState: str
307
+ transferStart: float
308
+ transferEnd: float
309
+
310
+
311
+ class TraceSchemaDict(TypedDict):
312
+ eventType: str
313
+
314
+
315
+ class FileToUploadDict(TypedDict):
316
+ path: PathTypeAlias
317
+ rse: str
318
+ did_scope: str
319
+ did_name: str
320
+ dataset_scope: NotRequired[str]
321
+ dataset_name: NotRequired[str]
322
+ dataset_meta: NotRequired[str]
323
+ impl: NotRequired[str]
324
+ force_scheme: NotRequired[str]
325
+ pfn: NotRequired[str]
326
+ no_register: NotRequired[bool]
327
+ register_after_upload: NotRequired[bool]
328
+ lifetime: NotRequired[int]
329
+ transfer_timeout: NotRequired[int]
330
+ guid: NotRequired[str]
331
+ recursive: NotRequired[bool]
332
+
333
+
334
+ class FileToUploadWithCollectedInfoDict(FileToUploadDict):
335
+ basename: str
336
+ adler32: str
337
+ md5: str
338
+ meta: dict[str, str]
339
+ state: str
340
+ dataset_did_str: NotRequired[str]
341
+ dirname: str
342
+ upload_result: dict
343
+ bytes: int
344
+ basename: str
345
+
346
+
347
+ class FileToUploadWithCollectedAndDatasetInfoDict(FileToUploadWithCollectedInfoDict):
348
+ dataset_scope: str
349
+ dataset_name: str
350
+
351
+
352
+ class RequestGatewayDict(TypedDict):
353
+ """
354
+ Request dict expected as input to gateway
355
+ """
356
+ scope: str
357
+ name: str
358
+ account: Optional[str]
359
+ dest_rse_id: str
360
+ request_type: "RequestType"
361
+ attributes: "RequestAttributesDict"
362
+
363
+
364
+ class RequestDict(TypedDict):
365
+ """
366
+ Requested dict used in core
367
+ """
368
+ id: str
369
+ request_id: str
370
+ scope: InternalScope
371
+ name: str
372
+ source_rse_id: str
373
+ dest_rse_id: str
374
+ dest_url: str
375
+ state: "RequestState"
376
+ account: NotRequired[InternalAccount]
377
+ rule_id: str
378
+ adler32: str
379
+ bytes: int
380
+ err_msg: str
381
+ sources: list[dict[str, Any]]
382
+ request_type: "RequestType"
383
+ retry_count: Optional[int]
384
+ previous_attempt_id: str
385
+ external_host: str
386
+ external_id: str
387
+ transfertool: str
388
+ attributes: "RequestAttributesDict"
389
+
390
+
391
+ class RequestAttributesDict(TypedDict):
392
+ activity: str
393
+ bytes: int
394
+ md5: str
395
+ adler32: str
396
+ is_intermediate_hop: bool
397
+
398
+
399
+ class FilterDict(TypedDict):
400
+ rule_id: str
401
+ request_id: str
402
+ older_than: datetime
403
+ activities: Union[list[str], str]