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,871 @@
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 copy
17
+ import json
18
+ import logging
19
+ import os
20
+ import os.path
21
+ import random
22
+ import socket
23
+ import time
24
+
25
+ from rucio import version
26
+ from rucio.client.client import Client
27
+ from rucio.common.config import config_get_int, config_get
28
+ from rucio.common.exception import (RucioException, RSEWriteBlocked, DataIdentifierAlreadyExists, RSEOperationNotSupported,
29
+ DataIdentifierNotFound, NoFilesUploaded, NotAllFilesUploaded, FileReplicaAlreadyExists,
30
+ ResourceTemporaryUnavailable, ServiceUnavailable, InputValidationError, RSEChecksumUnavailable,
31
+ ScopeNotFound)
32
+ from rucio.common.utils import (adler32, detect_client_location, execute, generate_uuid, make_valid_did, md5, send_trace,
33
+ retry, GLOBALLY_SUPPORTED_CHECKSUMS)
34
+ from rucio.rse import rsemanager as rsemgr
35
+
36
+
37
+ class UploadClient:
38
+
39
+ def __init__(self, _client=None, logger=None, tracing=True):
40
+ """
41
+ Initialises the basic settings for an UploadClient object
42
+
43
+ :param _client: - Optional: rucio.client.client.Client object. If None, a new object will be created.
44
+ :param logger: - Optional: logging.Logger object. If None, default logger will be used.
45
+ """
46
+ if not logger:
47
+ self.logger = logging.log
48
+ else:
49
+ self.logger = logger.log
50
+
51
+ self.client = _client if _client else Client()
52
+ self.client_location = detect_client_location()
53
+ # if token should be used, use only JWT tokens
54
+ self.auth_token = self.client.auth_token if len(self.client.auth_token.split(".")) == 3 else None
55
+ self.tracing = tracing
56
+ if not self.tracing:
57
+ logger(logging.DEBUG, 'Tracing is turned off.')
58
+ self.default_file_scope = 'user.' + self.client.account
59
+ self.rses = {}
60
+ self.rse_expressions = {}
61
+
62
+ self.trace = {}
63
+ self.trace['hostname'] = socket.getfqdn()
64
+ self.trace['account'] = self.client.account
65
+ if self.client.vo != 'def':
66
+ self.trace['vo'] = self.client.vo
67
+ self.trace['eventType'] = 'upload'
68
+ self.trace['eventVersion'] = version.RUCIO_VERSION[0]
69
+
70
+ def upload(self, items, summary_file_path=None, traces_copy_out=None, ignore_availability=False, activity=None):
71
+ """
72
+ :param items: List of dictionaries. Each dictionary describing a file to upload. Keys:
73
+ path - path of the file that will be uploaded
74
+ rse - rse expression/name (e.g. 'CERN-PROD_DATADISK') where to upload the file
75
+ did_scope - Optional: custom did scope (Default: user.<account>)
76
+ did_name - Optional: custom did name (Default: name of the file)
77
+ dataset_scope - Optional: custom dataset scope
78
+ dataset_name - Optional: custom dataset name
79
+ dataset_meta - Optional: custom metadata for dataset
80
+ impl - Optional: name of the protocol implementation to be used to upload this item.
81
+ force_scheme - Optional: force a specific scheme (if PFN upload this will be overwritten) (Default: None)
82
+ pfn - Optional: use a given PFN (this sets no_register to True, and no_register becomes mandatory)
83
+ no_register - Optional: if True, the file will not be registered in the rucio catalogue
84
+ register_after_upload - Optional: if True, the file will be registered after successful upload
85
+ lifetime - Optional: the lifetime of the file after it was uploaded
86
+ transfer_timeout - Optional: time after the upload will be aborted
87
+ guid - Optional: guid of the file
88
+ recursive - Optional: if set, parses the folder structure recursively into collections
89
+ :param summary_file_path: Optional: a path where a summary in form of a json file will be stored
90
+ :param traces_copy_out: reference to an external list, where the traces should be uploaded
91
+ :param ignore_availability: ignore the availability of a RSE
92
+ :param activity: the activity set to the rule if no dataset is specified
93
+
94
+ :returns: 0 on success
95
+
96
+ :raises InputValidationError: if any input arguments are in a wrong format
97
+ :raises RSEWriteBlocked: if a given RSE is not available for writing
98
+ :raises NoFilesUploaded: if no files were successfully uploaded
99
+ :raises NotAllFilesUploaded: if not all files were successfully uploaded
100
+ """
101
+ # helper to get rse from rse_expression:
102
+ def _pick_random_rse(rse_expression):
103
+ rses = [r['rse'] for r in self.client.list_rses(rse_expression)] # can raise InvalidRSEExpression
104
+ random.shuffle(rses)
105
+ return rses[0]
106
+
107
+ logger = self.logger
108
+ self.trace['uuid'] = generate_uuid()
109
+
110
+ # check given sources, resolve dirs into files, and collect meta infos
111
+ files = self._collect_and_validate_file_info(items)
112
+ logger(logging.DEBUG, 'Num. of files that upload client is processing: {}'.format(len(files)))
113
+
114
+ # check if RSE of every file is available for writing
115
+ # and cache rse settings
116
+ registered_dataset_dids = set()
117
+ registered_file_dids = set()
118
+ rse_expression = None
119
+ for file in files:
120
+ rse_expression = file['rse']
121
+ rse = self.rse_expressions.setdefault(rse_expression, _pick_random_rse(rse_expression))
122
+
123
+ if not self.rses.get(rse):
124
+ rse_settings = self.rses.setdefault(rse, rsemgr.get_rse_info(rse, vo=self.client.vo))
125
+ if not ignore_availability and rse_settings['availability_write'] != 1:
126
+ raise RSEWriteBlocked('%s is not available for writing. No actions have been taken' % rse)
127
+
128
+ dataset_scope = file.get('dataset_scope')
129
+ dataset_name = file.get('dataset_name')
130
+ file['rse'] = rse
131
+ if dataset_scope and dataset_name:
132
+ dataset_did_str = ('%s:%s' % (dataset_scope, dataset_name))
133
+ file['dataset_did_str'] = dataset_did_str
134
+ registered_dataset_dids.add(dataset_did_str)
135
+
136
+ registered_file_dids.add('%s:%s' % (file['did_scope'], file['did_name']))
137
+ wrong_dids = registered_file_dids.intersection(registered_dataset_dids)
138
+ if len(wrong_dids):
139
+ raise InputValidationError('DIDs used to address both files and datasets: %s' % str(wrong_dids))
140
+ logger(logging.DEBUG, 'Input validation done.')
141
+
142
+ # clear this set again to ensure that we only try to register datasets once
143
+ registered_dataset_dids = set()
144
+ num_succeeded = 0
145
+ summary = []
146
+ for file in files:
147
+ basename = file['basename']
148
+ logger(logging.INFO, 'Preparing upload for file %s' % basename)
149
+
150
+ no_register = file.get('no_register')
151
+ register_after_upload = file.get('register_after_upload') and not no_register
152
+ pfn = file.get('pfn')
153
+ force_scheme = file.get('force_scheme')
154
+ impl = file.get('impl')
155
+ delete_existing = False
156
+
157
+ trace = copy.deepcopy(self.trace)
158
+ # appending trace to list reference, if the reference exists
159
+ if traces_copy_out is not None:
160
+ traces_copy_out.append(trace)
161
+
162
+ rse = file['rse']
163
+ trace['scope'] = file['did_scope']
164
+ trace['datasetScope'] = file.get('dataset_scope', '')
165
+ trace['dataset'] = file.get('dataset_name', '')
166
+ trace['remoteSite'] = rse
167
+ trace['filesize'] = file['bytes']
168
+
169
+ file_did = {'scope': file['did_scope'], 'name': file['did_name']}
170
+ dataset_did_str = file.get('dataset_did_str')
171
+ rse_settings = self.rses[rse]
172
+ rse_sign_service = rse_settings.get('sign_url', None)
173
+ is_deterministic = rse_settings.get('deterministic', True)
174
+ if not is_deterministic and not pfn:
175
+ logger(logging.ERROR, 'PFN has to be defined for NON-DETERMINISTIC RSE.')
176
+ continue
177
+ if pfn and is_deterministic:
178
+ logger(logging.WARNING, 'Upload with given pfn implies that no_register is True, except non-deterministic RSEs')
179
+ no_register = True
180
+
181
+ # resolving local area networks
182
+ domain = 'wan'
183
+ rse_attributes = {}
184
+ try:
185
+ rse_attributes = self.client.list_rse_attributes(rse)
186
+ except:
187
+ logger(logging.WARNING, 'Attributes of the RSE: %s not available.' % rse)
188
+ if (self.client_location and 'lan' in rse_settings['domain'] and 'site' in rse_attributes):
189
+ if self.client_location['site'] == rse_attributes['site']:
190
+ domain = 'lan'
191
+ logger(logging.DEBUG, '{} domain is used for the upload'.format(domain))
192
+
193
+ # FIXME:
194
+ # Rewrite preferred_impl selection - also check test_upload.py/test_download.py and fix impl order (see FIXME there)
195
+ #
196
+ # if not impl and not force_scheme:
197
+ # impl = self.preferred_impl(rse_settings, domain)
198
+
199
+ if not no_register and not register_after_upload:
200
+ self._register_file(file, registered_dataset_dids, ignore_availability=ignore_availability, activity=activity)
201
+
202
+ # if register_after_upload, file should be overwritten if it is not registered
203
+ # otherwise if file already exists on RSE we're done
204
+ if register_after_upload:
205
+ if rsemgr.exists(rse_settings, pfn if pfn else file_did, domain=domain, scheme=force_scheme, impl=impl, auth_token=self.auth_token, vo=self.client.vo, logger=logger):
206
+ try:
207
+ self.client.get_did(file['did_scope'], file['did_name'])
208
+ logger(logging.INFO, 'File already registered. Skipping upload.')
209
+ trace['stateReason'] = 'File already exists'
210
+ continue
211
+ except DataIdentifierNotFound:
212
+ logger(logging.INFO, 'File already exists on RSE. Previous left overs will be overwritten.')
213
+ delete_existing = True
214
+ elif not is_deterministic and not no_register:
215
+ if rsemgr.exists(rse_settings, pfn, domain=domain, scheme=force_scheme, impl=impl, auth_token=self.auth_token, vo=self.client.vo, logger=logger):
216
+ logger(logging.INFO, 'File already exists on RSE with given pfn. Skipping upload. Existing replica has to be removed first.')
217
+ trace['stateReason'] = 'File already exists'
218
+ continue
219
+ elif rsemgr.exists(rse_settings, file_did, domain=domain, scheme=force_scheme, impl=impl, auth_token=self.auth_token, vo=self.client.vo, logger=logger):
220
+ logger(logging.INFO, 'File already exists on RSE with different pfn. Skipping upload.')
221
+ trace['stateReason'] = 'File already exists'
222
+ continue
223
+ else:
224
+ if rsemgr.exists(rse_settings, pfn if pfn else file_did, domain=domain, scheme=force_scheme, impl=impl, auth_token=self.auth_token, vo=self.client.vo, logger=logger):
225
+ logger(logging.INFO, 'File already exists on RSE. Skipping upload')
226
+ trace['stateReason'] = 'File already exists'
227
+ continue
228
+
229
+ # protocol handling and upload
230
+ protocols = rsemgr.get_protocols_ordered(rse_settings=rse_settings, operation='write', scheme=force_scheme, domain=domain, impl=impl)
231
+ protocols.reverse()
232
+ success = False
233
+ state_reason = ''
234
+ logger(logging.DEBUG, str(protocols))
235
+ while not success and len(protocols):
236
+ protocol = protocols.pop()
237
+ cur_scheme = protocol['scheme']
238
+ logger(logging.INFO, 'Trying upload with %s to %s' % (cur_scheme, rse))
239
+ lfn = {}
240
+ lfn['filename'] = basename
241
+ lfn['scope'] = file['did_scope']
242
+ lfn['name'] = file['did_name']
243
+
244
+ for checksum_name in GLOBALLY_SUPPORTED_CHECKSUMS:
245
+ if checksum_name in file:
246
+ lfn[checksum_name] = file[checksum_name]
247
+
248
+ lfn['filesize'] = file['bytes']
249
+
250
+ sign_service = None
251
+ if cur_scheme == 'https':
252
+ sign_service = rse_sign_service
253
+
254
+ trace['protocol'] = cur_scheme
255
+ trace['transferStart'] = time.time()
256
+ logger(logging.DEBUG, 'Processing upload with the domain: {}'.format(domain))
257
+ try:
258
+ pfn = self._upload_item(rse_settings=rse_settings,
259
+ rse_attributes=rse_attributes,
260
+ lfn=lfn,
261
+ source_dir=file['dirname'],
262
+ domain=domain,
263
+ impl=impl,
264
+ force_scheme=cur_scheme,
265
+ force_pfn=pfn,
266
+ transfer_timeout=file.get('transfer_timeout'),
267
+ delete_existing=delete_existing,
268
+ sign_service=sign_service)
269
+ logger(logging.DEBUG, 'Upload done.')
270
+ success = True
271
+ file['upload_result'] = {0: True, 1: None, 'success': True, 'pfn': pfn} # needs to be removed
272
+ except (ServiceUnavailable, ResourceTemporaryUnavailable, RSEOperationNotSupported, RucioException) as error:
273
+ logger(logging.WARNING, 'Upload attempt failed')
274
+ logger(logging.INFO, 'Exception: %s' % str(error), exc_info=True)
275
+ state_reason = str(error)
276
+
277
+ if success:
278
+ trace['transferEnd'] = time.time()
279
+ trace['clientState'] = 'DONE'
280
+ file['state'] = 'A'
281
+ logger(logging.INFO, 'Successfully uploaded file %s' % basename)
282
+ self._send_trace(trace)
283
+
284
+ if summary_file_path:
285
+ summary.append(copy.deepcopy(file))
286
+
287
+ registration_succeeded = True
288
+ if not no_register:
289
+ if register_after_upload:
290
+ self._register_file(file, registered_dataset_dids, ignore_availability=ignore_availability, activity=activity)
291
+ else:
292
+ replica_for_api = self._convert_file_for_api(file)
293
+ try:
294
+ self.client.update_replicas_states(rse, files=[replica_for_api])
295
+ except Exception as error:
296
+ registration_succeeded = False
297
+ logger(logging.ERROR, 'Failed to update replica state for file {}'.format(basename))
298
+ logger(logging.DEBUG, 'Details: {}'.format(str(error)))
299
+
300
+ # add file to dataset if needed
301
+ if dataset_did_str and not no_register:
302
+ try:
303
+ self.client.attach_dids(file['dataset_scope'], file['dataset_name'], [file_did])
304
+ except Exception as error:
305
+ registration_succeeded = False
306
+ logger(logging.ERROR, 'Failed to attach file to the dataset')
307
+ logger(logging.DEBUG, 'Attaching to dataset {}'.format(str(error)))
308
+
309
+ # only report success if the registration operations succeeded as well
310
+ if registration_succeeded:
311
+ num_succeeded += 1
312
+ else:
313
+ trace['clientState'] = 'FAILED'
314
+ trace['stateReason'] = state_reason
315
+ self._send_trace(trace)
316
+ logger(logging.ERROR, 'Failed to upload file %s' % basename)
317
+
318
+ if summary_file_path:
319
+ logger(logging.DEBUG, 'Summary will be available at {}'.format(summary_file_path))
320
+ final_summary = {}
321
+ for file in summary:
322
+ file_scope = file['did_scope']
323
+ file_name = file['did_name']
324
+ file_did_str = '%s:%s' % (file_scope, file_name)
325
+ final_summary[file_did_str] = {'scope': file_scope,
326
+ 'name': file_name,
327
+ 'bytes': file['bytes'],
328
+ 'rse': file['rse'],
329
+ 'pfn': file['upload_result'].get('pfn', ''),
330
+ 'guid': file['meta']['guid']}
331
+
332
+ for checksum_name in GLOBALLY_SUPPORTED_CHECKSUMS:
333
+ if checksum_name in file:
334
+ final_summary[file_did_str][checksum_name] = file[checksum_name]
335
+
336
+ with open(summary_file_path, 'w') as summary_file:
337
+ json.dump(final_summary, summary_file, sort_keys=True, indent=1)
338
+
339
+ if num_succeeded == 0:
340
+ raise NoFilesUploaded()
341
+ elif num_succeeded != len(files):
342
+ raise NotAllFilesUploaded()
343
+ return 0
344
+
345
+ def _register_file(self, file, registered_dataset_dids, ignore_availability=False, activity=None):
346
+ """
347
+ Registers the given file in Rucio. Creates a dataset if
348
+ needed. Registers the file DID and creates the replication
349
+ rule if needed. Adds a replica to the file did.
350
+ (This function is meant to be used as class internal only)
351
+
352
+ :param file: dictionary describing the file
353
+ :param registered_dataset_dids: set of dataset dids that were already registered
354
+ :param ignore_availability: ignore the availability of a RSE
355
+ :param activity: the activity set to the rule if no dataset is specified
356
+
357
+ :raises DataIdentifierAlreadyExists: if file DID is already registered and the checksums do not match
358
+ """
359
+ logger = self.logger
360
+ logger(logging.DEBUG, 'Registering file')
361
+
362
+ # verification whether the scope exists
363
+ account_scopes = []
364
+ try:
365
+ account_scopes = self.client.list_scopes_for_account(self.client.account)
366
+ except ScopeNotFound:
367
+ pass
368
+ if account_scopes and file['did_scope'] not in account_scopes:
369
+ logger(logging.WARNING, 'Scope {} not found for the account {}.'.format(file['did_scope'], self.client.account))
370
+
371
+ rse = file['rse']
372
+ dataset_did_str = file.get('dataset_did_str')
373
+ # register a dataset if we need to
374
+ if dataset_did_str and dataset_did_str not in registered_dataset_dids:
375
+ registered_dataset_dids.add(dataset_did_str)
376
+ try:
377
+ logger(logging.DEBUG, 'Trying to create dataset: %s' % dataset_did_str)
378
+ self.client.add_dataset(scope=file['dataset_scope'],
379
+ name=file['dataset_name'],
380
+ meta=file.get('dataset_meta'),
381
+ rules=[{'account': self.client.account,
382
+ 'copies': 1,
383
+ 'rse_expression': rse,
384
+ 'grouping': 'DATASET',
385
+ 'lifetime': file.get('lifetime')}])
386
+ logger(logging.INFO, 'Successfully created dataset %s' % dataset_did_str)
387
+ except DataIdentifierAlreadyExists:
388
+ logger(logging.INFO, 'Dataset %s already exists - no rule will be created' % dataset_did_str)
389
+
390
+ if file.get('lifetime') is not None:
391
+ raise InputValidationError('Dataset %s exists and lifetime %s given. Prohibited to modify parent dataset lifetime.' % (dataset_did_str,
392
+ file.get('lifetime')))
393
+ else:
394
+ logger(logging.DEBUG, 'Skipping dataset registration')
395
+
396
+ file_scope = file['did_scope']
397
+ file_name = file['did_name']
398
+ file_did = {'scope': file_scope, 'name': file_name}
399
+ replica_for_api = self._convert_file_for_api(file)
400
+ try:
401
+ # if the remote checksum is different this did must not be used
402
+ meta = self.client.get_metadata(file_scope, file_name)
403
+ logger(logging.INFO, 'File DID already exists')
404
+ logger(logging.DEBUG, 'local checksum: %s, remote checksum: %s' % (file['adler32'], meta['adler32']))
405
+
406
+ if str(meta['adler32']).lstrip('0') != str(file['adler32']).lstrip('0'):
407
+ logger(logging.ERROR, 'Local checksum %s does not match remote checksum %s' % (file['adler32'], meta['adler32']))
408
+
409
+ raise DataIdentifierAlreadyExists
410
+
411
+ # add file to rse if it is not registered yet
412
+ replicastate = list(self.client.list_replicas([file_did], all_states=True))
413
+ if rse not in replicastate[0]['rses']:
414
+ self.client.add_replicas(rse=rse, files=[replica_for_api])
415
+ logger(logging.INFO, 'Successfully added replica in Rucio catalogue at %s' % rse)
416
+ except DataIdentifierNotFound:
417
+ logger(logging.DEBUG, 'File DID does not exist')
418
+ self.client.add_replicas(rse=rse, files=[replica_for_api])
419
+ logger(logging.INFO, 'Successfully added replica in Rucio catalogue at %s' % rse)
420
+ if not dataset_did_str:
421
+ # only need to add rules for files if no dataset is given
422
+ self.client.add_replication_rule([file_did], copies=1, rse_expression=rse, lifetime=file.get('lifetime'), ignore_availability=ignore_availability, activity=activity)
423
+ logger(logging.INFO, 'Successfully added replication rule at %s' % rse)
424
+
425
+ def _get_file_guid(self, file):
426
+ """
427
+ Get the guid of a file, trying different strategies
428
+ (This function is meant to be used as class internal only)
429
+
430
+ :param file: dictionary describing the file
431
+
432
+ :returns: the guid
433
+ """
434
+ guid = file.get('guid')
435
+ if not guid and 'pool.root' in file['basename'].lower() and not file.get('no_register'):
436
+ status, output, err = execute('pool_extractFileIdentifier %s' % file['path'])
437
+ if status != 0:
438
+ msg = 'Trying to upload ROOT files but pool_extractFileIdentifier tool can not be found.\n'
439
+ msg += 'Setup your ATHENA environment and try again.'
440
+ raise RucioException(msg)
441
+ try:
442
+ guid = output.splitlines()[-1].split()[0].replace('-', '').lower()
443
+ except Exception:
444
+ raise RucioException('Error extracting GUID from ouput of pool_extractFileIdentifier')
445
+ elif guid:
446
+ guid = guid.replace('-', '')
447
+ else:
448
+ guid = generate_uuid()
449
+ return guid
450
+
451
+ def _collect_file_info(self, filepath, item):
452
+ """
453
+ Collects infos (e.g. size, checksums, etc.) about the file and
454
+ returns them as a dictionary
455
+ (This function is meant to be used as class internal only)
456
+
457
+ :param filepath: path where the file is stored
458
+ :param item: input options for the given file
459
+
460
+ :returns: a dictionary containing all collected info and the input options
461
+ """
462
+ new_item = copy.deepcopy(item)
463
+ new_item['path'] = filepath
464
+ new_item['dirname'] = os.path.dirname(filepath)
465
+ new_item['basename'] = os.path.basename(filepath)
466
+
467
+ new_item['bytes'] = os.stat(filepath).st_size
468
+ new_item['adler32'] = adler32(filepath)
469
+ new_item['md5'] = md5(filepath)
470
+ new_item['meta'] = {'guid': self._get_file_guid(new_item)}
471
+ new_item['state'] = 'C'
472
+ if not new_item.get('did_scope'):
473
+ new_item['did_scope'] = self.default_file_scope
474
+ if not new_item.get('did_name'):
475
+ new_item['did_name'] = new_item['basename']
476
+
477
+ return new_item
478
+
479
+ def _collect_and_validate_file_info(self, items):
480
+ """
481
+ Checks if there are any inconsistencies within the given input
482
+ options and stores the output of _collect_file_info for every file
483
+ (This function is meant to be used as class internal only)
484
+
485
+ :param filepath: list of dictionaries with all input files and options
486
+
487
+ :returns: a list of dictionaries containing all descriptions of the files to upload
488
+
489
+ :raises InputValidationError: if an input option has a wrong format
490
+ """
491
+ logger = self.logger
492
+ files = []
493
+ for item in items:
494
+ path = item.get('path')
495
+ pfn = item.get('pfn')
496
+ recursive = item.get('recursive')
497
+ if not path:
498
+ logger(logging.WARNING, 'Skipping source entry because the key "path" is missing')
499
+ continue
500
+ if not item.get('rse'):
501
+ logger(logging.WARNING, 'Skipping file %s because no rse was given' % path)
502
+ continue
503
+ if pfn:
504
+ item['force_scheme'] = pfn.split(':')[0]
505
+ if item.get('impl'):
506
+ impl = item.get('impl')
507
+ impl_split = impl.split('.')
508
+ if len(impl_split) == 1:
509
+ impl = 'rucio.rse.protocols.' + impl + '.Default'
510
+ else:
511
+ impl = 'rucio.rse.protocols.' + impl
512
+ item['impl'] = impl
513
+ if os.path.isdir(path) and not recursive:
514
+ dname, subdirs, fnames = next(os.walk(path))
515
+ for fname in fnames:
516
+ file = self._collect_file_info(os.path.join(dname, fname), item)
517
+ files.append(file)
518
+ if not len(fnames) and not len(subdirs):
519
+ logger(logging.WARNING, 'Skipping %s because it is empty.' % dname)
520
+ elif not len(fnames):
521
+ logger(logging.WARNING, 'Skipping %s because it has no files in it. Subdirectories are not supported.' % dname)
522
+ elif os.path.isdir(path) and recursive:
523
+ files.extend(self._recursive(item))
524
+ elif os.path.isfile(path) and not recursive:
525
+ file = self._collect_file_info(path, item)
526
+ files.append(file)
527
+ elif os.path.isfile(path) and recursive:
528
+ logger(logging.WARNING, 'Skipping %s because of --recursive flag' % path)
529
+ else:
530
+ logger(logging.WARNING, 'No such file or directory: %s' % path)
531
+
532
+ if not len(files):
533
+ raise InputValidationError('No valid input files given')
534
+
535
+ return files
536
+
537
+ def _convert_file_for_api(self, file):
538
+ """
539
+ Creates a new dictionary that contains only the values
540
+ that are needed for the upload with the correct keys
541
+ (This function is meant to be used as class internal only)
542
+
543
+ :param file: dictionary describing a file to upload
544
+
545
+ :returns: dictionary containing not more then the needed values for the upload
546
+ """
547
+ replica = {}
548
+ replica['scope'] = file['did_scope']
549
+ replica['name'] = file['did_name']
550
+ replica['bytes'] = file['bytes']
551
+ replica['adler32'] = file['adler32']
552
+ replica['md5'] = file['md5']
553
+ replica['meta'] = file['meta']
554
+ replica['state'] = file['state']
555
+ pfn = file.get('pfn')
556
+ if pfn:
557
+ replica['pfn'] = pfn
558
+ return replica
559
+
560
+ def _upload_item(self, rse_settings, rse_attributes, lfn, source_dir=None, domain='wan', impl=None, force_pfn=None, force_scheme=None, transfer_timeout=None, delete_existing=False, sign_service=None):
561
+ """
562
+ Uploads a file to the connected storage.
563
+
564
+ :param rse_settings: dictionary containing the RSE settings
565
+ :param rse_attributes: dictionary containing the RSE attribute key value pairs
566
+ :param lfn: a single dict containing 'scope' and 'name'.
567
+ Example:
568
+ {'name': '1_rse_local_put.raw', 'scope': 'user.jdoe', 'filesize': 42, 'adler32': '87HS3J968JSNWID'}
569
+ If the 'filename' key is present, it will be used by Rucio as the actual name of the file on disk (separate from the Rucio 'name').
570
+ :param source_dir: path to the local directory including the source files
571
+ :param force_pfn: use the given PFN -- can lead to dark data, use sparingly
572
+ :param force_scheme: use the given protocol scheme, overriding the protocol priority in the RSE description
573
+ :param transfer_timeout: set this timeout (in seconds) for the transfers, for protocols that support it
574
+ :param sign_service: use the given service (e.g. gcs, s3, swift) to sign the URL
575
+
576
+ :raises RucioException(msg): general exception with msg for more details.
577
+ """
578
+ logger = self.logger
579
+
580
+ # Construct protocol for write operation.
581
+ # IMPORTANT: All upload stat() checks are always done with the write_protocol EXCEPT for cloud resources (signed URL for write cannot be used for read)
582
+ protocol_write = self._create_protocol(rse_settings, 'write', force_scheme=force_scheme, domain=domain, impl=impl)
583
+
584
+ base_name = lfn.get('filename', lfn['name'])
585
+ name = lfn.get('name', base_name)
586
+ scope = lfn['scope']
587
+
588
+ # Conditional lfn properties
589
+ if 'adler32' not in lfn and 'md5' not in lfn:
590
+ logger(logging.WARNING, 'Missing checksum for file %s:%s' % (lfn['scope'], name))
591
+
592
+ # Getting pfn
593
+ pfn = None
594
+ signed_read_pfn = None
595
+ try:
596
+ pfn = list(protocol_write.lfns2pfns(make_valid_did(lfn)).values())[0]
597
+ logger(logging.DEBUG, 'The PFN created from the LFN: {}'.format(pfn))
598
+ except Exception as error:
599
+ logger(logging.WARNING, 'Failed to create PFN for LFN: %s' % lfn)
600
+ logger(logging.DEBUG, str(error), exc_info=True)
601
+ if force_pfn:
602
+ pfn = force_pfn
603
+ logger(logging.DEBUG, 'The given PFN is used: {}'.format(pfn))
604
+
605
+ # Auth. mostly for object stores
606
+ if sign_service:
607
+ protocol_read = self._create_protocol(rse_settings, 'read', domain=domain, impl=impl)
608
+ signed_read_pfn = self.client.get_signed_url(rse_settings['rse'], sign_service, 'read', pfn) # NOQA pylint: disable=undefined-variable
609
+ pfn = self.client.get_signed_url(rse_settings['rse'], sign_service, 'write', pfn) # NOQA pylint: disable=undefined-variable
610
+
611
+ # Create a name of tmp file if renaming operation is supported
612
+ pfn_tmp = '%s.rucio.upload' % pfn if protocol_write.renaming else pfn
613
+ signed_read_pfn_tmp = '%s.rucio.upload' % signed_read_pfn if protocol_write.renaming else signed_read_pfn
614
+
615
+ # Either DID exists or not register_after_upload
616
+ if protocol_write.overwrite is False and delete_existing is False:
617
+ if sign_service:
618
+ # Construct protocol for read ONLY for cloud resources and get signed URL for GET
619
+ if protocol_read.exists(signed_read_pfn):
620
+ raise FileReplicaAlreadyExists('File %s in scope %s already exists on storage as PFN %s' % (name, scope, pfn)) # wrong exception ?
621
+ elif protocol_write.exists(pfn):
622
+ raise FileReplicaAlreadyExists('File %s in scope %s already exists on storage as PFN %s' % (name, scope, pfn)) # wrong exception ?
623
+
624
+ # Removing tmp from earlier attempts
625
+ if (not sign_service and protocol_write.exists(pfn_tmp)) or (sign_service and protocol_read.exists(signed_read_pfn_tmp)):
626
+ logger(logging.DEBUG, 'Removing remains of previous upload attempts.')
627
+ try:
628
+ # Construct protocol for delete operation.
629
+ protocol_delete = self._create_protocol(rse_settings, 'delete', force_scheme=force_scheme, domain=domain, impl=impl)
630
+ delete_pfn = '%s.rucio.upload' % list(protocol_delete.lfns2pfns(make_valid_did(lfn)).values())[0]
631
+ if sign_service:
632
+ delete_pfn = self.client.get_signed_url(rse_settings['rse'], sign_service, 'delete', delete_pfn)
633
+ protocol_delete.delete(delete_pfn)
634
+ protocol_delete.close()
635
+ except Exception as error:
636
+ raise RSEOperationNotSupported('Unable to remove temporary file %s.rucio.upload: %s' % (pfn, str(error)))
637
+
638
+ # Removing not registered files from earlier attempts
639
+ if delete_existing:
640
+ logger(logging.DEBUG, 'Removing not-registered remains of previous upload attempts.')
641
+ try:
642
+ # Construct protocol for delete operation.
643
+ protocol_delete = self._create_protocol(rse_settings, 'delete', force_scheme=force_scheme, domain=domain, impl=impl)
644
+ delete_pfn = '%s' % list(protocol_delete.lfns2pfns(make_valid_did(lfn)).values())[0]
645
+ if sign_service:
646
+ delete_pfn = self.client.get_signed_url(rse_settings['rse'], sign_service, 'delete', delete_pfn)
647
+ protocol_delete.delete(delete_pfn)
648
+ protocol_delete.close()
649
+ except Exception as error:
650
+ raise RSEOperationNotSupported('Unable to remove file %s: %s' % (pfn, str(error)))
651
+
652
+ # Process the upload of the tmp file
653
+ try:
654
+ retry(protocol_write.put, base_name, pfn_tmp, source_dir, transfer_timeout=transfer_timeout)(mtries=2, logger=logger)
655
+ logger(logging.INFO, 'Successful upload of temporary file. {}'.format(pfn_tmp))
656
+ except Exception as error:
657
+ raise RSEOperationNotSupported(str(error))
658
+
659
+ # Is stat after that upload allowed?
660
+ skip_upload_stat = rse_attributes.get('skip_upload_stat', False)
661
+ self.logger(logging.DEBUG, 'skip_upload_stat=%s', skip_upload_stat)
662
+
663
+ # Checksum verification, obsolete, see Gabriele changes.
664
+ if not skip_upload_stat:
665
+ try:
666
+ stats = self._retry_protocol_stat(protocol_write, pfn_tmp)
667
+ if not isinstance(stats, dict):
668
+ raise RucioException('Could not get protocol.stats for given PFN: %s' % pfn)
669
+
670
+ # The checksum and filesize check
671
+ if ('filesize' in stats) and ('filesize' in lfn):
672
+ self.logger(logging.DEBUG, 'Filesize: Expected=%s Found=%s' % (lfn['filesize'], stats['filesize']))
673
+ if int(stats['filesize']) != int(lfn['filesize']):
674
+ raise RucioException('Filesize mismatch. Source: %s Destination: %s' % (lfn['filesize'], stats['filesize']))
675
+ if rse_settings['verify_checksum'] is not False:
676
+ if ('adler32' in stats) and ('adler32' in lfn):
677
+ self.logger(logging.DEBUG, 'Checksum: Expected=%s Found=%s' % (lfn['adler32'], stats['adler32']))
678
+ if str(stats['adler32']).lstrip('0') != str(lfn['adler32']).lstrip('0'):
679
+ raise RucioException('Checksum mismatch. Source: %s Destination: %s' % (lfn['adler32'], stats['adler32']))
680
+
681
+ except Exception as error:
682
+ raise error
683
+
684
+ # The upload finished successful and the file can be renamed
685
+ try:
686
+ if protocol_write.renaming:
687
+ logger(logging.DEBUG, 'Renaming file %s to %s' % (pfn_tmp, pfn))
688
+ protocol_write.rename(pfn_tmp, pfn)
689
+ except Exception:
690
+ raise RucioException('Unable to rename the tmp file %s.' % pfn_tmp)
691
+
692
+ protocol_write.close()
693
+
694
+ return pfn
695
+
696
+ def _retry_protocol_stat(self, protocol, pfn):
697
+ """
698
+ Try to stat file, on fail try again 1s, 2s, 4s, 8s, 16s, 32s later. Fail is all fail
699
+ :param protocol: The protocol to use to reach this file
700
+ :param pfn: Physical file name of the target for the protocol stat
701
+ """
702
+ retries = config_get_int('client', 'protocol_stat_retries', raise_exception=False, default=6)
703
+ for attempt in range(retries):
704
+ try:
705
+ self.logger(logging.DEBUG, 'stat: pfn=%s' % pfn)
706
+ stats = protocol.stat(pfn)
707
+
708
+ if int(stats['filesize']) == 0:
709
+ raise Exception('Filesize came back as 0. Potential storage race condition, need to retry.')
710
+
711
+ return stats
712
+ except RSEChecksumUnavailable as error:
713
+ # The stat succeeded here, but the checksum failed
714
+ raise error
715
+ except Exception as error:
716
+ self.logger(logging.DEBUG, 'stat: unexpected error=%s' % error)
717
+ fail_str = ['The requested service is not available at the moment', 'Permission refused']
718
+ if any(x in str(error) for x in fail_str):
719
+ raise error
720
+ self.logger(logging.DEBUG, 'stat: unknown edge case, retrying in %ss' % 2**attempt)
721
+ time.sleep(2**attempt)
722
+ return protocol.stat(pfn)
723
+
724
+ def _create_protocol(self, rse_settings, operation, impl=None, force_scheme=None, domain='wan'):
725
+ """
726
+ Protol construction.
727
+ :param rse_settings: rse_settings
728
+ :param operation: activity, e.g. read, write, delete etc.
729
+ :param force_scheme: custom scheme
730
+ :param auth_token: Optionally passing JSON Web Token (OIDC) string for authentication
731
+ """
732
+ try:
733
+ protocol = rsemgr.create_protocol(rse_settings, operation, scheme=force_scheme, domain=domain, impl=impl, auth_token=self.auth_token, logger=self.logger)
734
+ protocol.connect()
735
+ except Exception as error:
736
+ self.logger(logging.WARNING, 'Failed to create protocol for operation: %s' % operation)
737
+ self.logger(logging.DEBUG, 'scheme: %s, exception: %s' % (force_scheme, error))
738
+ raise error
739
+ return protocol
740
+
741
+ def _send_trace(self, trace):
742
+ """
743
+ Checks if sending trace is allowed and send the trace.
744
+
745
+ :param trace: the trace
746
+ """
747
+ if self.tracing:
748
+ send_trace(trace, self.client.trace_host, self.client.user_agent)
749
+
750
+ def _recursive(self, item):
751
+ """
752
+ If the --recursive flag is set, it replicates the folder structure recursively into collections
753
+ A folder only can have either other folders inside or files, but not both of them
754
+ - If it has folders, the root folder will be a container
755
+ - If it has files, the root folder will be a dataset
756
+ - If it is empty, it does not create anything
757
+
758
+ :param item: dictionary containing all descriptions of the files to upload
759
+ """
760
+ files = []
761
+ datasets = []
762
+ containers = []
763
+ attach = []
764
+ scope = item.get('did_scope') if item.get('did_scope') is not None else self.default_file_scope
765
+ rse = item.get('rse')
766
+ path = item.get('path')
767
+ if path[-1] == '/':
768
+ path = path[0:-1]
769
+ i = 0
770
+ path = os.path.abspath(path)
771
+ for root, dirs, fnames in os.walk(path):
772
+ if len(dirs) > 0 and len(fnames) > 0 and i == 0:
773
+ self.logger(logging.ERROR, 'A container can only have either collections or files, not both')
774
+ raise InputValidationError('Invalid input folder structure')
775
+ if len(fnames) > 0:
776
+ datasets.append({'scope': scope, 'name': root.split('/')[-1], 'rse': rse})
777
+ self.logger(logging.DEBUG, 'Appended dataset with DID %s:%s' % (scope, path))
778
+ for fname in fnames:
779
+ file = self._collect_file_info(os.path.join(root, fname), item)
780
+ file['dataset_scope'] = scope
781
+ file['dataset_name'] = root.split('/')[-1]
782
+ files.append(file)
783
+ self.logger(logging.DEBUG, 'Appended file with DID %s:%s' % (scope, fname))
784
+ elif len(dirs) > 0:
785
+ containers.append({'scope': scope, 'name': root.split('/')[-1]})
786
+ self.logger(logging.DEBUG, 'Appended container with DID %s:%s' % (scope, path))
787
+ attach.extend([{'scope': scope, 'name': root.split('/')[-1], 'rse': rse, 'dids': {'scope': scope, 'name': dir_}} for dir_ in dirs])
788
+ elif len(dirs) == 0 and len(fnames) == 0:
789
+ self.logger(logging.WARNING, 'The folder %s is empty, skipping' % root)
790
+ continue
791
+ i += 1
792
+ # if everything went ok, replicate the folder structure in Rucio storage
793
+ for dataset in datasets:
794
+ try:
795
+ self.client.add_dataset(scope=dataset['scope'], name=dataset['name'], rse=dataset['rse'])
796
+ self.logger(logging.INFO, 'Created dataset with DID %s:%s' % (dataset['scope'], dataset['name']))
797
+ except RucioException as error:
798
+ self.logger(logging.ERROR, error)
799
+ self.logger(logging.ERROR, 'It was not possible to create dataset with DID %s:%s' % (dataset['scope'], dataset['name']))
800
+ for container in containers:
801
+ try:
802
+ self.client.add_container(scope=container['scope'], name=container['name'])
803
+ self.logger(logging.INFO, 'Created container with DID %s:%s' % (container['scope'], container['name']))
804
+ except RucioException as error:
805
+ self.logger(logging.ERROR, error)
806
+ self.logger(logging.ERROR, 'It was not possible to create dataset with DID %s:%s' % (container['scope'], container['name']))
807
+ for att in attach:
808
+ try:
809
+ self.client.attach_dids(scope=att['scope'], name=att['name'], dids=[att['dids']])
810
+ self.logger(logging.INFO, 'DIDs attached to collection %s:%s' % (att['scope'], att['name']))
811
+ except RucioException as error:
812
+ self.logger(logging.ERROR, error)
813
+ self.logger(logging.ERROR, 'It was not possible to attach to collection with DID %s:%s' % (att['scope'], att['name']))
814
+ return files
815
+
816
+ def preferred_impl(self, rse_settings, domain):
817
+ """
818
+ Finds the optimum protocol impl preferred by the client and
819
+ supported by the remote RSE.
820
+
821
+ :param rse_settings: dictionary containing the RSE settings
822
+ :param domain: The network domain, either 'wan' (default) or 'lan'
823
+
824
+ :raises RucioException(msg): general exception with msg for more details.
825
+ """
826
+ preferred_protocols = []
827
+ supported_impl = None
828
+
829
+ try:
830
+ preferred_impls = config_get('upload', 'preferred_impl')
831
+ except Exception as error:
832
+ self.logger(logging.INFO, 'No preferred protocol impl in rucio.cfg: %s' % (error))
833
+ pass
834
+ else:
835
+ preferred_impls = list(preferred_impls.split(', '))
836
+ i = 0
837
+ while i < len(preferred_impls):
838
+ impl = preferred_impls[i]
839
+ impl_split = impl.split('.')
840
+ if len(impl_split) == 1:
841
+ preferred_impls[i] = 'rucio.rse.protocols.' + impl + '.Default'
842
+ else:
843
+ preferred_impls[i] = 'rucio.rse.protocols.' + impl
844
+ i += 1
845
+
846
+ preferred_protocols = [protocol for protocol in reversed(rse_settings['protocols']) if protocol['impl'] in preferred_impls]
847
+
848
+ if len(preferred_protocols) > 0:
849
+ preferred_protocols += [protocol for protocol in reversed(rse_settings['protocols']) if protocol not in preferred_protocols]
850
+ else:
851
+ preferred_protocols = reversed(rse_settings['protocols'])
852
+
853
+ for protocol in preferred_protocols:
854
+ if domain not in list(protocol['domains'].keys()):
855
+ self.logger(logging.DEBUG, 'Unsuitable protocol "%s": Domain %s not supported' % (protocol['impl'], domain))
856
+ continue
857
+ if not all(operations in protocol['domains'][domain] for operations in ("read", "write", "delete")):
858
+ self.logger(logging.DEBUG, 'Unsuitable protocol "%s": All operations are not supported' % (protocol['impl']))
859
+ continue
860
+ try:
861
+ supported_protocol = rsemgr.create_protocol(rse_settings, 'write', domain=domain, impl=protocol['impl'], auth_token=self.auth_token, logger=self.logger)
862
+ supported_protocol.connect()
863
+ except Exception as error:
864
+ self.logger(logging.DEBUG, 'Failed to create protocol "%s", exception: %s' % (protocol['impl'], error))
865
+ pass
866
+ else:
867
+ self.logger(logging.INFO, 'Preferred protocol impl supported locally and remotely: %s' % (protocol['impl']))
868
+ supported_impl = protocol['impl']
869
+ break
870
+
871
+ return supported_impl