rucio-clients 35.7.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-clients might be problematic. Click here for more details.

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.7.0.data/data/etc/rse-accounts.cfg.template +25 -0
  77. rucio_clients-35.7.0.data/data/etc/rucio.cfg.atlas.client.template +42 -0
  78. rucio_clients-35.7.0.data/data/etc/rucio.cfg.template +257 -0
  79. rucio_clients-35.7.0.data/data/requirements.client.txt +15 -0
  80. rucio_clients-35.7.0.data/data/rucio_client/merge_rucio_configs.py +144 -0
  81. rucio_clients-35.7.0.data/scripts/rucio +2542 -0
  82. rucio_clients-35.7.0.data/scripts/rucio-admin +2447 -0
  83. rucio_clients-35.7.0.dist-info/METADATA +50 -0
  84. rucio_clients-35.7.0.dist-info/RECORD +88 -0
  85. rucio_clients-35.7.0.dist-info/WHEEL +5 -0
  86. rucio_clients-35.7.0.dist-info/licenses/AUTHORS.rst +97 -0
  87. rucio_clients-35.7.0.dist-info/licenses/LICENSE +201 -0
  88. rucio_clients-35.7.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,301 @@
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 logging
16
+ import os
17
+
18
+ from rucio.common import exception
19
+ from rucio.common.utils import PREFERRED_CHECKSUM, execute
20
+ from rucio.rse.protocols import protocol
21
+
22
+
23
+ class Default(protocol.RSEProtocol):
24
+ """ Implementing access to RSEs using the XRootD protocol using GSI authentication."""
25
+
26
+ @property
27
+ def _auth_env(self):
28
+ if self.auth_token:
29
+ return f"XrdSecPROTOCOL=ztn BEARER_TOKEN='{self.auth_token}'"
30
+ else:
31
+ return 'XrdSecPROTOCOL=gsi'
32
+
33
+ def __init__(self, protocol_attr, rse_settings, logger=logging.log):
34
+ """ Initializes the object with information about the referred RSE.
35
+
36
+ :param props: Properties derived from the RSE Repository
37
+ """
38
+ super(Default, self).__init__(protocol_attr, rse_settings, logger=logger)
39
+
40
+ self.scheme = self.attributes['scheme']
41
+ self.hostname = self.attributes['hostname']
42
+ self.port = str(self.attributes['port'])
43
+ self.logger = logger
44
+
45
+ def path2pfn(self, path):
46
+ """
47
+ Returns a fully qualified PFN for the file referred by path.
48
+
49
+ :param path: The path to the file.
50
+
51
+ :returns: Fully qualified PFN.
52
+
53
+ """
54
+ self.logger(logging.DEBUG, 'xrootd.path2pfn: path: {}'.format(path))
55
+ if not path.startswith('xroot') and not path.startswith('root'):
56
+ if path.startswith('/'):
57
+ return '%s://%s:%s/%s' % (self.scheme, self.hostname, self.port, path)
58
+ else:
59
+ return '%s://%s:%s//%s' % (self.scheme, self.hostname, self.port, path)
60
+ else:
61
+ return path
62
+
63
+ def exists(self, pfn):
64
+ """ Checks if the requested file is known by the referred RSE.
65
+
66
+ :param pfn: Physical file name
67
+
68
+ :returns: True if the file exists, False if it doesn't
69
+
70
+ :raise ServiceUnavailable
71
+ """
72
+ self.logger(logging.DEBUG, 'xrootd.exists: pfn: {}'.format(pfn))
73
+ try:
74
+ path = self.pfn2path(pfn)
75
+ cmd = f'{self._auth_env} xrdfs {self.hostname}:{self.port} stat {path}'
76
+ self.logger(logging.DEBUG, 'xrootd.exists: cmd: {}'.format(cmd))
77
+ status, out, err = execute(cmd)
78
+ if status != 0:
79
+ return False
80
+ except Exception as e:
81
+ raise exception.ServiceUnavailable(e)
82
+
83
+ return True
84
+
85
+ def stat(self, path):
86
+ """
87
+ Returns the stats of a file.
88
+
89
+ :param path: path to file
90
+
91
+ :raises ServiceUnavailable: if some generic error occurred in the library.
92
+
93
+ :returns: a dict with two keys, filesize and an element of GLOBALLY_SUPPORTED_CHECKSUMS.
94
+ """
95
+ self.logger(logging.DEBUG, f'xrootd.stat: path: {path}')
96
+ ret = {}
97
+ chsum = None
98
+ if path.startswith('root:'):
99
+ path = self.pfn2path(path)
100
+
101
+ try:
102
+ # xrdfs stat for getting filesize
103
+ cmd = f'{self._auth_env} xrdfs {self.hostname}:{self.port} stat {path}'
104
+ self.logger(logging.DEBUG, 'xrootd.stat: filesize cmd: {}'.format(cmd))
105
+ status_stat, out, err = execute(cmd)
106
+ if status_stat == 0:
107
+ for line in out.split('\n'):
108
+ if line and ':' in line:
109
+ k, v = line.split(':', maxsplit=1)
110
+ if k.strip().lower() == 'size':
111
+ ret['filesize'] = v.strip()
112
+ break
113
+
114
+ # xrdfs query checksum for getting checksum
115
+ cmd = f'{self._auth_env} xrdfs {self.hostname}:{self.port} query checksum {path}'
116
+ self.logger(logging.DEBUG, 'xrootd.stat: checksum cmd: {}'.format(cmd))
117
+ status_query, out, err = execute(cmd)
118
+ if status_query == 0:
119
+ chsum, value = out.strip('\n').split()
120
+ ret[chsum] = value
121
+
122
+ except Exception as e:
123
+ raise exception.ServiceUnavailable(e)
124
+
125
+ if 'filesize' not in ret:
126
+ raise exception.ServiceUnavailable('Filesize could not be retrieved.')
127
+ if PREFERRED_CHECKSUM != chsum or not chsum:
128
+ msg = '{} does not match with {}'.format(chsum, PREFERRED_CHECKSUM)
129
+ raise exception.RSEChecksumUnavailable(msg)
130
+
131
+ return ret
132
+
133
+ def pfn2path(self, pfn):
134
+ """
135
+ Returns the path of a file given the pfn, i.e. scheme and hostname are subtracted from the pfn.
136
+
137
+ :param path: pfn of a file
138
+
139
+ :returns: path.
140
+ """
141
+ self.logger(logging.DEBUG, 'xrootd.pfn2path: pfn: {}'.format(pfn))
142
+ if pfn.startswith('//'):
143
+ return pfn
144
+ elif pfn.startswith('/'):
145
+ return '/' + pfn
146
+ else:
147
+ prefix = self.attributes['prefix']
148
+ path = pfn.partition(self.attributes['prefix'])[2]
149
+ path = prefix + path
150
+ return path
151
+
152
+ def lfns2pfns(self, lfns):
153
+ """
154
+ Returns a fully qualified PFN for the file referred by path.
155
+
156
+ :param path: The path to the file.
157
+
158
+ :returns: Fully qualified PFN.
159
+ """
160
+ self.logger(logging.DEBUG, 'xrootd.lfns2pfns: lfns: {}'.format(lfns))
161
+ pfns = {}
162
+ prefix = self.attributes['prefix']
163
+
164
+ if not prefix.startswith('/'):
165
+ prefix = ''.join(['/', prefix])
166
+ if not prefix.endswith('/'):
167
+ prefix = ''.join([prefix, '/'])
168
+
169
+ lfns = [lfns] if isinstance(lfns, dict) else lfns
170
+ for lfn in lfns:
171
+ scope, name = lfn['scope'], lfn['name']
172
+ if 'path' in lfn and lfn['path'] is not None:
173
+ pfns['%s:%s' % (scope, name)] = ''.join([self.attributes['scheme'], '://', self.attributes['hostname'], ':', str(self.attributes['port']), prefix, lfn['path']])
174
+ else:
175
+ pfns['%s:%s' % (scope, name)] = ''.join([self.attributes['scheme'], '://', self.attributes['hostname'], ':', str(self.attributes['port']), prefix, self._get_path(scope=scope, name=name)])
176
+ return pfns
177
+
178
+ def connect(self):
179
+ """ Establishes the actual connection to the referred RSE.
180
+
181
+ :param credentials: Provides information to establish a connection
182
+ to the referred storage system. For S3 connections these are
183
+ access_key, secretkey, host_base, host_bucket, progress_meter
184
+ and skip_existing.
185
+
186
+ :raises RSEAccessDenied
187
+ """
188
+ self.logger(logging.DEBUG, 'xrootd.connect: port: {}, hostname {}'.format(self.port, self.hostname))
189
+ try:
190
+ # The query stats call is not implemented on some xroot doors.
191
+ # Workaround: fail, if server does not reply within 10 seconds for static config query
192
+ cmd = f'{self._auth_env} XRD_REQUESTTIMEOUT=10 xrdfs {self.hostname}:{self.port} query config {self.hostname}:{self.port}'
193
+ self.logger(logging.DEBUG, 'xrootd.connect: cmd: {}'.format(cmd))
194
+ status, out, err = execute(cmd)
195
+ if status != 0:
196
+ raise exception.RSEAccessDenied(err)
197
+ except Exception as e:
198
+ raise exception.RSEAccessDenied(e)
199
+
200
+ def close(self):
201
+ """ Closes the connection to RSE."""
202
+ pass
203
+
204
+ def get(self, pfn, dest, transfer_timeout=None):
205
+ """ Provides access to files stored inside connected the RSE.
206
+
207
+ :param pfn: Physical file name of requested file
208
+ :param dest: Name and path of the files when stored at the client
209
+ :param transfer_timeout: Transfer timeout (in seconds) - dummy
210
+
211
+ :raises DestinationNotAccessible, ServiceUnavailable, SourceNotFound
212
+ """
213
+ self.logger(logging.DEBUG, 'xrootd.get: pfn: {}'.format(pfn))
214
+ try:
215
+ cmd = f'{self._auth_env} xrdcp -f {pfn} {dest}'
216
+ self.logger(logging.DEBUG, 'xrootd.get: cmd: {}'.format(cmd))
217
+ status, out, err = execute(cmd)
218
+ if status == 54:
219
+ raise exception.SourceNotFound()
220
+ elif status != 0:
221
+ raise exception.RucioException(err)
222
+ except Exception as e:
223
+ raise exception.ServiceUnavailable(e)
224
+
225
+ def put(self, filename, target, source_dir, transfer_timeout=None):
226
+ """
227
+ Allows to store files inside the referred RSE.
228
+
229
+ :param source: path to the source file on the client file system
230
+ :param target: path to the destination file on the storage
231
+ :param source_dir: Path where the to be transferred files are stored in the local file system
232
+ :param transfer_timeout: Transfer timeout (in seconds) - dummy
233
+
234
+ :raises DestinationNotAccessible: if the destination storage was not accessible.
235
+ :raises ServiceUnavailable: if some generic error occurred in the library.
236
+ :raises SourceNotFound: if the source file was not found on the referred storage.
237
+ """
238
+ self.logger(logging.DEBUG, 'xrootd.put: filename: {} target: {}'.format(filename, target))
239
+ source_dir = source_dir or '.'
240
+ source_url = '%s/%s' % (source_dir, filename)
241
+ self.logger(logging.DEBUG, 'xrootd put: source url: {}'.format(source_url))
242
+ path = self.path2pfn(target)
243
+ if not os.path.exists(source_url):
244
+ raise exception.SourceNotFound()
245
+ try:
246
+ cmd = f'{self._auth_env} xrdcp -f {source_url} {path}'
247
+ self.logger(logging.DEBUG, 'xrootd.put: cmd: {}'.format(cmd))
248
+ status, out, err = execute(cmd)
249
+ if status != 0:
250
+ raise exception.RucioException(err)
251
+ except Exception as e:
252
+ raise exception.ServiceUnavailable(e)
253
+
254
+ def delete(self, pfn):
255
+ """
256
+ Deletes a file from the connected RSE.
257
+
258
+ :param pfn: Physical file name
259
+
260
+ :raises ServiceUnavailable: if some generic error occurred in the library.
261
+ :raises SourceNotFound: if the source file was not found on the referred storage.
262
+ """
263
+ self.logger(logging.DEBUG, 'xrootd.delete: pfn: {}'.format(pfn))
264
+ if not self.exists(pfn):
265
+ raise exception.SourceNotFound()
266
+ try:
267
+ path = self.pfn2path(pfn)
268
+ cmd = f'{self._auth_env} xrdfs {self.hostname}:{self.port} rm {path}'
269
+ self.logger(logging.DEBUG, 'xrootd.delete: cmd: {}'.format(cmd))
270
+ status, out, err = execute(cmd)
271
+ if status != 0:
272
+ raise exception.RucioException(err)
273
+ except Exception as e:
274
+ raise exception.ServiceUnavailable(e)
275
+
276
+ def rename(self, pfn, new_pfn):
277
+ """ Allows to rename a file stored inside the connected RSE.
278
+
279
+ :param pfn: Current physical file name
280
+ :param new_pfn New physical file name
281
+ :raises DestinationNotAccessible: if the destination storage was not accessible.
282
+ :raises ServiceUnavailable: if some generic error occurred in the library.
283
+ :raises SourceNotFound: if the source file was not found on the referred storage.
284
+ """
285
+ self.logger(logging.DEBUG, 'xrootd.rename: pfn: {}'.format(pfn))
286
+ if not self.exists(pfn):
287
+ raise exception.SourceNotFound()
288
+ try:
289
+ path = self.pfn2path(pfn)
290
+ new_path = self.pfn2path(new_pfn)
291
+ new_dir = new_path[:new_path.rindex('/') + 1]
292
+ cmd = f'{self._auth_env} xrdfs {self.hostname}:{self.port} mkdir -p {new_dir}'
293
+ self.logger(logging.DEBUG, 'xrootd.stat: mkdir cmd: {}'.format(cmd))
294
+ status, out, err = execute(cmd)
295
+ cmd = f'{self._auth_env} xrdfs {self.hostname}:{self.port} mv {path} {new_path}'
296
+ self.logger(logging.DEBUG, 'xrootd.stat: rename cmd: {}'.format(cmd))
297
+ status, out, err = execute(cmd)
298
+ if status != 0:
299
+ raise exception.RucioException(err)
300
+ except Exception as e:
301
+ raise exception.ServiceUnavailable(e)