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