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.

Files changed (88) hide show
  1. rucio/__init__.py +18 -0
  2. rucio/alembicrevision.py +16 -0
  3. rucio/client/__init__.py +16 -0
  4. rucio/client/accountclient.py +413 -0
  5. rucio/client/accountlimitclient.py +155 -0
  6. rucio/client/baseclient.py +929 -0
  7. rucio/client/client.py +77 -0
  8. rucio/client/configclient.py +113 -0
  9. rucio/client/credentialclient.py +54 -0
  10. rucio/client/didclient.py +691 -0
  11. rucio/client/diracclient.py +48 -0
  12. rucio/client/downloadclient.py +1674 -0
  13. rucio/client/exportclient.py +44 -0
  14. rucio/client/fileclient.py +51 -0
  15. rucio/client/importclient.py +42 -0
  16. rucio/client/lifetimeclient.py +74 -0
  17. rucio/client/lockclient.py +99 -0
  18. rucio/client/metaclient.py +137 -0
  19. rucio/client/pingclient.py +45 -0
  20. rucio/client/replicaclient.py +444 -0
  21. rucio/client/requestclient.py +109 -0
  22. rucio/client/rseclient.py +664 -0
  23. rucio/client/ruleclient.py +287 -0
  24. rucio/client/scopeclient.py +88 -0
  25. rucio/client/subscriptionclient.py +161 -0
  26. rucio/client/touchclient.py +78 -0
  27. rucio/client/uploadclient.py +871 -0
  28. rucio/common/__init__.py +14 -0
  29. rucio/common/cache.py +74 -0
  30. rucio/common/config.py +796 -0
  31. rucio/common/constants.py +92 -0
  32. rucio/common/constraints.py +18 -0
  33. rucio/common/didtype.py +187 -0
  34. rucio/common/exception.py +1092 -0
  35. rucio/common/extra.py +37 -0
  36. rucio/common/logging.py +404 -0
  37. rucio/common/pcache.py +1387 -0
  38. rucio/common/policy.py +84 -0
  39. rucio/common/schema/__init__.py +143 -0
  40. rucio/common/schema/atlas.py +411 -0
  41. rucio/common/schema/belleii.py +406 -0
  42. rucio/common/schema/cms.py +478 -0
  43. rucio/common/schema/domatpc.py +399 -0
  44. rucio/common/schema/escape.py +424 -0
  45. rucio/common/schema/generic.py +431 -0
  46. rucio/common/schema/generic_multi_vo.py +410 -0
  47. rucio/common/schema/icecube.py +404 -0
  48. rucio/common/schema/lsst.py +423 -0
  49. rucio/common/stomp_utils.py +160 -0
  50. rucio/common/stopwatch.py +56 -0
  51. rucio/common/test_rucio_server.py +148 -0
  52. rucio/common/types.py +158 -0
  53. rucio/common/utils.py +1946 -0
  54. rucio/rse/__init__.py +97 -0
  55. rucio/rse/protocols/__init__.py +14 -0
  56. rucio/rse/protocols/cache.py +123 -0
  57. rucio/rse/protocols/dummy.py +112 -0
  58. rucio/rse/protocols/gfal.py +701 -0
  59. rucio/rse/protocols/globus.py +243 -0
  60. rucio/rse/protocols/gsiftp.py +93 -0
  61. rucio/rse/protocols/http_cache.py +83 -0
  62. rucio/rse/protocols/mock.py +124 -0
  63. rucio/rse/protocols/ngarc.py +210 -0
  64. rucio/rse/protocols/posix.py +251 -0
  65. rucio/rse/protocols/protocol.py +530 -0
  66. rucio/rse/protocols/rclone.py +365 -0
  67. rucio/rse/protocols/rfio.py +137 -0
  68. rucio/rse/protocols/srm.py +339 -0
  69. rucio/rse/protocols/ssh.py +414 -0
  70. rucio/rse/protocols/storm.py +207 -0
  71. rucio/rse/protocols/webdav.py +547 -0
  72. rucio/rse/protocols/xrootd.py +295 -0
  73. rucio/rse/rsemanager.py +752 -0
  74. rucio/vcsversion.py +11 -0
  75. rucio/version.py +46 -0
  76. rucio_clients-32.8.6.data/data/etc/rse-accounts.cfg.template +25 -0
  77. rucio_clients-32.8.6.data/data/etc/rucio.cfg.atlas.client.template +42 -0
  78. rucio_clients-32.8.6.data/data/etc/rucio.cfg.template +257 -0
  79. rucio_clients-32.8.6.data/data/requirements.txt +55 -0
  80. rucio_clients-32.8.6.data/data/rucio_client/merge_rucio_configs.py +147 -0
  81. rucio_clients-32.8.6.data/scripts/rucio +2540 -0
  82. rucio_clients-32.8.6.data/scripts/rucio-admin +2434 -0
  83. rucio_clients-32.8.6.dist-info/METADATA +50 -0
  84. rucio_clients-32.8.6.dist-info/RECORD +88 -0
  85. rucio_clients-32.8.6.dist-info/WHEEL +5 -0
  86. rucio_clients-32.8.6.dist-info/licenses/AUTHORS.rst +94 -0
  87. rucio_clients-32.8.6.dist-info/licenses/LICENSE +201 -0
  88. rucio_clients-32.8.6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,530 @@
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
+ """
17
+ This module defines the base class for implementing a transfer protocol,
18
+ along with some of the default methods for LFN2PFN translations.
19
+ """
20
+
21
+ import hashlib
22
+ import logging
23
+ from configparser import NoOptionError, NoSectionError
24
+ from urllib.parse import urlparse
25
+
26
+ from rucio.common import config, exception
27
+ from rucio.common.utils import register_policy_package_algorithms
28
+ from rucio.rse import rsemanager
29
+
30
+ if getattr(rsemanager, 'CLIENT_MODE', None):
31
+ from rucio.client.rseclient import RSEClient
32
+
33
+ if getattr(rsemanager, 'SERVER_MODE', None):
34
+ from rucio.common.types import InternalScope
35
+ from rucio.core import replica
36
+ from rucio.core.rse import get_rse_vo
37
+
38
+
39
+ class RSEDeterministicTranslation(object):
40
+ """
41
+ Execute the logic for translating a LFN to a path.
42
+ """
43
+
44
+ _LFN2PFN_ALGORITHMS = {}
45
+ _DEFAULT_LFN2PFN = "hash"
46
+
47
+ def __init__(self, rse=None, rse_attributes=None, protocol_attributes=None):
48
+ """
49
+ Initialize a translator object from the RSE, its attributes, and the protocol-specific
50
+ attributes.
51
+
52
+ :param rse: Name of RSE for this translation.
53
+ :param rse_attributes: A dictionary of RSE-specific attributes for use in the translation.
54
+ :param protocol_attributes: A dictionary of RSE/protocol-specific attributes.
55
+ """
56
+ self.rse = rse
57
+ self.rse_attributes = rse_attributes if rse_attributes else {}
58
+ self.protocol_attributes = protocol_attributes if protocol_attributes else {}
59
+ self.loaded_policy_modules = False
60
+
61
+ @classmethod
62
+ def supports(cls, name):
63
+ """
64
+ Check to see if a specific algorithm is supported.
65
+
66
+ :param name: Name of the deterministic algorithm.
67
+ :returns: True if `name` is an algorithm supported by the translator class, False otherwise.
68
+ """
69
+ return name in cls._LFN2PFN_ALGORITHMS
70
+
71
+ @staticmethod
72
+ def register(lfn2pfn_callable, name=None):
73
+ """
74
+ Provided a callable function, register it as one of the valid LFN2PFN algorithms.
75
+
76
+ The callable will receive five arguments:
77
+ - scope: Scope of the LFN.
78
+ - name: LFN's path name
79
+ - rse: RSE name the translation is being done for.
80
+ - rse_attributes: Attributes of the RSE.
81
+ - protocol_attributes: Attributes of the RSE's protocol
82
+ The return value should be the last part of the PFN - it will be appended to the
83
+ rest of the URL.
84
+
85
+ :param lfn2pfn_callable: Callable function to use for generating paths.
86
+ :param name: Algorithm name used for registration. If None, then `lfn2pfn_callable.__name__` is used.
87
+ """
88
+ if name is None:
89
+ name = lfn2pfn_callable.__name__
90
+ RSEDeterministicTranslation._LFN2PFN_ALGORITHMS[name] = lfn2pfn_callable
91
+
92
+ @staticmethod
93
+ def __hash(scope, name, rse, rse_attrs, protocol_attrs):
94
+ """
95
+ Given a LFN, turn it into a sub-directory structure using a hash function.
96
+
97
+ This takes the MD5 of the LFN and uses the first four characters as a subdirectory
98
+ name.
99
+
100
+ :param scope: Scope of the LFN.
101
+ :param name: File name of the LFN.
102
+ :param rse: RSE for PFN (ignored)
103
+ :param rse_attrs: RSE attributes for PFN (ignored)
104
+ :param protocol_attrs: RSE protocol attributes for PFN (ignored)
105
+ :returns: Path for use in the PFN generation.
106
+ """
107
+ del rse
108
+ del rse_attrs
109
+ del protocol_attrs
110
+ hstr = hashlib.md5(('%s:%s' % (scope, name)).encode('utf-8')).hexdigest()
111
+ if scope.startswith('user') or scope.startswith('group'):
112
+ scope = scope.replace('.', '/')
113
+ return '%s/%s/%s/%s' % (scope, hstr[0:2], hstr[2:4], name)
114
+
115
+ @staticmethod
116
+ def __identity(scope, name, rse, rse_attrs, protocol_attrs):
117
+ """
118
+ Given a LFN, convert it directly to a path using the mapping:
119
+
120
+ scope:path -> scope/path
121
+
122
+ :param scope: Scope of the LFN.
123
+ :param name: File name of the LFN.
124
+ :param rse: RSE for PFN (ignored)
125
+ :param rse_attrs: RSE attributes for PFN (ignored)
126
+ :param protocol_attrs: RSE protocol attributes for PFN (ignored)
127
+ :returns: Path for use in the PFN generation.
128
+ """
129
+ del rse
130
+ del rse_attrs
131
+ del protocol_attrs
132
+ if scope.startswith('user') or scope.startswith('group'):
133
+ scope = scope.replace('.', '/')
134
+ return '%s/%s' % (scope, name)
135
+
136
+ @staticmethod
137
+ def __belleii(scope, name, rse, rse_attrs, protocol_attrs):
138
+ """
139
+ Given a LFN, convert it directly to a path using the mapping:
140
+
141
+ path -> path
142
+ This is valid only for the belleii convention where the scope can be determined
143
+ from the LFN using a determinitic function.
144
+
145
+ :param scope: Scope of the LFN.
146
+ :param name: File name of the LFN.
147
+ :param rse: RSE for PFN (ignored)
148
+ :param rse_attrs: RSE attributes for PFN (ignored)
149
+ :param protocol_attrs: RSE protocol attributes for PFN (ignored)
150
+ :returns: Path for use in the PFN generation.
151
+ """
152
+ del scope
153
+ del rse
154
+ del rse_attrs
155
+ del protocol_attrs
156
+ return name
157
+
158
+ @staticmethod
159
+ def __ligo(scope, name, rse, rse_attrs, protocol_attrs):
160
+ """
161
+ Given a LFN, convert it directly to a path using the Caltech schema
162
+
163
+ e.g.,: ER8:H-H1_HOFT_C02-1126256640-4096 ->
164
+ ER8/hoft_C02/H1/H-H1_HOFT_C02-11262/H-H1_HOFT_C02-1126256640-4096
165
+
166
+ :param scope: Scope of the LFN (observing run: ER8, O2, postO1, ...)
167
+ :param name: File name of the LFN (E.g., H-H1_HOFT_C02-1126256640-4096.gwf)
168
+ :param rse: RSE for PFN (ignored)
169
+ :param rse_attrs: RSE attributes for PFN (ignored)
170
+ :param protocol_attrs: RSE protocol attributes for PFN (ignored)
171
+ :returns: Path for use in the PFN generation.
172
+ """
173
+ del rse
174
+ del rse_attrs
175
+ del protocol_attrs
176
+ from ligo_rucio import lfn2pfn as ligo_lfn2pfn # pylint: disable=import-error
177
+ return ligo_lfn2pfn.ligo_lab(scope, name, None, None, None)
178
+
179
+ @staticmethod
180
+ def __xenon(scope, name, rse, rse_attrs, protocol_attrs):
181
+ """
182
+ Given a LFN, turn it into a two level sub-directory structure based on the scope
183
+ plus a third level based on the name
184
+ :param scope: Scope of the LFN.
185
+ :param name: File name of the LFN.
186
+ :param rse: RSE for PFN (ignored)
187
+ :param rse_attrs: RSE attributes for PFN (ignored)
188
+ :param protocol_attrs: RSE protocol attributes for PFN (ignored)
189
+ :returns: Path for use in the PFN generation.
190
+ """
191
+ del rse
192
+ del rse_attrs
193
+ del protocol_attrs
194
+
195
+ return '%s/%s/%s/%s' % (scope[0:7], scope[4:len(scope)], name.split('-')[0] + "-" + name.split('-')[1], name)
196
+
197
+ @staticmethod
198
+ def __lsst(scope, name, rse, rse_attrs, protocol_attrs):
199
+ """
200
+ LFN2PFN algorithm for Rubin-LSST in the ESCAPE project
201
+
202
+ Replace convention delimiter '__' by '/'
203
+ The Escape instance does use the 'generic' Rucio schema.
204
+
205
+ :param scope: Scope of the LFN (ignored)
206
+ :param name: File name of the LFN.
207
+ :param rse: RSE for PFN (ignored)
208
+ :param rse_attrs: RSE attributes for PFN (ignored)
209
+ :param protocol_attrs: RSE protocol attributes for PFN (ignored)
210
+ :returns: Path for use in the PFN generation.
211
+ """
212
+ del scope
213
+ del rse
214
+ del rse_attrs
215
+ del protocol_attrs
216
+ return name.replace('__', '/')
217
+
218
+ @classmethod
219
+ def _module_init_(cls):
220
+ """
221
+ Initialize the class object on first module load.
222
+ """
223
+ cls.register(cls.__hash, "hash")
224
+ cls.register(cls.__identity, "identity")
225
+ cls.register(cls.__ligo, "ligo")
226
+ cls.register(cls.__belleii, "belleii")
227
+ cls.register(cls.__xenon, "xenon")
228
+ cls.register(cls.__lsst, "lsst")
229
+ policy_module = None
230
+ try:
231
+ policy_module = config.config_get('policy', 'lfn2pfn_module')
232
+ except (NoOptionError, NoSectionError):
233
+ pass
234
+ if policy_module:
235
+ # TODO: The import of importlib is done like this due to a dependency issue with python 2.6 and incompatibility of the module with py3.x
236
+ # More information https://github.com/rucio/rucio/issues/875
237
+ import importlib
238
+ importlib.import_module(policy_module)
239
+
240
+ cls._DEFAULT_LFN2PFN = config.get_lfn2pfn_algorithm_default()
241
+
242
+ def path(self, scope, name):
243
+ """ Transforms the logical file name into a PFN's path.
244
+
245
+ :param lfn: filename
246
+ :param scope: scope
247
+
248
+ :returns: RSE specific URI of the physical file
249
+ """
250
+ # on first call, register any lfn2pfn algorithms from the policy package(s) (server only)
251
+ if getattr(rsemanager, 'SERVER_MODE', None) and not self.loaded_policy_modules:
252
+ register_policy_package_algorithms('lfn2pfn', RSEDeterministicTranslation._LFN2PFN_ALGORITHMS)
253
+ self.loaded_policy_modules = True
254
+
255
+ algorithm = self.rse_attributes.get('lfn2pfn_algorithm', 'default')
256
+ if algorithm == 'default':
257
+ algorithm = RSEDeterministicTranslation._DEFAULT_LFN2PFN
258
+ algorithm_callable = RSEDeterministicTranslation._LFN2PFN_ALGORITHMS[algorithm]
259
+ return algorithm_callable(scope, name, self.rse, self.rse_attributes, self.protocol_attributes)
260
+
261
+
262
+ RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access
263
+
264
+
265
+ class RSEProtocol(object):
266
+ """ This class is virtual and acts as a base to inherit new protocols from. It further provides some common functionality which applies for the amjority of the protocols."""
267
+
268
+ def __init__(self, protocol_attr, rse_settings, logger=logging.log):
269
+ """ Initializes the object with information about the referred RSE.
270
+
271
+ :param protocol_attr: Properties of the requested protocol.
272
+ :param rse_settting: The RSE settings.
273
+ :param logger: Optional decorated logger that can be passed from the calling daemons or servers.
274
+ """
275
+ self.auth_token = protocol_attr['auth_token']
276
+ protocol_attr.pop('auth_token')
277
+ self.attributes = protocol_attr
278
+ self.translator = None
279
+ self.renaming = True
280
+ self.overwrite = False
281
+ self.rse = rse_settings
282
+ self.logger = logger
283
+ if self.rse['deterministic']:
284
+ self.translator = RSEDeterministicTranslation(self.rse['rse'], rse_settings, self.attributes)
285
+ if getattr(rsemanager, 'CLIENT_MODE', None) and \
286
+ not RSEDeterministicTranslation.supports(self.rse.get('lfn2pfn_algorithm')):
287
+ # Remote server has an algorithm we don't understand; always make the server do the lookup.
288
+ setattr(self, 'lfns2pfns', self.__lfns2pfns_client)
289
+ else:
290
+ if getattr(rsemanager, 'CLIENT_MODE', None):
291
+ setattr(self, 'lfns2pfns', self.__lfns2pfns_client)
292
+ if getattr(rsemanager, 'SERVER_MODE', None):
293
+ setattr(self, '_get_path', self._get_path_nondeterministic_server)
294
+
295
+ def lfns2pfns(self, lfns):
296
+ """
297
+ Retruns a fully qualified PFN for the file referred by path.
298
+
299
+ :param path: The path to the file.
300
+
301
+ :returns: Fully qualified PFN.
302
+ """
303
+ pfns = {}
304
+ prefix = self.attributes['prefix']
305
+
306
+ if not prefix.startswith('/'):
307
+ prefix = ''.join(['/', prefix])
308
+ if not prefix.endswith('/'):
309
+ prefix = ''.join([prefix, '/'])
310
+
311
+ lfns = [lfns] if isinstance(lfns, dict) else lfns
312
+ for lfn in lfns:
313
+ scope, name = str(lfn['scope']), lfn['name']
314
+ if 'path' in lfn and lfn['path'] is not None:
315
+ pfns['%s:%s' % (scope, name)] = ''.join([self.attributes['scheme'],
316
+ '://',
317
+ self.attributes['hostname'],
318
+ ':',
319
+ str(self.attributes['port']),
320
+ prefix,
321
+ lfn['path'] if not lfn['path'].startswith('/') else lfn['path'][1:]
322
+ ])
323
+ else:
324
+ try:
325
+ pfns['%s:%s' % (scope, name)] = ''.join([self.attributes['scheme'],
326
+ '://',
327
+ self.attributes['hostname'],
328
+ ':',
329
+ str(self.attributes['port']),
330
+ prefix,
331
+ self._get_path(scope=scope, name=name)
332
+ ])
333
+ except exception.ReplicaNotFound as e:
334
+ self.logger(logging.WARNING, str(e))
335
+ return pfns
336
+
337
+ def __lfns2pfns_client(self, lfns):
338
+ """ Provides the path of a replica for non-deterministic sites. Will be assigned to get path by the __init__ method if neccessary.
339
+
340
+ :param scope: list of DIDs
341
+
342
+ :returns: dict with scope:name as keys and PFN as value (in case of errors the Rucio exception si assigned to the key)
343
+ """
344
+ client = RSEClient() # pylint: disable=E0601
345
+
346
+ lfns = [lfns] if isinstance(lfns, dict) else lfns
347
+ lfn_query = ["%s:%s" % (lfn['scope'], lfn['name']) for lfn in lfns]
348
+ return client.lfns2pfns(self.rse['rse'], lfn_query, scheme=self.attributes['scheme'])
349
+
350
+ def _get_path(self, scope, name):
351
+ """ Transforms the logical file name into a PFN.
352
+ Suitable for sites implementing the RUCIO naming convention.
353
+ This implementation is only invoked if the RSE is deterministic.
354
+
355
+ :param scope: scope
356
+ :param name: filename
357
+
358
+ :returns: RSE specific URI of the physical file
359
+ """
360
+ return self.translator.path(scope, name)
361
+
362
+ def _get_path_nondeterministic_server(self, scope, name): # pylint: disable=invalid-name
363
+ """ Provides the path of a replica for non-deterministic sites. Will be assigned to get path by the __init__ method if neccessary. """
364
+ vo = get_rse_vo(self.rse['id']) # pylint: disable=E0601
365
+ scope = InternalScope(scope, vo=vo) # pylint: disable=E0601
366
+ rep = replica.get_replica(scope=scope, name=name, rse_id=self.rse['id']) # pylint: disable=E0601
367
+ if 'path' in rep and rep['path'] is not None:
368
+ path = rep['path']
369
+ elif 'state' in rep and (rep['state'] is None or rep['state'] == 'UNAVAILABLE'):
370
+ raise exception.ReplicaUnAvailable('Missing path information and state is UNAVAILABLE for replica %s:%s on non-deterministic storage named %s' % (scope, name, self.rse['rse']))
371
+ else:
372
+ raise exception.ReplicaNotFound('Missing path information for replica %s:%s on non-deterministic storage named %s' % (scope, name, self.rse['rse']))
373
+ if path.startswith('/'):
374
+ path = path[1:]
375
+ if path.endswith('/'):
376
+ path = path[:-1]
377
+ return path
378
+
379
+ def parse_pfns(self, pfns):
380
+ """
381
+ Splits the given PFN into the parts known by the protocol. It is also checked if the provided protocol supportes the given PFNs.
382
+
383
+ :param pfns: a list of a fully qualified PFNs
384
+
385
+ :returns: dic with PFN as key and a dict with path and name as value
386
+
387
+ :raises RSEFileNameNotSupported: if the provided PFN doesn't match with the protocol settings
388
+ """
389
+ ret = dict()
390
+ pfns = [pfns] if isinstance(pfns, str) else pfns
391
+
392
+ for pfn in pfns:
393
+ parsed = urlparse(pfn)
394
+ scheme = parsed.scheme
395
+ hostname = parsed.netloc.partition(':')[0]
396
+ port = int(parsed.netloc.partition(':')[2]) if parsed.netloc.partition(':')[2] != '' else 0
397
+ while '//' in parsed.path:
398
+ parsed = parsed._replace(path=parsed.path.replace('//', '/'))
399
+ path = parsed.path
400
+ prefix = self.attributes['prefix']
401
+ while '//' in prefix:
402
+ prefix = prefix.replace('//', '/')
403
+
404
+ # Protect against 'lazy' defined prefixes for RSEs in the repository
405
+ if not prefix.startswith('/'):
406
+ prefix = '/' + prefix
407
+ if not prefix.endswith('/'):
408
+ prefix += '/'
409
+
410
+ if self.attributes['hostname'] != hostname:
411
+ if self.attributes['hostname'] != 'localhost': # In the database empty hostnames are replaced with localhost but for some URIs (e.g. file) a hostname is not included
412
+ raise exception.RSEFileNameNotSupported('Invalid hostname: provided \'%s\', expected \'%s\'' % (hostname, self.attributes['hostname']))
413
+
414
+ if self.attributes['port'] != port:
415
+ raise exception.RSEFileNameNotSupported('Invalid port: provided \'%s\', expected \'%s\'' % (port, self.attributes['port']))
416
+
417
+ if not path.startswith(prefix):
418
+ raise exception.RSEFileNameNotSupported('Invalid prefix: provided \'%s\', expected \'%s\'' % ('/'.join(path.split('/')[0:len(prefix.split('/')) - 1]),
419
+ prefix)) # len(...)-1 due to the leading '/
420
+
421
+ # Spliting parsed.path into prefix, path, filename
422
+ path = path.partition(prefix)[2]
423
+ name = path.split('/')[-1]
424
+ path = '/'.join(path.split('/')[:-1])
425
+ if not path.startswith('/'):
426
+ path = '/' + path
427
+ if path != '/' and not path.endswith('/'):
428
+ path = path + '/'
429
+ ret[pfn] = {'path': path, 'name': name, 'scheme': scheme, 'prefix': prefix, 'port': port, 'hostname': hostname, }
430
+
431
+ return ret
432
+
433
+ def exists(self, path):
434
+ """
435
+ Checks if the requested file is known by the referred RSE.
436
+
437
+ :param path: Physical file name
438
+
439
+ :returns: True if the file exists, False if it doesn't
440
+
441
+ :raises SourceNotFound: if the source file was not found on the referred storage.
442
+ """
443
+ raise NotImplementedError
444
+
445
+ def connect(self):
446
+ """
447
+ Establishes the actual connection to the referred RSE.
448
+
449
+ :raises RSEAccessDenied: if no connection could be established.
450
+ """
451
+ raise NotImplementedError
452
+
453
+ def close(self):
454
+ """ Closes the connection to RSE."""
455
+ raise NotImplementedError
456
+
457
+ def get(self, path, dest, transfer_timeout=None):
458
+ """
459
+ Provides access to files stored inside connected the RSE.
460
+
461
+ :param path: Physical file name of requested file
462
+ :param dest: Name and path of the files when stored at the client
463
+ :param transfer_timeout: Transfer timeout (in seconds)
464
+
465
+ :raises DestinationNotAccessible: if the destination storage was not accessible.
466
+ :raises ServiceUnavailable: if some generic error occured in the library.
467
+ :raises SourceNotFound: if the source file was not found on the referred storage.
468
+ """
469
+ raise NotImplementedError
470
+
471
+ def put(self, source, target, source_dir, transfer_timeout=None):
472
+ """
473
+ Allows to store files inside the referred RSE.
474
+
475
+ :param source: path to the source file on the client file system
476
+ :param target: path to the destination file on the storage
477
+ :param source_dir: Path where the to be transferred files are stored in the local file system
478
+ :param transfer_timeout: Transfer timeout (in seconds)
479
+
480
+ :raises DestinationNotAccessible: if the destination storage was not accessible.
481
+ :raises ServiceUnavailable: if some generic error occured in the library.
482
+ :raises SourceNotFound: if the source file was not found on the referred storage.
483
+ """
484
+ raise NotImplementedError
485
+
486
+ def delete(self, path):
487
+ """
488
+ Deletes a file from the connected RSE.
489
+
490
+ :param path: path to the to be deleted file
491
+
492
+ :raises ServiceUnavailable: if some generic error occured in the library.
493
+ :raises SourceNotFound: if the source file was not found on the referred storage.
494
+ """
495
+ raise NotImplementedError
496
+
497
+ def rename(self, path, new_path):
498
+ """ Allows to rename a file stored inside the connected RSE.
499
+
500
+ :param path: path to the current file on the storage
501
+ :param new_path: path to the new file on the storage
502
+
503
+ :raises DestinationNotAccessible: if the destination storage was not accessible.
504
+ :raises ServiceUnavailable: if some generic error occured in the library.
505
+ :raises SourceNotFound: if the source file was not found on the referred storage.
506
+ """
507
+ raise NotImplementedError
508
+
509
+ def get_space_usage(self):
510
+ """
511
+ Get RSE space usage information.
512
+
513
+ :returns: a list with dict containing 'totalsize' and 'unusedsize'
514
+
515
+ :raises ServiceUnavailable: if some generic error occured in the library.
516
+ """
517
+ raise NotImplementedError
518
+
519
+ def stat(self, path):
520
+ """
521
+ Returns the stats of a file.
522
+
523
+ :param path: path to file
524
+
525
+ :raises ServiceUnavailable: if some generic error occured in the library.
526
+ :raises SourceNotFound: if the source file was not found on the referred storage.
527
+
528
+ :returns: a dict with two keys, filesize and adler32 of the file provided in path.
529
+ """
530
+ raise NotImplementedError