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,2447 @@
1
+ #!python
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 argparse
17
+ import datetime
18
+ import errno
19
+ import json
20
+ import logging
21
+ import math
22
+ import os
23
+ import signal
24
+ import sys
25
+ import time
26
+ import traceback
27
+ from configparser import NoOptionError, NoSectionError
28
+ from functools import wraps
29
+ from textwrap import dedent
30
+
31
+ from tabulate import tabulate
32
+
33
+ from rucio import version
34
+ from rucio.client import Client
35
+ from rucio.common.config import config_get
36
+ from rucio.common.constants import RseAttr
37
+ from rucio.common.exception import (
38
+ AccessDenied,
39
+ AccountNotFound,
40
+ CannotAuthenticate,
41
+ ConfigNotFound,
42
+ DataIdentifierAlreadyExists,
43
+ DataIdentifierNotFound,
44
+ Duplicate,
45
+ DuplicateContent,
46
+ InputValidationError,
47
+ InvalidObject,
48
+ InvalidRSEExpression,
49
+ ReplicaIsLocked,
50
+ ReplicaNotFound,
51
+ RSENotFound,
52
+ RSEOperationNotSupported,
53
+ RuleNotFound,
54
+ ScopeNotFound,
55
+ )
56
+ from rucio.common.extra import import_extras
57
+ from rucio.common.utils import StoreAndDeprecateWarningAction, chunks, clean_pfns, construct_non_deterministic_pfn, extract_scope, get_bytes_value_from_string, parse_response, render_json, sizefmt
58
+ from rucio.rse import rsemanager as rsemgr
59
+
60
+ EXTRA_MODULES = import_extras(['argcomplete'])
61
+
62
+ if EXTRA_MODULES['argcomplete']:
63
+ import argcomplete # pylint: disable=E0401
64
+
65
+ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
66
+ os.pardir, os.pardir))
67
+ if os.path.exists(os.path.join(possible_topdir, 'lib/rucio', '__init__.py')):
68
+ sys.path.insert(0, possible_topdir)
69
+
70
+ SUCCESS = 0
71
+ FAILURE = 1
72
+ DEFAULT_PORT = 443
73
+
74
+ logger = logging.getLogger("user")
75
+
76
+ tablefmt = 'psql'
77
+
78
+
79
+ def setup_logger(logger):
80
+ logger.setLevel(logging.DEBUG)
81
+ hdlr = logging.StreamHandler()
82
+
83
+ def emit_decorator(fcn):
84
+ def func(*args):
85
+ formatter = logging.Formatter("%(message)s")
86
+ hdlr.setFormatter(formatter)
87
+ return fcn(*args)
88
+ return func
89
+ hdlr.emit = emit_decorator(hdlr.emit)
90
+ logger.addHandler(hdlr)
91
+
92
+
93
+ setup_logger(logger)
94
+
95
+
96
+ def signal_handler(signal, frame):
97
+ logger.warning('You pressed Ctrl+C! Exiting gracefully')
98
+ sys.exit(1)
99
+
100
+
101
+ signal.signal(signal.SIGINT, signal_handler)
102
+
103
+
104
+ def exception_handler(function):
105
+ @wraps(function)
106
+ def new_funct(*args, **kwargs):
107
+ try:
108
+ return function(*args, **kwargs)
109
+ except InvalidObject as error:
110
+ logger.error(error)
111
+ return error.error_code
112
+ except DataIdentifierNotFound as error:
113
+ logger.error(error)
114
+ logger.debug('This means that the Data IDentifier you provided is not known by Rucio.')
115
+ return error.error_code
116
+ except AccessDenied as error:
117
+ logger.error(error)
118
+ logger.debug('This error is a permission issue. You cannot run this command with your account.')
119
+ return error.error_code
120
+ except DataIdentifierAlreadyExists as error:
121
+ logger.error(error)
122
+ logger.debug('This means that the data IDentifier you try to add is already registered in Rucio.')
123
+ return error.error_code
124
+ except RSENotFound as error:
125
+ logger.error(error)
126
+ logger.debug('This means that the Rucio Storage Element you provided is not known by Rucio.')
127
+ return error.error_code
128
+ except InvalidRSEExpression as error:
129
+ logger.error(error)
130
+ logger.debug('This means the RSE expression you provided is not syntactically correct.')
131
+ return error.error_code
132
+ except DuplicateContent as error:
133
+ logger.error(error)
134
+ logger.debug('This means that the DID you want to attach is already in the target DID.')
135
+ return error.error_code
136
+ except TypeError as error:
137
+ logger.error(error)
138
+ logger.debug('This means the parameter you passed has a wrong type.')
139
+ return FAILURE
140
+ except RuleNotFound as error:
141
+ logger.error(error)
142
+ logger.debug('This means the rule you specified does not exist.')
143
+ return error.error_code
144
+ except AccountNotFound as error:
145
+ logger.error(error)
146
+ logger.debug('This means that the specified account cannot be found.')
147
+ return error.error_code
148
+ except NotImplementedError as error:
149
+ logger.error(error)
150
+ logger.debug('This means that the method is not implemented yet.')
151
+ return FAILURE
152
+ except Duplicate as error:
153
+ logger.error(error)
154
+ logger.debug('This means that you are trying to add something that already exists.')
155
+ return error.error_code
156
+ except ReplicaIsLocked as error:
157
+ logger.error(error)
158
+ logger.error('This means that the replica has a lock and is therefore protected.')
159
+ return FAILURE
160
+ except ReplicaNotFound as error:
161
+ logger.error(error)
162
+ logger.error('This means that the replica does not exist.')
163
+ return FAILURE
164
+ except ConfigNotFound as error:
165
+ logger.error(error)
166
+ logger.error('This means that the configuration section you are looking for does not exist.')
167
+ return FAILURE
168
+ except ScopeNotFound as error:
169
+ logger.error(error)
170
+ logger.error('This means that no scopes were found for the specified account ID.')
171
+ return FAILURE
172
+ except InputValidationError as error:
173
+ logger.error(error)
174
+ logger.error('This means that the input you provided did not meet all the requirements.')
175
+ return FAILURE
176
+ except Exception as error:
177
+ if isinstance(error, IOError) and getattr(error, 'errno', None) == errno.EPIPE:
178
+ # Ignore Broken Pipe
179
+ # While in python3 we can directly catch 'BrokenPipeError', in python2 it doesn't exist.
180
+
181
+ # Python flushes standard streams on exit; redirect remaining output
182
+ # to devnull to avoid another BrokenPipeError at shutdown
183
+ devnull = os.open(os.devnull, os.O_WRONLY)
184
+ os.dup2(devnull, sys.stdout.fileno())
185
+ return SUCCESS
186
+ logger.error(error)
187
+ logger.error('Rucio exited with an unexpected/unknown error, please provide the traceback below to the developers.')
188
+ logger.debug(traceback.format_exc())
189
+ return FAILURE
190
+ return new_funct
191
+
192
+
193
+ def get_client(args):
194
+ """
195
+ Returns a new client object.
196
+ """
197
+ if not args.auth_strategy:
198
+ if 'RUCIO_AUTH_TYPE' in os.environ:
199
+ auth_type = os.environ['RUCIO_AUTH_TYPE'].lower()
200
+ else:
201
+ try:
202
+ auth_type = config_get('client', 'auth_type').lower()
203
+ except (NoOptionError, NoSectionError):
204
+ logger.error('Cannot get AUTH_TYPE')
205
+ sys.exit(FAILURE)
206
+ else:
207
+ auth_type = args.auth_strategy.lower()
208
+
209
+ if auth_type in ['userpass', 'saml'] and args.username is not None and args.password is not None:
210
+ creds = {'username': args.username, 'password': args.password}
211
+ elif auth_type == 'oidc':
212
+ if args.oidc_issuer:
213
+ args.oidc_issuer = args.oidc_issuer.lower()
214
+ creds = {'oidc_auto': args.oidc_auto,
215
+ 'oidc_scope': args.oidc_scope,
216
+ 'oidc_audience': args.oidc_audience,
217
+ 'oidc_polling': args.oidc_polling,
218
+ 'oidc_refresh_lifetime': args.oidc_refresh_lifetime,
219
+ 'oidc_issuer': args.oidc_issuer,
220
+ 'oidc_username': args.oidc_username,
221
+ 'oidc_password': args.oidc_password}
222
+ else:
223
+ creds = None
224
+
225
+ try:
226
+ client = Client(rucio_host=args.host, auth_host=args.auth_host,
227
+ account=args.issuer,
228
+ auth_type=auth_type, creds=creds,
229
+ ca_cert=args.ca_certificate, timeout=args.timeout, vo=args.vo)
230
+ except CannotAuthenticate as error:
231
+ logger.error(error)
232
+ if 'alert certificate expired' in str(error):
233
+ logger.error('The server certificate expired.')
234
+ elif auth_type.lower() == 'x509_proxy':
235
+ logger.error('Please verify that your proxy is still valid and renew it if needed.')
236
+ sys.exit(FAILURE)
237
+ return client
238
+
239
+
240
+ def get_scope(did, client):
241
+ try:
242
+ scope, name = extract_scope(did)
243
+ return scope, name
244
+ except TypeError:
245
+ scopes = client.list_scopes()
246
+ scope, name = extract_scope(did, scopes)
247
+ return scope, name
248
+ return None, did
249
+
250
+
251
+ @exception_handler
252
+ def add_account(args):
253
+ """
254
+ %(prog)s add [options] <field1=value1 field2=value2 ...>
255
+
256
+ Adds a new account. Specify metadata fields as arguments.
257
+
258
+ """
259
+ client = get_client(args)
260
+ client.add_account(account=args.account, type_=args.accounttype, email=args.accountemail)
261
+ print('Added new account: %s' % args.account)
262
+ return SUCCESS
263
+
264
+
265
+ @exception_handler
266
+ def delete_account(args):
267
+ """
268
+ %(prog)s disable [options] <field1=value1 field2=value2 ...>
269
+
270
+ Delete account.
271
+
272
+ """
273
+ client = get_client(args)
274
+ client.delete_account(args.acnt)
275
+ print('Deleted account: %s' % args.acnt)
276
+ return SUCCESS
277
+
278
+
279
+ @exception_handler
280
+ def update_account(args):
281
+ """
282
+ %(prog)s update [options] <field1=value1 field2=value2 ...>
283
+
284
+ Update an account.
285
+
286
+ """
287
+ client = get_client(args)
288
+ client.update_account(account=args.account, key=args.key, value=args.value)
289
+ print('%s of account %s changed to %s' % (args.key, args.account, args.value))
290
+ return SUCCESS
291
+
292
+
293
+ @exception_handler
294
+ def ban_account(args):
295
+ """
296
+ %(prog)s ban [options] <field1=value1 field2=value2 ...>
297
+
298
+ Ban an account.
299
+
300
+ """
301
+ client = get_client(args)
302
+ client.update_account(account=args.account, key='status', value='SUSPENDED')
303
+ print('Account %s banned' % args.account)
304
+ return SUCCESS
305
+
306
+
307
+ @exception_handler
308
+ def unban_account(args):
309
+ """
310
+ %(prog)s unban [options] <field1=value1 field2=value2 ...>
311
+
312
+ Unban a banned account.
313
+
314
+ """
315
+ client = get_client(args)
316
+ client.update_account(account=args.account, key='status', value='ACTIVE')
317
+ print('Account %s unbanned' % args.account)
318
+ return SUCCESS
319
+
320
+
321
+ @exception_handler
322
+ def list_accounts(args):
323
+ """
324
+ %(prog)s list [options] <field1=value1 field2=value2 ...>
325
+
326
+ List accounts.
327
+
328
+ """
329
+ client = get_client(args)
330
+ filters = {}
331
+ if args.filters:
332
+ for key, value in [(_.split('=')[0], _.split('=')[1]) for _ in args.filters.split(',')]:
333
+ filters[key] = value
334
+ accounts = client.list_accounts(identity=args.identity, account_type=args.account_type, filters=filters)
335
+ for account in accounts:
336
+ print(account['account'])
337
+ return SUCCESS
338
+
339
+
340
+ @exception_handler
341
+ def info_account(args):
342
+ """
343
+ %(prog)s show [options] <field1=value1 field2=value2 ...>
344
+
345
+ Show extended information of a given account
346
+
347
+ """
348
+ client = get_client(args)
349
+ info = client.get_account(account=args.account)
350
+ for k in info:
351
+ print(k.ljust(10) + ' : ' + str(info[k]))
352
+ return SUCCESS
353
+
354
+
355
+ @exception_handler
356
+ def list_identities(args):
357
+ """
358
+ %(prog)s list-identities [options] <field1=value1 field2=value2 ...>
359
+
360
+ List all identities on an account.
361
+ """
362
+ client = get_client(args)
363
+ identities = client.list_identities(account=args.account)
364
+ for identity in identities:
365
+ print('Identity: %(identity)s,\ttype: %(type)s' % identity)
366
+ return SUCCESS
367
+
368
+
369
+ @exception_handler
370
+ def set_limits(args):
371
+ """
372
+ %(prog)s set [options] <field1=value1 field2=value2 ...>
373
+
374
+ Set account limit for an account and rse.
375
+ """
376
+ client = get_client(args)
377
+ locality = args.locality.lower()
378
+ byte_limit = None
379
+ limit_input = args.bytes.lower()
380
+
381
+ if limit_input == 'inf' or limit_input == 'infinity':
382
+ byte_limit = -1
383
+ else:
384
+ byte_limit = get_bytes_value_from_string(limit_input)
385
+ if not byte_limit:
386
+ try:
387
+ byte_limit = int(limit_input)
388
+ except ValueError:
389
+ logger.error('The limit could not be set. Either you misspelled infinity or your input could not be converted to integer or you used a wrong pattern. Please use a format like 10GB with B,KB,MB,GB,TB,PB as units (not case sensitive)')
390
+ return FAILURE
391
+
392
+ client.set_account_limit(account=args.account, rse=args.rse, bytes_=byte_limit, locality=locality)
393
+ print('Set account limit for account %s on RSE %s: %s' % (args.account, args.rse, sizefmt(byte_limit, True)))
394
+ return SUCCESS
395
+
396
+
397
+ @exception_handler
398
+ def get_limits(args):
399
+ """
400
+ %(prog)s get-limits [options] <field1=value1 field2=value2 ...>
401
+
402
+ Grant an identity access to an account.
403
+
404
+ """
405
+ client = get_client(args)
406
+ locality = args.locality.lower()
407
+ limits = client.get_account_limits(account=args.account, rse_expression=args.rse, locality=locality)
408
+ for rse in limits:
409
+ print('Quota on %s for %s : %s' % (rse, args.account, sizefmt(limits[rse], True)))
410
+ return SUCCESS
411
+
412
+
413
+ @exception_handler
414
+ def delete_limits(args):
415
+ """
416
+ %(prog)s delete [options] <field1=value1 field2=value2 ...>
417
+
418
+ Delete account limit for an account and rse.
419
+ """
420
+ client = get_client(args)
421
+ client.delete_account_limit(account=args.account, rse=args.rse, locality=args.locality)
422
+ print('Deleted account limit for account %s and RSE %s' % (args.account, args.rse))
423
+ return SUCCESS
424
+
425
+
426
+ @exception_handler
427
+ def identity_add(args):
428
+ """
429
+ %(prog)s del [options] <field1=value1 field2=value2 ...>
430
+
431
+ Grant an identity access to an account.
432
+
433
+ """
434
+ client = get_client(args)
435
+ if args.email == "":
436
+ logger.error('Error: --email argument can\'t be an empty string. Failed to grant an identity access to an account')
437
+ return FAILURE
438
+
439
+ if args.authtype == 'USERPASS' and not args.password:
440
+ logger.error('missing --password argument')
441
+ return FAILURE
442
+
443
+ client.add_identity(account=args.account, identity=args.identity, authtype=args.authtype, email=args.email, password=args.password)
444
+ print('Added new identity to account: %s-%s' % (args.identity, args.account))
445
+ return SUCCESS
446
+
447
+
448
+ @exception_handler
449
+ def identity_delete(args):
450
+ """
451
+ %(prog)s delete [options] <field1=value1 field2=value2 ...>
452
+
453
+ Revoke an identity's access to an account.
454
+
455
+ """
456
+ client = get_client(args)
457
+ client.del_identity(args.account, args.identity, authtype=args.authtype)
458
+ print('Deleted identity: %s' % args.identity)
459
+ return SUCCESS
460
+
461
+
462
+ @exception_handler
463
+ def add_rse(args):
464
+ """
465
+ %(prog)s add [options] <field1=value1 field2=value2 ...>
466
+
467
+ Adds a new RSE. Specify metadata fields as arguments.
468
+
469
+ """
470
+ client = get_client(args)
471
+ client.add_rse(args.rse, deterministic=not args.non_deterministic)
472
+ print('Added new %sdeterministic RSE: %s' % ('non-' if args.non_deterministic else '', args.rse))
473
+ return SUCCESS
474
+
475
+
476
+ @exception_handler
477
+ def disable_rse(args):
478
+ """
479
+ %(prog)s del [options] <field1=value1 field2=value2 ...>
480
+
481
+ Disable RSE.
482
+
483
+ """
484
+ client = get_client(args)
485
+ client.delete_rse(args.rse)
486
+ return SUCCESS
487
+
488
+
489
+ @exception_handler
490
+ def list_rses(args):
491
+ """
492
+ %(prog)s list [options] <field1=value1 field2=value2 ...>
493
+
494
+ List RSEs.
495
+
496
+ """
497
+ client = get_client(args)
498
+ rses = client.list_rses()
499
+ for rse in rses:
500
+ print('%(rse)s' % rse)
501
+ return SUCCESS
502
+
503
+
504
+ @exception_handler
505
+ def update_rse(args):
506
+ """
507
+ %(prog)s update [options] <field1=value1 field2=value2 ...>
508
+
509
+ Update the settings of the RSE:
510
+ deterministic, rse_type, staging_are, volatile, qos_class,
511
+ availability_delete, availability_read, availability_write,
512
+ city, country_name, latitude, longitude, region_code, time_zone
513
+
514
+ Use '', 'None' or 'null' to wipe the value of following RSE settings:
515
+ qos_class
516
+ """
517
+ client = get_client(args)
518
+ if args.value in ['true', 'True', 'TRUE', '1']:
519
+ args.value = True
520
+ if args.value in ['false', 'False', 'FALSE', '0']:
521
+ args.value = False
522
+ params = {args.param: args.value}
523
+ client.update_rse(args.rse, parameters=params)
524
+
525
+ if isinstance(args.value, bool):
526
+ args.value = str(args.value)
527
+
528
+ print('Updated RSE %s settings %s to %s' % (args.rse, args.param, args.value if args.value.lower() not in ['', 'none', 'null'] else '[WIPED]'))
529
+ return SUCCESS
530
+
531
+
532
+ @exception_handler
533
+ def info_rse(args):
534
+ """
535
+ %(prog)s info [options] <field1=value1 field2=value2 ...>
536
+
537
+ Show extended information of a given RSE
538
+
539
+ """
540
+ client = get_client(args)
541
+ rseinfo = client.get_rse(rse=args.rse)
542
+ attributes = client.list_rse_attributes(rse=args.rse)
543
+ usage = client.get_rse_usage(rse=args.rse)
544
+ rse_limits = client.get_rse_limits(args.rse)
545
+ print('Settings:')
546
+ print('=========')
547
+ for key in sorted(rseinfo):
548
+ if key != 'protocols':
549
+ print(' ' + key + ': ' + str(rseinfo[key]))
550
+ print('Attributes:')
551
+ print('===========')
552
+ for attribute in sorted(attributes):
553
+ print(' ' + attribute + ': ' + str(attributes[attribute]))
554
+ print('Protocols:')
555
+ print('==========')
556
+ for protocol in sorted(rseinfo['protocols'], key=lambda x: x['scheme']):
557
+ print(' ' + protocol['scheme'])
558
+ for item in sorted(protocol):
559
+ if item == 'domains':
560
+ print(' ' + item + ': \'' + json.dumps(protocol[item]) + '\'')
561
+ else:
562
+ print(' ' + item + ': ' + str(protocol[item]))
563
+ print('Usage:')
564
+ print('======')
565
+ for elem in sorted(usage, key=lambda x: x['source']):
566
+ print(' ' + elem['source'])
567
+ for item in sorted(elem):
568
+ print(' ' + item + ': ' + str(elem[item]))
569
+ print('RSE limits:')
570
+ print('===========')
571
+ for limit in rse_limits:
572
+ print(' ' + limit + ': ' + str(rse_limits[limit]) + ' B')
573
+
574
+ return SUCCESS
575
+
576
+
577
+ @exception_handler
578
+ def set_attribute_rse(args):
579
+ """
580
+ %(prog)s set-attribute [options] <field1=value1 field2=value2 ...>
581
+
582
+ Set RSE attributes.
583
+
584
+ """
585
+ client = get_client(args)
586
+ client.add_rse_attribute(rse=args.rse, key=args.key, value=args.value)
587
+ print('Added new RSE attribute for %s: %s-%s ' % (args.rse, args.key, args.value))
588
+ return SUCCESS
589
+
590
+
591
+ @exception_handler
592
+ def get_attribute_rse(args):
593
+ """
594
+ %(prog)s get-attribute [options] <field1=value1 field2=value2 ...>
595
+
596
+ Get RSE attributes.
597
+
598
+ """
599
+ client = get_client(args)
600
+ attributes = client.list_rse_attributes(rse=args.rse)
601
+ for k in attributes:
602
+ print(k + ': ' + str(attributes[k]))
603
+
604
+ return SUCCESS
605
+
606
+
607
+ @exception_handler
608
+ def delete_attribute_rse(args):
609
+ """
610
+ %(prog)s delete-attribute [options] <field1=value1 field2=value2 ...>
611
+
612
+ Delete RSE attributes.
613
+
614
+ """
615
+ client = get_client(args)
616
+ client.delete_rse_attribute(rse=args.rse, key=args.key)
617
+ print('Deleted RSE attribute for %s: %s-%s ' % (args.rse, args.key, args.value))
618
+ return SUCCESS
619
+
620
+
621
+ @exception_handler
622
+ def add_distance_rses(args):
623
+ """
624
+ %(prog)s add-distance [options] SOURCE_RSE DEST_RSE
625
+
626
+ Set the distance between two RSEs.
627
+ """
628
+ client = get_client(args)
629
+ params = {'distance': args.distance}
630
+ client.add_distance(args.source, args.destination, params)
631
+ print('Set distance from %s to %s to %d' % (args.source, args.destination, args.distance))
632
+ return SUCCESS
633
+
634
+
635
+ @exception_handler
636
+ def get_distance_rses(args):
637
+ """
638
+ %(prog)s get-distance SOURCE_RSE DEST_RSE
639
+
640
+ Retrieve the existing distance information between two RSEs.
641
+ """
642
+ client = get_client(args)
643
+ distance_info = client.get_distance(args.source, args.destination)
644
+ if distance_info:
645
+ print('Distance information from %s to %s: distance=%d' % (args.source, args.destination, distance_info[0]['distance']))
646
+ else:
647
+ print("No distance set from %s to %s" % (args.source, args.destination))
648
+ return SUCCESS
649
+
650
+
651
+ @exception_handler
652
+ def update_distance_rses(args):
653
+ """
654
+ %(prog)s update-distance [options] SOURCE_RSE DEST_RSE
655
+
656
+ Update the existing distance entry between two RSEs.
657
+ """
658
+ client = get_client(args)
659
+ params = {}
660
+ if args.distance is not None:
661
+ params['distance'] = args.distance
662
+ elif args.ranking is not None:
663
+ params['distance'] = args.ranking
664
+ client.update_distance(args.source, args.destination, params)
665
+ print('Update distance information from %s to %s:' % (args.source, args.destination))
666
+ if params.get('distance') is not None:
667
+ print("- Distance set to %d" % params['distance'])
668
+ return SUCCESS
669
+
670
+
671
+ @exception_handler
672
+ def delete_distance_rses(args):
673
+ """
674
+ %(prog)s delete-distance [options] SOURCE_RSE DEST_RSE
675
+
676
+ Update the existing distance entry between two RSEs.
677
+ """
678
+ client = get_client(args)
679
+ client.delete_distance(args.source, args.destination)
680
+ print('Deleted distance information from %s to %s.' % (args.source, args.destination))
681
+ return SUCCESS
682
+
683
+
684
+ @exception_handler
685
+ def add_protocol_rse(args):
686
+ """
687
+ %(prog)s add-protocol-rse [options] <rse>
688
+
689
+ Add a new protocol handler for an RSE
690
+ """
691
+ client = get_client(args)
692
+ proto = {'hostname': args.hostname,
693
+ 'scheme': args.scheme,
694
+ 'port': args.port,
695
+ 'impl': args.impl,
696
+ 'prefix': args.prefix}
697
+ if args.domain_json:
698
+ proto['domains'] = args.domain_json
699
+ proto.setdefault('extended_attributes', {})
700
+ if args.ext_attr_json:
701
+ proto['extended_attributes'] = args.ext_attr_json
702
+ if proto['scheme'] == 'srm' and not args.web_service_path:
703
+ print('Error: space-token and web-service-path must be provided for SRM endpoints.')
704
+ return FAILURE
705
+ if args.space_token:
706
+ proto['extended_attributes']['space_token'] = args.space_token
707
+ if args.web_service_path:
708
+ proto['extended_attributes']['web_service_path'] = args.web_service_path
709
+ # Rucio 1.14.1 chokes on an empty extended_attributes key.
710
+ if not proto['extended_attributes']:
711
+ del proto['extended_attributes']
712
+ client.add_protocol(args.rse, proto)
713
+ return SUCCESS
714
+
715
+
716
+ @exception_handler
717
+ def del_protocol_rse(args):
718
+ """
719
+ %(prog)s delete-protocol-rse [options] <rse>
720
+
721
+ Remove a protocol handler for a RSE
722
+ """
723
+ client = get_client(args)
724
+ kwargs = {}
725
+ if args.port:
726
+ kwargs['port'] = args.port
727
+ if args.hostname:
728
+ kwargs['hostname'] = args.hostname
729
+ client.delete_protocols(args.rse, args.scheme, **kwargs)
730
+
731
+
732
+ @exception_handler
733
+ def add_qos_policy(args):
734
+ """
735
+ %(prog)s add-qos-policy <rse> <qos_policy>
736
+
737
+ Add a QoS policy to an RSE.
738
+ """
739
+ client = get_client(args)
740
+ client.add_qos_policy(args.rse, args.qos_policy)
741
+ print('Added QoS policy to RSE %s: %s' % (args.rse, args.qos_policy))
742
+ return SUCCESS
743
+
744
+
745
+ @exception_handler
746
+ def delete_qos_policy(args):
747
+ """
748
+ %(prog)s delete-qos-policy <rse> <qos_policy>
749
+
750
+ Delete a QoS policy from an RSE.
751
+ """
752
+ client = get_client(args)
753
+ client.delete_qos_policy(args.rse, args.qos_policy)
754
+ print('Deleted QoS policy from RSE %s: %s' % (args.rse, args.qos_policy))
755
+ return SUCCESS
756
+
757
+
758
+ @exception_handler
759
+ def list_qos_policies(args):
760
+ """
761
+ %(prog)s list-qos-policies <rse>
762
+
763
+ List all QoS policies of an RSE.
764
+ """
765
+ client = get_client(args)
766
+ qos_policies = client.list_qos_policies(args.rse)
767
+ for qos_policy in sorted(qos_policies):
768
+ print(qos_policy)
769
+ return SUCCESS
770
+
771
+
772
+ @exception_handler
773
+ def set_limit_rse(args):
774
+ """
775
+ %(prog)s set-limit <rse> <name> <value>
776
+
777
+ Set the RSE limit given the rse name and the name and value of the limit
778
+ """
779
+ client = get_client(args)
780
+ try:
781
+ args.value = int(args.value)
782
+ if client.set_rse_limits(args.rse, args.name, args.value):
783
+ logger.info('Set RSE limit successfully for %s: %s = %s' % (args.rse, args.name, args.value))
784
+ except ValueError:
785
+ logger.error('The RSE limit value must be an integer')
786
+
787
+ return SUCCESS
788
+
789
+
790
+ @exception_handler
791
+ def delete_limit_rse(args):
792
+ """
793
+ %(prog)s delete-limit <rse> <name>
794
+
795
+ Delete the RSE limit given the rse name and the name of the limit
796
+ """
797
+ client = get_client(args)
798
+ limits = client.get_rse_limits(args.rse)
799
+ if args.name not in limits.keys():
800
+ logger.error('Limit %s not defined in RSE %s' % (args.name, args.rse))
801
+ else:
802
+ if client.delete_rse_limits(args.rse, args.name):
803
+ logger.info('Deleted RSE limit successfully for %s: %s' % (args.rse, args.name))
804
+
805
+ return SUCCESS
806
+
807
+
808
+ @exception_handler
809
+ def add_scope(args):
810
+ """
811
+ %(prog)s add [options] <field1=value1 field2=value2 ...>
812
+
813
+ Add scope.
814
+
815
+ """
816
+ client = get_client(args)
817
+ client.add_scope(account=args.account, scope=args.scope)
818
+ print('Added new scope to account: %s-%s' % (args.scope, args.account))
819
+ return SUCCESS
820
+
821
+
822
+ @exception_handler
823
+ def list_scopes(args):
824
+ """
825
+ %(prog)s list [options] <field1=value1 field2=value2 ...>
826
+
827
+ List scopes.
828
+
829
+ """
830
+ client = get_client(args)
831
+ if args.account:
832
+ scopes = client.list_scopes_for_account(args.account)
833
+ else:
834
+ scopes = client.list_scopes()
835
+ for scope in scopes:
836
+ if 'mock' not in scope:
837
+ print(scope)
838
+ return SUCCESS
839
+
840
+
841
+ @exception_handler
842
+ def get_config(args):
843
+ """
844
+ %(prog)s get [options] <field1=value1 field2=value2 ...>
845
+
846
+ Get the configuration. Either everything, or matching the given section/option.
847
+ """
848
+ client = get_client(args)
849
+ res = client.get_config(section=args.section, option=args.option)
850
+ if not isinstance(res, dict):
851
+ print('[%s]\n%s=%s' % (args.section, args.option, str(res)))
852
+ else:
853
+ print_header = True
854
+ for i in list(res.keys()):
855
+ if print_header:
856
+ if args.section is not None:
857
+ print('[%s]' % args.section)
858
+ else:
859
+ print('[%s]' % i)
860
+ if not isinstance(res[i], dict):
861
+ print('%s=%s' % (i, str(res[i])))
862
+ print_header = False
863
+ else:
864
+ for j in list(res[i].keys()):
865
+ print('%s=%s' % (j, str(res[i][j])))
866
+ return SUCCESS
867
+
868
+
869
+ @exception_handler
870
+ def set_config_option(args):
871
+ """
872
+ %(prog)s set [options] <field1=value1 field2=value2 ...>
873
+
874
+ Set the configuration value for a matching section/option. Missing section/option will be created.
875
+ """
876
+ client = get_client(args)
877
+ client.set_config_option(section=args.section, option=args.option, value=args.value)
878
+ print('Set configuration: %s.%s=%s' % (args.section, args.option, args.value))
879
+ return SUCCESS
880
+
881
+
882
+ @exception_handler
883
+ def delete_config_option(args):
884
+ """
885
+ %(prog)s delete [options] <field1=value1 field2=value2 ...>
886
+
887
+ Delete a configuration option from a section
888
+ """
889
+ client = get_client(args)
890
+ if client.delete_config_option(section=args.section, option=args.option):
891
+ print('Deleted section \'%s\' option \'%s\'' % (args.section, args.option))
892
+ else:
893
+ print('Section \'%s\' option \'%s\' not found' % (args.section, args.option))
894
+ return SUCCESS
895
+
896
+
897
+ @exception_handler
898
+ def add_subscription(args):
899
+ """
900
+ %(prog)s add [options] name Filter replication_rules
901
+
902
+ Add subscription.
903
+
904
+ """
905
+ client = get_client(args)
906
+ if args.subs_account:
907
+ account = args.subs_account
908
+ elif args.issuer:
909
+ account = args.issuer
910
+ else:
911
+ account = client.account
912
+ subscription_id = client.add_subscription(name=args.name, account=account, filter_=json.loads(args.filter), replication_rules=json.loads(args.replication_rules),
913
+ comments=args.comments, lifetime=args.lifetime, retroactive=False, dry_run=False, priority=args.priority)
914
+ print('Subscription added %s' % (subscription_id))
915
+ return SUCCESS
916
+
917
+
918
+ @exception_handler
919
+ def list_subscriptions(args):
920
+ """
921
+ %(prog)s list [options] [name]
922
+
923
+ List subscriptions.
924
+
925
+ """
926
+ client = get_client(args)
927
+ if args.subs_account:
928
+ account = args.subs_account
929
+ elif args.issuer:
930
+ account = args.issuer
931
+ else:
932
+ account = client.account
933
+ subs = client.list_subscriptions(name=args.name, account=account)
934
+ for sub in subs:
935
+ if args.long:
936
+ print('\n'.join('%s: %s' % (str(k), str(v)) for (k, v) in list(sub.items())))
937
+ print()
938
+ else:
939
+ print("%s: %s %s\n priority: %s\n filter: %s\n rules: %s\n comments: %s" % (sub['account'], sub['name'], sub['state'], sub['policyid'], sub['filter'], sub['replication_rules'], sub.get('comments', '')))
940
+ return SUCCESS
941
+
942
+
943
+ @exception_handler
944
+ def update_subscription(args):
945
+ """
946
+ %(prog)s update [options] name filter replication_rules
947
+
948
+ Update a subscription.
949
+
950
+ """
951
+ client = get_client(args)
952
+ if args.subs_account:
953
+ account = args.subs_account
954
+ elif args.issuer:
955
+ account = args.issuer
956
+ else:
957
+ account = client.account
958
+ client.update_subscription(name=args.name, account=account, filter_=json.loads(args.filter), replication_rules=json.loads(args.replication_rules),
959
+ comments=args.comments, lifetime=args.lifetime, retroactive=False, dry_run=False, priority=args.priority)
960
+ return SUCCESS
961
+
962
+
963
+ @exception_handler
964
+ def reevaluate_did_for_subscription(args):
965
+ """
966
+ %(prog)s reevaulate [options] dids
967
+
968
+ Reevaluate a list of DIDs against all active subscriptions.
969
+
970
+ """
971
+ client = get_client(args)
972
+ for did in args.dids.split(','):
973
+ scope, name = get_scope(did, client)
974
+ client.set_metadata(scope, name, 'is_new', True)
975
+ return SUCCESS
976
+
977
+
978
+ @exception_handler
979
+ def list_account_attributes(args):
980
+ """
981
+ %(prog)s show [options] <field1=value1 field2=value2 ...>
982
+
983
+ List the attributes for an account.
984
+
985
+ """
986
+ client = get_client(args)
987
+ account = args.account or client.account
988
+ attributes = next(client.list_account_attributes(account))
989
+ table = []
990
+ for attr in attributes:
991
+ table.append([attr['key'], attr['value']])
992
+ print(tabulate(table, tablefmt=tablefmt, headers=['Key', 'Value']))
993
+ return SUCCESS
994
+
995
+
996
+ @exception_handler
997
+ def add_account_attribute(args):
998
+ """
999
+ %(prog)s show [options] <field1=value1 field2=value2 ...>
1000
+
1001
+ Add attribute for an account.
1002
+
1003
+ """
1004
+ client = get_client(args)
1005
+ client.add_account_attribute(account=args.account, key=args.key, value=args.value)
1006
+ return SUCCESS
1007
+
1008
+
1009
+ @exception_handler
1010
+ def delete_account_attribute(args):
1011
+ """
1012
+ %(prog)s show [options] <field1=value1 field2=value2 ...>
1013
+
1014
+ Delete attribute for an account.
1015
+
1016
+ """
1017
+ client = get_client(args)
1018
+ client.delete_account_attribute(account=args.account, key=args.key)
1019
+ return SUCCESS
1020
+
1021
+
1022
+ @exception_handler
1023
+ def quarantine_replicas(args):
1024
+ """
1025
+ %(prog)s quarantine --rse <rse> (--paths <file with replica paths>|<path> ...)
1026
+ Quarantine replicas
1027
+ """
1028
+ client = get_client(args)
1029
+ chunk = []
1030
+
1031
+ # send requests in chunks
1032
+ chunk_size = 1000
1033
+
1034
+ rse = args.rse
1035
+ if args.paths_list:
1036
+ replicas_list = args.paths_list
1037
+ else:
1038
+ replicas_list = open(args.paths_file, "r") # will iterate over file lines
1039
+
1040
+ for line in replicas_list:
1041
+ path = line.strip()
1042
+ if path: # skip blank lines
1043
+ chunk.append(dict(path=path))
1044
+ if len(chunk) >= chunk_size:
1045
+ client.quarantine_replicas(chunk, rse=rse)
1046
+ chunk = []
1047
+ if chunk:
1048
+ client.quarantine_replicas(chunk, rse=rse)
1049
+ return SUCCESS
1050
+
1051
+
1052
+ def __declare_bad_file_replicas_by_lfns(args: object) -> object:
1053
+ """
1054
+ Declare a list of bad replicas using RSE name, scope and list of LFNs.
1055
+ """
1056
+ if not args.scope or not args.rse:
1057
+ print("--lfns requires using --rse and --scope")
1058
+ return FAILURE
1059
+ reason = args.reason
1060
+ scope = args.scope
1061
+ rse = args.rse
1062
+ client = get_client(args)
1063
+ replicas = []
1064
+
1065
+ # send requests in chunks
1066
+ chunk_size = 10000
1067
+
1068
+ def do_declare(client, lst, reason):
1069
+ non_declared = client.declare_bad_file_replicas(lst, reason)
1070
+ for rse, undeclared in non_declared.items():
1071
+ for r in undeclared:
1072
+ print(f'{rse} : replica cannot be declared: {r}')
1073
+
1074
+ for line in open(args.lfns, "r"):
1075
+ lfn = line.strip()
1076
+ if lfn:
1077
+ replicas.append({"scope": scope, "rse": rse, "name": lfn})
1078
+ if len(replicas) >= chunk_size:
1079
+ do_declare(client, replicas, reason)
1080
+ replicas = []
1081
+ if replicas:
1082
+ do_declare(client, replicas, reason)
1083
+ return SUCCESS
1084
+
1085
+
1086
+ @exception_handler
1087
+ def declare_bad_file_replicas(args):
1088
+ """
1089
+
1090
+ Declare replicas as bad.
1091
+
1092
+ """
1093
+
1094
+ if args.lfns:
1095
+ return __declare_bad_file_replicas_by_lfns(args)
1096
+
1097
+ client = get_client(args)
1098
+
1099
+ if args.inputfile:
1100
+ with open(args.inputfile) as infile:
1101
+ bad_files = list(filter(None, [line.strip() for line in infile]))
1102
+ else:
1103
+ bad_files = args.listbadfiles
1104
+
1105
+ # Interpret filenames not in scheme://* format as LFNs and convert them to PFNs
1106
+ bad_files_pfns = []
1107
+ for bad_file in bad_files:
1108
+ if bad_file.find('://') == -1:
1109
+ scope, name = get_scope(bad_file, client)
1110
+ did_info = client.get_did(scope, name)
1111
+ if did_info['type'].upper() != 'FILE' and not args.allow_collection:
1112
+ print('DID %s:%s is a collection and --allow-collection was not specified.' % (scope, name))
1113
+ return FAILURE
1114
+ replicas = [replica for rep in client.list_replicas([{'scope': scope, 'name': name}])
1115
+ for replica in list(rep['pfns'].keys())]
1116
+ bad_files_pfns.extend(replicas)
1117
+ else:
1118
+ bad_files_pfns.append(bad_file)
1119
+ if args.verbose:
1120
+ print("PFNs that will be declared bad:")
1121
+ for pfn in bad_files_pfns:
1122
+ print(pfn)
1123
+
1124
+ if len(bad_files_pfns) < 100:
1125
+ # Using the old API to declare
1126
+ non_declared = client.declare_bad_file_replicas(bad_files_pfns, args.reason)
1127
+ for rse in non_declared:
1128
+ for pfn in non_declared[rse]:
1129
+ print('%s : PFN %s cannot be declared.' % (rse, pfn))
1130
+ else:
1131
+ print('Getting the information about RSE protocols. It can take several seconds')
1132
+ dict_rse = client.export_data(distance=False)
1133
+ prot_dict = {}
1134
+ for rse, dict_attr in dict_rse['rses'].items():
1135
+ protocols = dict_attr['protocols']
1136
+ for prot in protocols:
1137
+ prot_dict[str('%s://%s%s' % (prot['scheme'], prot['hostname'], prot['prefix']))] = rse
1138
+ prot_dict[str('%s://%s:%s%s' % (prot['scheme'], prot['hostname'], prot['port'], prot['prefix']))] = rse
1139
+ print('Protocol information retrieved')
1140
+
1141
+ chunk_size = 10000
1142
+ print('Starting the declaration by chunks of %s' % chunk_size)
1143
+ tot_files = len(bad_files)
1144
+ tot_file_declared = 0
1145
+ cnt = 0
1146
+ nchunk = math.ceil(tot_files / chunk_size)
1147
+ for chunk in chunks(bad_files_pfns, chunk_size):
1148
+ list_bad_pfns = []
1149
+ cnt += 1
1150
+ previous_pattern = None
1151
+ for pfn in clean_pfns(chunk):
1152
+ unknown = True
1153
+ if previous_pattern:
1154
+ if previous_pattern in pfn:
1155
+ list_bad_pfns.append(pfn)
1156
+ unknown = False
1157
+ continue
1158
+ for pattern in prot_dict:
1159
+ if pattern in pfn:
1160
+ previous_pattern = prot_dict[pattern]
1161
+ list_bad_pfns.append(pfn)
1162
+ unknown = False
1163
+ break
1164
+ if unknown:
1165
+ print('Cannot find any RSE associated to %s' % pfn)
1166
+ client.add_bad_pfns(pfns=list_bad_pfns, reason=args.reason, state='BAD', expires_at=None)
1167
+ ndeclared = len(list_bad_pfns)
1168
+ tot_file_declared += ndeclared
1169
+ print('Chunk %s/%s : %s replicas successfully declared' % (int(cnt), int(nchunk), ndeclared))
1170
+ print('--------------------------------')
1171
+ print('Summary')
1172
+ print('%s/%s replicas successfully declared' % (tot_file_declared, tot_files))
1173
+
1174
+ return SUCCESS
1175
+
1176
+
1177
+ @exception_handler
1178
+ def declare_temporary_unavailable_replicas(args):
1179
+ """
1180
+ %(prog)s show [options] <field1=value1 field2=value2 ...>
1181
+
1182
+ Declare a list of temporary unavailable replicas.
1183
+
1184
+ """
1185
+ client = get_client(args)
1186
+ bad_files = []
1187
+ if args.inputfile:
1188
+ with open(args.inputfile) as infile:
1189
+ for line in infile:
1190
+ bad_file = line.rstrip('\n')
1191
+ if '://' not in bad_file:
1192
+ print('%s is not a valid PFN. Aborting', bad_file)
1193
+ return FAILURE
1194
+ if bad_file != '':
1195
+ bad_files.append(bad_file)
1196
+ else:
1197
+ bad_files = args.listbadfiles
1198
+
1199
+ if args.duration is None:
1200
+ raise ValueError("Duration should have been set, something went wrong!")
1201
+
1202
+ expiration_date = (datetime.datetime.utcnow() + datetime.timedelta(seconds=args.duration)).isoformat()
1203
+
1204
+ chunk_size = 10000
1205
+ tot_files = len(bad_files)
1206
+ cnt = 0
1207
+ nchunk = math.ceil(tot_files / chunk_size)
1208
+ for chunk in chunks(bad_files, chunk_size):
1209
+ cnt += 1
1210
+ client.add_bad_pfns(pfns=chunk, reason=args.reason, state='TEMPORARY_UNAVAILABLE', expires_at=expiration_date)
1211
+ ndeclared = len(chunk)
1212
+ print('Chunk %s/%s : %s replicas successfully declared' % (int(cnt), int(nchunk), ndeclared))
1213
+ print('--------------------------------')
1214
+ print('Summary')
1215
+ print('%s replicas successfully declared' % tot_files)
1216
+
1217
+ return SUCCESS
1218
+
1219
+
1220
+ @exception_handler
1221
+ def list_pfns(args):
1222
+ """
1223
+ %(prog)s list [options] <field1=value1 field2=value2 ...>
1224
+
1225
+ List the possible PFN for a file at a site.
1226
+
1227
+ """
1228
+ client = get_client(args)
1229
+ dids = args.dids.split(',')
1230
+ rse = args.rse
1231
+ protocol = args.protocol
1232
+ for input_did in dids:
1233
+ scope, name = get_scope(input_did, client)
1234
+ replicas = [rep for rep in client.list_replicas([{'scope': scope, 'name': name}, ], schemes=[protocol, ])]
1235
+ if rse in replicas[0]['rses'] and replicas[0]['rses'][rse]:
1236
+ print(replicas[0]['rses'][rse][0])
1237
+ else:
1238
+ logger.warning('The file has no replica on the specified RSE')
1239
+ rse_info = rsemgr.get_rse_info(rse, vo=client.vo)
1240
+ proto = rsemgr.create_protocol(rse_info, 'read', scheme=protocol)
1241
+ try:
1242
+ pfn = proto.lfns2pfns(lfns={'scope': scope, 'name': name})
1243
+ result = list(pfn.values())[0]
1244
+ except ReplicaNotFound as error:
1245
+ result = error
1246
+ if isinstance(result, (RSEOperationNotSupported, ReplicaNotFound)):
1247
+ if not rse_info['deterministic']:
1248
+ logger.warning('This is a non-deterministic site, so the real PFN might be different from the on suggested')
1249
+ rse_attr = client.list_rse_attributes(rse)
1250
+ naming_convention = rse_attr.get(RseAttr.NAMING_CONVENTION, None)
1251
+ parents = [did for did in client.list_parent_dids(scope, name)]
1252
+ if len(parents) > 1:
1253
+ logger.warning('The file has multiple parents')
1254
+ for did in parents:
1255
+ if did['type'] == 'DATASET':
1256
+ path = construct_non_deterministic_pfn(did['name'], scope, name, naming_convention=naming_convention)
1257
+ pfn = ''.join([proto.attributes['scheme'],
1258
+ '://',
1259
+ proto.attributes['hostname'],
1260
+ ':',
1261
+ str(proto.attributes['port']),
1262
+ proto.attributes['prefix'],
1263
+ path if not path.startswith('/') else path[1:]])
1264
+ print(pfn)
1265
+ else:
1266
+ logger.error('Unexpected error')
1267
+ return FAILURE
1268
+ else:
1269
+ print(result)
1270
+ return SUCCESS
1271
+
1272
+
1273
+ @exception_handler
1274
+ def import_data(args):
1275
+ """
1276
+ %(prog)s list [options] <field1=value1 field2=value2 ...>
1277
+
1278
+ Import data from JSON file to Rucio.
1279
+
1280
+ """
1281
+ client = get_client(args)
1282
+ import_file_path = args.file_path
1283
+ data = None
1284
+ print('Start reading file.')
1285
+ try:
1286
+ with open(import_file_path) as import_file:
1287
+ data_string = import_file.read()
1288
+ data = parse_response(data_string)
1289
+ except ValueError as error:
1290
+ print('There was problem with decoding your file.')
1291
+ print(error)
1292
+ return FAILURE
1293
+ except OSError as error:
1294
+ print('There was a problem with reading your file.')
1295
+ print(error)
1296
+ return FAILURE
1297
+
1298
+ if data:
1299
+ client.import_data(data)
1300
+ print('Data successfully imported.')
1301
+ return SUCCESS
1302
+ else:
1303
+ print('Nothing to import.')
1304
+ return FAILURE
1305
+
1306
+
1307
+ @exception_handler
1308
+ def export_data(args):
1309
+ """
1310
+ %(prog)s list [options] <field1=value1 field2=value2 ...>
1311
+
1312
+ Export data from Rucio to JSON file.
1313
+
1314
+ """
1315
+ client = get_client(args)
1316
+ destination_file_path = args.file_path
1317
+ print('Start querying data.')
1318
+ data = client.export_data()
1319
+ try:
1320
+ with open(destination_file_path, 'w+') as destination_file:
1321
+ destination_file.write(render_json(**data))
1322
+ print('File successfully written.')
1323
+ print('Data successfully exported to %s' % args.file_path)
1324
+ return SUCCESS
1325
+ except OSError as error:
1326
+ print('There was a problem with reading your file.')
1327
+ print(error)
1328
+ return FAILURE
1329
+
1330
+
1331
+ @exception_handler
1332
+ def set_tombstone(args):
1333
+ """
1334
+ %(prog)s list [options] <field1=value1 field2=value2 ...>
1335
+
1336
+ Set a tombstone on a list of replicas.
1337
+ """
1338
+ client = get_client(args)
1339
+ dids = args.dids
1340
+ rse = args.rse
1341
+ dids = [dids] if ',' not in dids else dids.split(',')
1342
+ replicas = []
1343
+ for did in dids:
1344
+ scope, name = get_scope(did, client)
1345
+ replicas.append({'scope': scope, 'name': name, 'rse': rse})
1346
+ client.set_tombstone(replicas)
1347
+ logger.info('Set tombstone successfully on: %s' % args.dids)
1348
+ return SUCCESS
1349
+
1350
+
1351
+ def get_parser():
1352
+ """
1353
+ Returns the argparse parser.
1354
+ """
1355
+ oparser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]), add_help=True)
1356
+
1357
+ # required argument was added in Python 3.7 and restores the Python 2 behavior
1358
+ required_arg = {'required': True}
1359
+
1360
+ subparsers = oparser.add_subparsers(dest='subcommand', **required_arg)
1361
+
1362
+ # Main arguments
1363
+ oparser.add_argument('--version', action='version', version='%(prog)s ' + version.version_string())
1364
+ oparser.add_argument('--verbose', '-v', default=False, action='store_true', help="Print more verbose output")
1365
+ oparser.add_argument('-H', '--host', dest="host", metavar="ADDRESS", help="The Rucio API host")
1366
+ oparser.add_argument('--auth-host', dest="auth_host", metavar="ADDRESS", help="The Rucio Authentication host")
1367
+ oparser.add_argument('-a', '--account', dest="issuer", metavar="ACCOUNT", help="Rucio account to use")
1368
+ oparser.add_argument('-S', '--auth-strategy', dest="auth_strategy", default=None, help="Authentication strategy (userpass, x509, ssh ...)")
1369
+ oparser.add_argument('-T', '--timeout', dest="timeout", type=float, default=None, help="Set all timeout values to SECONDS")
1370
+ oparser.add_argument('--vo', dest="vo", metavar="VO", default=None, help="VO to authenticate at. Only used in multi-VO mode.")
1371
+
1372
+ # Options for the userpass auth_strategy
1373
+ oparser.add_argument('-u', '--user', dest='username', default=None, help='username')
1374
+ oparser.add_argument('-pwd', '--password', dest='password', default=None, help='password')
1375
+ # Options for defining the OIDC scope# Options for defining remaining OIDC parameters
1376
+ oparser.add_argument('--oidc-user', dest='oidc_username', default=None, help='OIDC username')
1377
+ oparser.add_argument('--oidc-password', dest='oidc_password', default=None, help='OIDC password')
1378
+ oparser.add_argument('--oidc-scope', dest='oidc_scope', default='openid profile', help='Defines which (OIDC) information user will share with Rucio. '
1379
+ + 'Rucio requires at least -sc="openid profile". To request refresh token for Rucio, scope must include "openid offline_access" and ' # NOQA: W503
1380
+ + 'there must be no active access token saved on the side of the currently used Rucio Client.') # NOQA: W503
1381
+ oparser.add_argument('--oidc-audience', dest='oidc_audience', default=None, help='Defines which audience are tokens requested for.')
1382
+ oparser.add_argument('--oidc-auto', dest='oidc_auto', default=False, action='store_true', help='If not specified, username and password credentials are not required and users will be given a URL '
1383
+ + 'to use in their browser. If specified, the users explicitly trust Rucio with their IdP credentials.') # NOQA: W503
1384
+ oparser.add_argument('--oidc-polling', dest='oidc_polling', default=False, action='store_true', help='If not specified, user will be asked to enter a code returned by the browser to the command line. '
1385
+ + 'If --polling is set, Rucio Client should get the token without any further interaction of the user. This option is active only if --auto is *not* specified.') # NOQA: W503
1386
+ oparser.add_argument('--oidc-refresh-lifetime', dest='oidc_refresh_lifetime', default=None, help='Max lifetime in hours for this an access token will be refreshed by asynchronous Rucio daemon. '
1387
+ + 'If not specified, refresh will be stopped after 4 days. This option is effective only if --oidc-scope includes offline_access scope for a refresh token to be granted to Rucio.') # NOQA: W503
1388
+ oparser.add_argument('--oidc-issuer', dest='oidc_issuer', default=None,
1389
+ help='Defines which Identity Provider is going to be used. The issuer string must correspond '
1390
+ + 'to the keys configured in the /etc/idpsecrets.json auth server configuration file.') # NOQA: W503
1391
+
1392
+ # Options for the x509 auth_strategy
1393
+ oparser.add_argument('--certificate', dest='certificate', default=None, help='Client certificate file')
1394
+ oparser.add_argument('--ca-certificate', dest='ca_certificate', default=None, help='CA certificate to verify peer against (SSL)')
1395
+
1396
+ # The import export subparser
1397
+ data_parser = subparsers.add_parser('data', help='Import and export data')
1398
+ data_subparsers = data_parser.add_subparsers(dest='data_subcommand', **required_arg)
1399
+
1400
+ # The import command
1401
+ import_parser = data_subparsers.add_parser('import',
1402
+ help='Import data to Rucio from JSON file.',
1403
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1404
+ epilog='Usage example\n'
1405
+ '"""""""""""""\n'
1406
+ 'Import data from the file file.json::\n'
1407
+ '\n'
1408
+ ' $ rucio-admin data import file.json\n'
1409
+ '\n')
1410
+ import_parser.add_argument('file_path', action='store', help='File path.')
1411
+ import_parser.set_defaults(which='import')
1412
+
1413
+ # The export command
1414
+ export_parser = data_subparsers.add_parser('export',
1415
+ help='Export data from Rucio to JSON file.',
1416
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1417
+ epilog='Usage example\n'
1418
+ '"""""""""""""\n'
1419
+ 'Export data to the file file.json::\n'
1420
+ '\n'
1421
+ ' $ rucio-admin data export file.json\n'
1422
+ '\n')
1423
+ export_parser.add_argument('file_path', action='store', help='File path.')
1424
+ export_parser.set_defaults(which='export')
1425
+
1426
+ # The account subparser
1427
+ account_parser = subparsers.add_parser('account', help='Account methods')
1428
+ account_subparser = account_parser.add_subparsers(dest='account_subcommand', **required_arg)
1429
+
1430
+ # The list_accounts command
1431
+ list_account_parser = account_subparser.add_parser('list',
1432
+ help='List Rucio accounts.',
1433
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1434
+ epilog='Usage example\n'
1435
+ '"""""""""""""\n'
1436
+ '::\n'
1437
+ '\n'
1438
+ ' $ rucio-admin account list --type USER\n'
1439
+ '\n')
1440
+ list_account_parser.add_argument('--type', dest='account_type', action='store', help='Account Type (USER, GROUP, SERVICE)')
1441
+ list_account_parser.add_argument('--id', dest='identity', action='store', help='Identity (e.g. DN)')
1442
+ list_account_parser.add_argument('--filters', dest='filters', action='store', help='Filter arguments in form `key=value,another_key=next_value`')
1443
+ list_account_parser.set_defaults(which='list_accounts')
1444
+
1445
+ # The list_account_attributes command
1446
+ list_attr_parser = account_subparser.add_parser('list-attributes',
1447
+ help='List attributes for an account.',
1448
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1449
+ epilog='Usage example\n'
1450
+ '"""""""""""""\n'
1451
+ '::\n'
1452
+ '\n'
1453
+ ' $ rucio-admin account list-attributes jdoe\n'
1454
+ ' +-------+---------+\n'
1455
+ ' | Key | Value |\n'
1456
+ ' |-------+---------|\n'
1457
+ ' | admin | False |\n'
1458
+ ' +-------+---------+\n'
1459
+ '\n'
1460
+ 'Note: this table empty in most cases.\n'
1461
+ '\n')
1462
+ list_attr_parser.add_argument('account', action='store', help='Account name')
1463
+ list_attr_parser.set_defaults(which='list_account_attributes')
1464
+
1465
+ # The add_account_attribute command
1466
+ add_attr_parser = account_subparser.add_parser('add-attribute',
1467
+ help='Add attribute for an account.',
1468
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1469
+ epilog='Usage example\n'
1470
+ '"""""""""""""\n'
1471
+ '::\n'
1472
+ '\n'
1473
+ ' $ rucio-admin account add-attribute --key \'test\' --value true jdoe\n'
1474
+ '\n'
1475
+ 'Note: no printed stdout.\n'
1476
+ '\n')
1477
+ add_attr_parser.add_argument('account', action='store', help='Account name')
1478
+ add_attr_parser.add_argument('--key', dest='key', action='store', help='Attribute key', required=True)
1479
+ add_attr_parser.add_argument('--value', dest='value', action='store', help='Attribute value', required=True)
1480
+ add_attr_parser.set_defaults(which='add_account_attribute')
1481
+
1482
+ # The delete_account_attribute command
1483
+ delete_attr_parser = account_subparser.add_parser('delete-attribute',
1484
+ help='Delete attribute for an account.',
1485
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1486
+ epilog='Usage example\n'
1487
+ '"""""""""""""\n'
1488
+ '::\n'
1489
+ '\n'
1490
+ ' $ rucio-admin account delete-attribute --key \'test\' jdoe\n'
1491
+ '\n'
1492
+ 'Note: no printed stdout.\n'
1493
+ '\n')
1494
+ delete_attr_parser.add_argument('account', action='store', help='Account name')
1495
+ delete_attr_parser.add_argument('--key', dest='key', action='store', help='Attribute key', required=True)
1496
+ delete_attr_parser.set_defaults(which='delete_account_attribute')
1497
+
1498
+ # The add_account command
1499
+ add_account_parser = account_subparser.add_parser('add',
1500
+ help='Add Rucio account.',
1501
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1502
+ epilog='Usage example\n'
1503
+ '"""""""""""""\n'
1504
+ '::\n'
1505
+ '\n'
1506
+ ' $ rucio-admin account add jdoe-sister\n'
1507
+ ' Added new account: jdoe-sister\n'
1508
+ '\n')
1509
+ add_account_parser.set_defaults(which='add_account')
1510
+ add_account_parser.add_argument('account', action='store', help='Account name')
1511
+ add_account_parser.add_argument('--type', dest='accounttype', default='USER', help='Account Type (USER, GROUP, SERVICE)')
1512
+ add_account_parser.add_argument('--email', dest='accountemail', action='store',
1513
+ help='Email address associated with the account')
1514
+
1515
+ # The disable_account command
1516
+ delete_account_parser = account_subparser.add_parser('delete',
1517
+ help='Delete Rucio account.',
1518
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1519
+ epilog='Usage example\n'
1520
+ '"""""""""""""\n'
1521
+ '::\n'
1522
+ '\n'
1523
+ ' $ rucio-admin account delete jdoe-sister\n'
1524
+ ' Deleted account: jdoe-sister\n'
1525
+ '\n')
1526
+ delete_account_parser.set_defaults(which='delete_account')
1527
+ delete_account_parser.add_argument('acnt', action='store', help='Account name')
1528
+
1529
+ # The info_account command
1530
+ info_account_parser = account_subparser.add_parser('info',
1531
+ help='Show detailed information about an account.',
1532
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1533
+ epilog='Usage example\n'
1534
+ '"""""""""""""\n'
1535
+ '::\n'
1536
+ '\n'
1537
+ ' $ rucio-admin account info jdoe\n'
1538
+ ' status : ACTIVE\n'
1539
+ ' account : jdoe\n'
1540
+ ' account_type : SERVICE\n'
1541
+ ' created_at : 2015-02-03T15:51:16\n'
1542
+ ' suspended_at : None\n'
1543
+ ' updated_at : 2015-02-03T15:51:16\n'
1544
+ ' deleted_at : None\n'
1545
+ ' email : None\n'
1546
+ '\n')
1547
+ info_account_parser.set_defaults(which='info_account')
1548
+ info_account_parser.add_argument('account', action='store', help='Account name')
1549
+
1550
+ # The list_account_identities command
1551
+ list_account_identities_parser = account_subparser.add_parser('list-identities',
1552
+ help='List all identities (DNs) on an account.',
1553
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1554
+ epilog='Usage example\n'
1555
+ '"""""""""""""\n'
1556
+ '::\n'
1557
+ '\n'
1558
+ ' $ rucio-admin account list-identities jdoe\n'
1559
+ ' Identity: CN=Joe Doe,OU=Desy,O=GermanGrid,C=DE, type: X509\n'
1560
+ ' Identity: jdoe@CERN.CH, type: GSS\n'
1561
+ ' Identity: CN=Joe Doe,CN=707654,CN=jdoe,OU=Users,OU=Organic Units,DC=cern,DC=ch, type: X509\n'
1562
+ '\n')
1563
+ list_account_identities_parser.set_defaults(which='list_identities')
1564
+ list_account_identities_parser.add_argument('account', action='store', help='Account name')
1565
+
1566
+ # The set-limits command
1567
+ set_account_limits_parser = account_subparser.add_parser('set-limits',
1568
+ help='Set the limits for the provided account at given RSE.',
1569
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1570
+ epilog='Usage example\n'
1571
+ '"""""""""""""\n'
1572
+ '::\n'
1573
+ '\n'
1574
+ ' $ rucio-admin account set-limits jdoe DESY-ZN_DATADISK 1000000000000\n'
1575
+ ' Set account limit for account jdoe on RSE DESY-ZN_DATADISK: 1.000 TB\n'
1576
+ '\n'
1577
+ 'Note: the order of perameters is fixed: account, rse, bytes.\n'
1578
+ '\n')
1579
+ set_account_limits_parser.set_defaults(which='set_limits')
1580
+ set_account_limits_parser.add_argument('account', action='store', help='Account name')
1581
+ set_account_limits_parser.add_argument('rse', action='store', help='RSE boolean expression')
1582
+ set_account_limits_parser.add_argument('bytes', action='store', help='Value can be specified in bytes ("10000"), with a storage unit ("10GB"), or "infinity"')
1583
+ set_account_limits_parser.add_argument('locality', action='store', nargs='?', default='local', choices=['local', 'global'], help='Global or local limit scope. Default: "local"')
1584
+
1585
+ # The account-limit subparser
1586
+ get_account_limits_parser = account_subparser.add_parser('get-limits',
1587
+ help='To get the account limits on an RSE.',
1588
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1589
+ epilog='Usage example\n'
1590
+ '"""""""""""""\n'
1591
+ '::\n'
1592
+ '\n'
1593
+ ' $ rucio-admin account get-limits jdoe DESY-ZN_DATADISK\n'
1594
+ ' Quota on DESY-ZN_DATADISK for jdoe : 1.000 TB\n'
1595
+ 'Note: the order of parameters is fixed: account, rse.\n'
1596
+ '\n')
1597
+ get_account_limits_parser.set_defaults(which='get_limits')
1598
+ get_account_limits_parser.add_argument('account', action='store', help='Account name')
1599
+ get_account_limits_parser.add_argument('rse', action='store', help='The RSE name')
1600
+ get_account_limits_parser.add_argument('locality', action='store', nargs='?', default='local', choices=['local', 'global'], help='Global or local limit scope. Default: "local"')
1601
+
1602
+ # The delete_quota command
1603
+ delete_account_limits_parser = account_subparser.add_parser('delete-limits',
1604
+ help='Delete limites for an account at given RSE.',
1605
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1606
+ epilog='Usage example\n'
1607
+ '"""""""""""""\n'
1608
+ '::\n'
1609
+ '\n'
1610
+ ' $ rucio-admain account delete-limits jdoe DESY-ZN_DATADISK\n'
1611
+ ' Deleted account limit for account jdoe and RSE DESY-ZN_DATADISK\n'
1612
+ '\n'
1613
+ 'Note: the order of parameters is fixed: account, rse.\n'
1614
+ '\n')
1615
+ delete_account_limits_parser.set_defaults(which='delete_limits')
1616
+ delete_account_limits_parser.add_argument('account', action='store', help='Account name')
1617
+ delete_account_limits_parser.add_argument('rse', action='store', help='RSE name')
1618
+ delete_account_limits_parser.add_argument('locality', action='store', nargs='?', default='local', choices=['local', 'global'], help='Global or local limit scope. Default: "local"')
1619
+
1620
+ # Ban/unban operations not implemented yet
1621
+ ban_account_limits_parser = account_subparser.add_parser('ban',
1622
+ help='Disable an account.',
1623
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1624
+ epilog='Usage example\n'
1625
+ '"""""""""""""\n'
1626
+ '::\n'
1627
+ '\n'
1628
+ ' $ rucio-admin account ban --account jdoe\n'
1629
+ ' Account jdoe banned\n'
1630
+ '\n'
1631
+ 'Note: in case of accidental ban, use unban.\n'
1632
+ 'CAUTION: the account is completely disabled.\n'
1633
+ '\n')
1634
+ ban_account_limits_parser.set_defaults(which='ban_account')
1635
+ ban_account_limits_parser.add_argument('--account', dest='account', action='store', help='Account name', required=True)
1636
+
1637
+ unban_account_limits_parser = account_subparser.add_parser('unban',
1638
+ help='Unban a banned account. The account is mandatory parameter.',
1639
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1640
+ epilog='Usage example\n'
1641
+ '"""""""""""""\n'
1642
+ '::\n'
1643
+ '\n'
1644
+ ' $ rucio-admin account unban --account jdoe\n'
1645
+ ' Account jdoe unbanned\n'
1646
+ '\n')
1647
+ unban_account_limits_parser.set_defaults(which='unban_account')
1648
+ unban_account_limits_parser.add_argument('--account', dest='account', action='store', help='Account name', required=True)
1649
+
1650
+ # Update account subparser
1651
+ update_account_parser = account_subparser.add_parser('update',
1652
+ help='Update an account.',
1653
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1654
+ epilog='Usage example\n'
1655
+ '"""""""""""""\n'
1656
+ '::\n'
1657
+ '\n'
1658
+ ' $ rucio-admin account update --account jdoe --key email --value test\n'
1659
+ ' Account jdoe updated\n'
1660
+ '\n')
1661
+ update_account_parser.set_defaults(which='update_account')
1662
+ update_account_parser.add_argument('--account', dest='account', action='store', help='Account name', required=True)
1663
+ update_account_parser.add_argument('--key', dest='key', action='store', help='Account parameter', required=True)
1664
+ update_account_parser.add_argument('--value', dest='value', action='store', help='Account parameter value', required=True)
1665
+
1666
+ # The identity subparser
1667
+ identity_parser = subparsers.add_parser('identity', help='Identity methods')
1668
+ identity_subparser = identity_parser.add_subparsers(dest='identity_subcommand', **required_arg)
1669
+
1670
+ # The identity_add command
1671
+ identity_add_parser = identity_subparser.add_parser('add',
1672
+ help='Grant an identity access to an account.',
1673
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1674
+ epilog='Usage example\n'
1675
+ '"""""""""""""\n'
1676
+ '\n'
1677
+ 'To add an identity of X509 type::\n'
1678
+ '\n'
1679
+ ' $ rucio-admin identity add --account jdoe --type X509 --id \'CN=Joe Doe,CN=707658,CN=jdoe,OU=Users,OU=Organic Units,DC=cern,DC=ch\' --email jdoe@cern.ch\n'
1680
+ ' Added new identity to account: CN=Joe Doe,CN=707658,CN=jdoe,OU=Users,OU=Organic Units,DC=cern,DC=ch\n'
1681
+ ' \n'
1682
+ ' $ rucio-admin account list-identities jdoe\n'
1683
+ ' Identity: CN=Joe Doe,CN=707658,CN=jdoe,OU=Users,OU=Organic Units,DC=cern,DC=ch, type: X509\n'
1684
+ '\n'
1685
+ 'Note: please keep the DN inside quota marks.\n'
1686
+ '\n'
1687
+ 'To add an identity of GSS type::\n'
1688
+ '\n'
1689
+ ' $ rucio-admin identity add --account jdoe --type GSS --email jdoe@cern.ch --id jdoe@CERN.CH\n'
1690
+ ' Added new identity to account: jdoe@CERN.CH-jdoe\n'
1691
+ ' \n'
1692
+ ' $ rucio-admin account list-identities jdoe\n'
1693
+ ' Identity: jdoe@CERN.CH, type: GSS\n'
1694
+ ' Identity: CN=Joe Doe,CN=707658,CN=jdoe,OU=Users,OU=Organic Units,DC=cern,DC=ch, type: X509\n'
1695
+ '\n')
1696
+ identity_add_parser.set_defaults(which='identity_add')
1697
+ identity_add_parser.add_argument('--account', dest='account', action='store', help='Account name', required=True)
1698
+ identity_add_parser.add_argument('--type', dest='authtype', action='store', choices=['X509', 'GSS', 'USERPASS', 'SSH', 'SAML', 'OIDC'], help='Authentication type [X509|GSS|USERPASS|SSH|SAML|OIDC]', required=True)
1699
+ identity_add_parser.add_argument('--id', dest='identity', action='store', help='Identity', required=True)
1700
+ identity_add_parser.add_argument('--email', dest='email', action='store', help='Email address associated with the identity', required=True)
1701
+ identity_add_parser.add_argument('--password', dest='password', action='store', help='Password if authtype is USERPASS', required=False)
1702
+
1703
+ # The identity_delete command
1704
+ identity_delete_parser = identity_subparser.add_parser('delete',
1705
+ help="Revoke an identity's access to an account. The mandatory parameters are account, type and identity.",
1706
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1707
+ epilog='Usage example\n'
1708
+ '"""""""""""""\n'
1709
+ '::\n'
1710
+ '\n'
1711
+ ' $ rucio-admin identity delete --account jdoe --type X509 --id \'CN=Joe Doe,CN=707658,CN=jdoe,OU=Users,OU=Organic Units,DC=cern,DC=ch\'\n'
1712
+ ' Deleted identity: CN=Joe Doe,CN=707658,CN=jdoe,OU=Users,OU=Organic Units,DC=cern,DC=ch\n'
1713
+ '\n'
1714
+ 'Note: if the identity was accidentally deleted, use add option.\n'
1715
+ '\n')
1716
+ identity_delete_parser.set_defaults(which='identity_delete')
1717
+ identity_delete_parser.add_argument('--account', dest='account', action='store', help='Account name', required=True)
1718
+ identity_delete_parser.add_argument('--type', dest='authtype', action='store', choices=['X509', 'GSS', 'USERPASS', 'SSH', 'SAML', 'OIDC'], help='Authentication type [X509|GSS|USERPASS|SSH|SAML|OIDC]', required=True)
1719
+ identity_delete_parser.add_argument('--id', dest='identity', action='store', help='Identity', required=True)
1720
+
1721
+ # The RSE subparser
1722
+ rse_parser = subparsers.add_parser('rse', help='RSE (Rucio Storage Element) methods')
1723
+ rse_subparser = rse_parser.add_subparsers(dest='rse_subcommand', **required_arg)
1724
+
1725
+ # The list_rses command
1726
+ list_rse_parser = rse_subparser.add_parser('list',
1727
+ help='List all RSEs.',
1728
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1729
+ epilog='Usage example\n'
1730
+ '"""""""""""""\n'
1731
+ 'To list all rses::\n'
1732
+ '\n'
1733
+ ' $ rucio-admin rse list'
1734
+ '\n'
1735
+ 'Note: same as rucio list-rses\n'
1736
+ '\n'
1737
+ 'To list special class of rses::\n'
1738
+ '\n'
1739
+ ' $ rucio list-rses --rses \"tier=2&type=DATADISK\"\n'
1740
+ '\n')
1741
+ list_rse_parser.set_defaults(which='list_rses')
1742
+
1743
+ # The add_rse command
1744
+ add_rse_parser = rse_subparser.add_parser('add',
1745
+ help='Add new RSE.',
1746
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1747
+ epilog='Example Usage\n'
1748
+ '"""""""""""""\n'
1749
+ '::\n'
1750
+ '\n'
1751
+ ' $ rucio-admin rse add JDOE_DATADISK\n'
1752
+ ' Added new deterministic RSE: JDOE_DATADISK\n'
1753
+ '\n'
1754
+ ' $ rucio-admin rse add --non-deterministic JDOE-TEST_DATATAPE\n'
1755
+ ' Added new non-deterministic RSE: JDOE-TEST_DATATAPE\n'
1756
+ '\n')
1757
+ add_rse_parser.set_defaults(which='add_rse')
1758
+ add_rse_parser.add_argument('rse', action='store', help='RSE name')
1759
+ add_rse_parser.add_argument('--non-deterministic', action='store_true', help='Create RSE in non-deterministic mode')
1760
+
1761
+ # The update_rse command
1762
+ update_rse_parser = rse_subparser.add_parser('update',
1763
+ help='Update RSE settings.',
1764
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1765
+ epilog='Example Usage\n'
1766
+ '"""""""""""""\n'
1767
+ '\n'
1768
+ ' $ rucio-admin rse update --setting availability_write --value False\n'
1769
+ '\n'
1770
+ '\n')
1771
+ update_rse_parser.set_defaults(which='update_rse')
1772
+ update_rse_parser.add_argument('--rse', dest='rse', action='store', help='RSE name', required=True)
1773
+ update_rse_parser.add_argument('--setting', dest='param', action='store', help="One of deterministic, rse_type, staging_are, volatile, qos_class, availability_delete, availability_read, availability_write, city, country_name, latitude, longitude, region_code, time_zone", required=True) # noqa: E501
1774
+ update_rse_parser.add_argument('--value', dest='value', action='store', help='Value for the new setting configuration. Use "", None or null to wipe the value', required=True)
1775
+
1776
+ # The info_rse command
1777
+ info_rse_parser = rse_subparser.add_parser('info',
1778
+ help='Information about RSE.',
1779
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1780
+ epilog='Usage example\n'
1781
+ '"""""""""""""\n'
1782
+ 'Information about a RSE::\n'
1783
+ '\n'
1784
+ ' $ rucio-admin rse info JDOE_DATADISK\n'
1785
+ ' Settings:\n'
1786
+ ' =========\n'
1787
+ ' third_party_copy_protocol: 1\n'
1788
+ ' rse_type: DISK\n'
1789
+ ' domain: [u\'lan\', u\'wan\']\n'
1790
+ ' availability_delete: True\n'
1791
+ ' delete_protocol: 1\n'
1792
+ ' rse: JDOE_DATADISK\n'
1793
+ ' deterministic: True\n'
1794
+ ' write_protocol: 1\n'
1795
+ ' read_protocol: 1\n'
1796
+ ' staging_area: False\n'
1797
+ ' credentials: None\n'
1798
+ ' availability_write: True\n'
1799
+ ' lfn2pfn_algorithm: default\n'
1800
+ ' availability_read: True\n'
1801
+ ' volatile: False\n'
1802
+ ' id: 9c54c73cbd534450b2202a576f809f1f\n'
1803
+ ' Attributes:\n'
1804
+ ' ===========\n'
1805
+ ' JDOE_DATADISK: True\n'
1806
+ ' Protocols:\n'
1807
+ ' ==========\n'
1808
+ ' Usage:\n'
1809
+ ' ======\n'
1810
+ ' rucio\n'
1811
+ ' used: 0\n'
1812
+ ' rse: JDOE_DATADISK\n'
1813
+ ' updated_at: 2018-02-16 13:08:28\n'
1814
+ ' free: None\n'
1815
+ ' source: rucio\n'
1816
+ ' total: 0\n'
1817
+ '\n'
1818
+ 'Note: alternatively: rucio list-rse-usage JDOE_DATADISK.\n'
1819
+ '\n')
1820
+ info_rse_parser.set_defaults(which='info_rse')
1821
+ info_rse_parser.add_argument('rse', action='store', help='RSE name')
1822
+
1823
+ # The set_attribute_rse command
1824
+ set_attribute_rse_parser = rse_subparser.add_parser('set-attribute',
1825
+ help='Add RSE attribute(key-value pair).',
1826
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1827
+ epilog='Usage example\n'
1828
+ '"""""""""""""\n'
1829
+ '::\n'
1830
+ '\n'
1831
+ ' $ rucio-admin rse set-attribute --rse JDOE_DATADISK --key owner --value jdoe\n'
1832
+ ' Added new RSE attribute for JDOE_DATADISK: owner-jdoe\n'
1833
+ '\n'
1834
+ 'CAUTION: the existing attribute can be overwritten. Check rucio list-rse-attributes JDOE_DATADISK before setting an attribute.\n'
1835
+ '\n')
1836
+ set_attribute_rse_parser.set_defaults(which='set_attribute_rse')
1837
+ set_attribute_rse_parser.add_argument('--rse', dest='rse', action='store', help='RSE name', required=True)
1838
+ set_attribute_rse_parser.add_argument('--key', dest='key', action='store', help='Attribute key', required=True)
1839
+ set_attribute_rse_parser.add_argument('--value', dest='value', action='store', help='Attribute value', required=True)
1840
+
1841
+ # The delete_attribute_rse command
1842
+ delete_attribute_rse_parser = rse_subparser.add_parser('delete-attribute',
1843
+ help='Delete a RSE attribute(key-value pair).',
1844
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1845
+ epilog='Usage example\n'
1846
+ '"""""""""""""\n'
1847
+ '::\n'
1848
+ '\n'
1849
+ ' $ rucio-admin rse delete-attribute --rse JDOE_DATADISK --key owner --value jdoe\n'
1850
+ ' Deleted RSE attribute for JDOE_DATADISK: owner-jdoe\n'
1851
+ '\n')
1852
+ delete_attribute_rse_parser.set_defaults(which='delete_attribute_rse')
1853
+ delete_attribute_rse_parser.add_argument('--rse', dest='rse', action='store', help='RSE name', required=True)
1854
+ delete_attribute_rse_parser.add_argument('--key', dest='key', action='store', help='Attribute key', required=True)
1855
+ delete_attribute_rse_parser.add_argument('--value', dest='value', action='store', help='Attribute value', required=True)
1856
+
1857
+ # The add_distance_rses command
1858
+ add_distance_rses_parser = rse_subparser.add_parser('add-distance',
1859
+ help='Set the distance between a pair of RSEs.',
1860
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1861
+ epilog='Usage example\n'
1862
+ '"""""""""""""\n'
1863
+ '::\n'
1864
+ '\n'
1865
+ ' $ rucio-admin rse add-distance JDOE_SCRATCHDISK JDOE_DATADISK\n'
1866
+ ' Set distance from JDOE_SCRATCHDISK to JDOE_DATADISK to 1/n'
1867
+ '\n'
1868
+ 'Note::\n'
1869
+ '\n'
1870
+ ' --distance can be any positive integer, 0 is the closest\n'
1871
+ 'Note: order of RSEs is fixed: source, destination\n'
1872
+ '\n')
1873
+ add_distance_rses_parser.set_defaults(which='add_distance_rses')
1874
+ add_distance_rses_parser.add_argument(dest='source', action='store', help='Source RSE name')
1875
+ add_distance_rses_parser.add_argument(dest='destination', action='store', help='Destination RSE name')
1876
+ add_distance_rses_parser.add_argument('--distance', dest='distance', default=1, type=int, help='Distance between RSEs')
1877
+ add_distance_rses_parser.add_argument('--ranking', '--ranking', dest='ranking', new_option_string='--ranking', default=1, type=int, action=StoreAndDeprecateWarningAction, help='Ranking of link')
1878
+
1879
+ # The update_distance_rses command
1880
+ update_distance_rses_parser = rse_subparser.add_parser('update-distance',
1881
+ help='Update the existing distance between a pair of RSEs. The mandatory parameters are source, destination and distance or ranking.',
1882
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1883
+ epilog='Usage example\n'
1884
+ '"""""""""""""\n'
1885
+ '::\n'
1886
+ '\n'
1887
+ ' $ rucio-admin rse update-distance JDOE_DATADISK JDOE_SCRATCHDISK --distance 10\n'
1888
+ ' Update distance information from JDOE_DATADISK to JDOE_SCRATCHDISK:\n'
1889
+ ' - Distance set to 10\n'
1890
+ '\n'
1891
+ 'Note::\n'
1892
+ '\n'
1893
+ ' --distance can be any positive integer, 0 is the closest\n'
1894
+ 'Note: order of RSEs is fixed: source, destination.\n'
1895
+ '\n')
1896
+ update_distance_rses_parser.set_defaults(which='update_distance_rses')
1897
+ update_distance_rses_parser.add_argument(dest='source', action='store', help='Source RSE name')
1898
+ update_distance_rses_parser.add_argument(dest='destination', action='store', help='Destination RSE name')
1899
+ update_distance_rses_parser.add_argument('--distance', dest='distance', type=int, help='Distance between RSEs')
1900
+ update_distance_rses_parser.add_argument('--ranking', '--ranking', dest='ranking', new_option_string='--ranking', type=int, action=StoreAndDeprecateWarningAction, help='Ranking of link')
1901
+
1902
+ # The delete_distance_rses command
1903
+ delete_distance_rses_parser = rse_subparser.add_parser('delete-distance',
1904
+ help='Delete the distance between a pair of RSEs. The mandatory parameters are source and destination.',
1905
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1906
+ epilog='Usage example\n'
1907
+ '"""""""""""""\n'
1908
+ '::\n'
1909
+ '\n'
1910
+ ' $ rucio-admin rse delete-distance JDOE_DATADISK JDOE_SCRATCHDISK\n'
1911
+ ' Delete distance information from JDOE_DATADISK to JDOE_SCRATCHDISK:\n'
1912
+ '\n')
1913
+ delete_distance_rses_parser.set_defaults(which='delete_distance_rses')
1914
+ delete_distance_rses_parser.add_argument(dest='source', action='store', help='Source RSE name')
1915
+ delete_distance_rses_parser.add_argument(dest='destination', action='store', help='Destination RSE name')
1916
+
1917
+ # The get_distance_rses command
1918
+ get_distance_rses_parser = rse_subparser.add_parser('get-distance',
1919
+ help='Get the distance information between a pair of RSEs.',
1920
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1921
+ epilog='Usage example\n'
1922
+ '"""""""""""""\n'
1923
+ '::\n'
1924
+ '\n'
1925
+ ' $ rucio-admin rse get-distance JDOE_DATADISK JDOE_SCRATCHDISK\n'
1926
+ ' Distance information from JDOE_DATADISK to JDOE_SCRATCHDISK: distance=3, ranking=10\n'
1927
+ '\n'
1928
+ 'Note: order of RSEs is fixed: source, destination.\n'
1929
+ '\n')
1930
+ get_distance_rses_parser.set_defaults(which='get_distance_rses')
1931
+ get_distance_rses_parser.add_argument(dest='source', action='store', help='Source RSE name')
1932
+ get_distance_rses_parser.add_argument(dest='destination', action='store', help='Destination RSE name')
1933
+
1934
+ # The get_attribute_rse command
1935
+ get_attribute_rse_parser = rse_subparser.add_parser('get-attribute',
1936
+ help='List RSE attributes.',
1937
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1938
+ epilog='Usage example\n'
1939
+ '"""""""""""""\n'
1940
+ '::\n'
1941
+ '\n'
1942
+ ' $ rucio-admin rse get-attribute JDOE_DATADISK\n'
1943
+ ' owner: jdoe\n'
1944
+ ' JDOE_DATADISK: True\n'
1945
+ '\n'
1946
+ 'Note: alternatively: rucio list-rse-attributes JDOE_DATADISK.\n'
1947
+ '\n')
1948
+ get_attribute_rse_parser.set_defaults(which='get_attribute_rse')
1949
+ get_attribute_rse_parser.add_argument(dest='rse', action='store', help='RSE name')
1950
+
1951
+ # The add_protocol_rse command
1952
+ add_protocol_rse_parser = rse_subparser.add_parser('add-protocol',
1953
+ help='Add a protocol and its settings to a RSE.',
1954
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1955
+ epilog='Usage example\n'
1956
+ '"""""""""""""\n'
1957
+ '::\n'
1958
+ '\n'
1959
+ ' $ rucio-admin rse add-protocol --hostname jdoes.test.org --scheme gsiftp --prefix \'/atlasdatadisk/rucio/\' --port 8443 JDOE_DATADISK\n'
1960
+ '\n'
1961
+ 'Note: no printed stdout.\n'
1962
+ 'Note: examples of optional parameters::\n'
1963
+ '\n'
1964
+ ' --space-token DATADISK\n'
1965
+ ' --web-service-path \'/srm/managerv2?SFN=\'\n'
1966
+ ' --port 8443\n'
1967
+ ' --impl \'rucio.rse.protocols.gfal.Default\'\n'
1968
+ ' (for other protocol implementation, replace gfal2 with impl. name, e.g. srm)\n'
1969
+ ' --domain-json\n'
1970
+ ' --extended-attributes-json example.json\n'
1971
+ ' where example.json contains dict {\'attr_name\':\'value\', ...}\n'
1972
+ '\n')
1973
+ add_protocol_rse_parser.set_defaults(which='add_protocol_rse')
1974
+ add_protocol_rse_parser.add_argument(dest='rse', action='store', help='RSE name')
1975
+ add_protocol_rse_parser.add_argument('--hostname', dest='hostname', action='store', help='Endpoint hostname', required=True)
1976
+ add_protocol_rse_parser.add_argument('--scheme', dest='scheme', action='store', help='Endpoint URL scheme', required=True)
1977
+ add_protocol_rse_parser.add_argument('--prefix', dest='prefix', action='store', help='Endpoint URL path prefix', required=True)
1978
+ add_protocol_rse_parser.add_argument('--space-token', dest='space_token', action='store', help='Space token name (SRM-only)')
1979
+ add_protocol_rse_parser.add_argument('--web-service-path', dest='web_service_path', action='store', help='Web service URL (SRM-only)')
1980
+ add_protocol_rse_parser.add_argument('--port', dest='port', action='store', type=int, help='URL port')
1981
+ add_protocol_rse_parser.add_argument('--impl', dest='impl', default='rucio.rse.protocols.gfal.Default', action='store', help='Transfer protocol implementation to use')
1982
+ add_protocol_rse_parser.add_argument('--domain-json', dest='domain_json', action='store', type=json.loads, help='JSON describing the WAN / LAN setup')
1983
+ add_protocol_rse_parser.add_argument('--extended-attributes-json', dest='ext_attr_json', action='store', type=json.loads, help='JSON describing any extended attributes')
1984
+
1985
+ # The del_protocol_rse command
1986
+ del_protocol_rse_parser = rse_subparser.add_parser('delete-protocol',
1987
+ help='Delete a protocol from a RSE.',
1988
+ formatter_class=argparse.RawDescriptionHelpFormatter,
1989
+ epilog='Usage example\n'
1990
+ '"""""""""""""\n'
1991
+ '::\n'
1992
+ '\n'
1993
+ ' $ rucio-admin rse delete-protocol --scheme gsiftp JDOE_DATADISK\n'
1994
+ '\n'
1995
+ 'Note: no printed stdout.\n'
1996
+ '\n')
1997
+ del_protocol_rse_parser.set_defaults(which='del_protocol_rse')
1998
+ del_protocol_rse_parser.add_argument(dest='rse', action='store', help='RSE name')
1999
+ del_protocol_rse_parser.add_argument('--hostname', dest='hostname', action='store', help='Endpoint hostname')
2000
+ del_protocol_rse_parser.add_argument('--scheme', dest='scheme', action='store', help='Endpoint URL scheme', required=True)
2001
+ del_protocol_rse_parser.add_argument('--port', dest='port', action='store', type=int, help='URL port')
2002
+
2003
+ # The disable_location command
2004
+ disable_rse_parser = rse_subparser.add_parser('delete',
2005
+ help='Disable RSE.',
2006
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2007
+ epilog='Usage example\n'
2008
+ '"""""""""""""\n'
2009
+ '::\n'
2010
+ '\n'
2011
+ ' $ rucio-admin rse delete JDOE_SCRATCHDISK\n'
2012
+ '\n'
2013
+ 'Note: no printed stdout.\n'
2014
+ 'CAUTION: all information about the RSE might be lost!\n'
2015
+ '\n')
2016
+ disable_rse_parser.set_defaults(which='disable_rse')
2017
+ disable_rse_parser.add_argument('rse', action='store', help='RSE name')
2018
+
2019
+ # The add_qos_policy command
2020
+ add_qos_policy_parser = rse_subparser.add_parser('add-qos-policy',
2021
+ help='Add a QoS policy to an RSE.',
2022
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2023
+ epilog='Usage example\n'
2024
+ '"""""""""""""\n'
2025
+ '\n'
2026
+ ' $ rucio-admin rse add-qos-policy JDOE_DATADISK SLOW_BUT_CHEAP')
2027
+ add_qos_policy_parser.set_defaults(which='add_qos_policy')
2028
+ add_qos_policy_parser.add_argument('rse', action='store', help='RSE name')
2029
+ add_qos_policy_parser.add_argument('qos_policy', action='store', help='QoS policy')
2030
+
2031
+ # The delete_qos_policy command
2032
+ delete_qos_policy_parser = rse_subparser.add_parser('delete-qos-policy',
2033
+ help='Delete a QoS policy from an RSE.',
2034
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2035
+ epilog='Usage example\n'
2036
+ '"""""""""""""\n'
2037
+ '\n'
2038
+ ' $ rucio-admin rse delete-qos-policy JDOE_DATADISK SLOW_BUT_CHEAP')
2039
+ delete_qos_policy_parser.set_defaults(which='delete_qos_policy')
2040
+ delete_qos_policy_parser.add_argument('rse', action='store', help='RSE name')
2041
+ delete_qos_policy_parser.add_argument('qos_policy', action='store', help='QoS policy')
2042
+
2043
+ # The delete_qos_policy command
2044
+ list_qos_policies_parser = rse_subparser.add_parser('list-qos-policies',
2045
+ help='List all QoS policies of an RSE.',
2046
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2047
+ epilog='Usage example\n'
2048
+ '"""""""""""""\n'
2049
+ '\n'
2050
+ ' $ rucio-admin rse list-qos-policies JDOE_DATADISK')
2051
+ list_qos_policies_parser.set_defaults(which='list_qos_policies')
2052
+ list_qos_policies_parser.add_argument('rse', action='store', help='RSE name')
2053
+
2054
+ # The set_limit_rse command
2055
+ set_limit_rse_parser = rse_subparser.add_parser('set-limit',
2056
+ help='Set a RSE limit',
2057
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2058
+ epilog='Usage example\n'
2059
+ '"""""""""""""\n'
2060
+ '\n'
2061
+ ' $ rucio-admin rse set-limit XRD1 MinFreeSpace 10000')
2062
+ set_limit_rse_parser.set_defaults(which='set_limit_rse')
2063
+ set_limit_rse_parser.add_argument('rse', action='store', help='RSE name')
2064
+ set_limit_rse_parser.add_argument('name', action='store', help='Name of the limit')
2065
+ set_limit_rse_parser.add_argument('value', action='store', help='Value of the limit')
2066
+
2067
+ # The delete_limit_rse command
2068
+ set_limit_rse_parser = rse_subparser.add_parser('delete-limit',
2069
+ help='Delete a RSE limit',
2070
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2071
+ epilog='Usage example\n'
2072
+ '"""""""""""""\n'
2073
+ '\n'
2074
+ ' $ rucio-admin rse delete-limit XRD3 MinFreeSpace')
2075
+ set_limit_rse_parser.set_defaults(which='delete_limit_rse')
2076
+ set_limit_rse_parser.add_argument('rse', action='store', help='RSE name')
2077
+ set_limit_rse_parser.add_argument('name', action='store', help='Name of the limit')
2078
+
2079
+ # The scope subparser
2080
+ scope_parser = subparsers.add_parser('scope', help='Scope methods')
2081
+ scope_subparser = scope_parser.add_subparsers(dest='scope_subcommand', **required_arg)
2082
+
2083
+ # The add_scope command
2084
+ add_scope_parser = scope_subparser.add_parser('add',
2085
+ help='Add scope.',
2086
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2087
+ epilog='Usage example\n'
2088
+ '"""""""""""""\n'
2089
+ '::\n'
2090
+ '\n'
2091
+ ' $ rucio-admin scope add --scope user.jdoe --account jdoe\n'
2092
+ ' Added new scope to account: user.jdoe-jdoe\n'
2093
+ '\n')
2094
+ add_scope_parser.set_defaults(which='add_scope')
2095
+ add_scope_parser.add_argument('--account', dest='account', action='store', help='Account name', required=True)
2096
+ add_scope_parser.add_argument('--scope', dest='scope', action='store', help='Scope name', required=True)
2097
+
2098
+ # The list_scope command
2099
+ list_scope_parser = scope_subparser.add_parser('list',
2100
+ help='List scopes.',
2101
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2102
+ epilog='Usage example\n'
2103
+ '"""""""""""""\n'
2104
+ '::\n'
2105
+ '\n'
2106
+ ' $ rucio-admin scope list --account jdoe\n'
2107
+ ' user.jdoe\n'
2108
+ '\n'
2109
+ 'Note: alternatively: rucio list-scopes.\n'
2110
+ '\n')
2111
+ list_scope_parser.set_defaults(which='list_scopes')
2112
+ list_scope_parser.add_argument('--account', dest='account', action='store', help='Account name')
2113
+
2114
+ # The config subparser
2115
+ config_parser = subparsers.add_parser('config',
2116
+ help='Configuration methods. The global configuration of data management system can by modified.',
2117
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2118
+ epilog='''e.g. quotas, daemons, rses''')
2119
+ config_subparser = config_parser.add_subparsers(dest='config_subcommand', **required_arg)
2120
+
2121
+ # The get_config command
2122
+ get_config_parser = config_subparser.add_parser('get',
2123
+ help='Get matching configuration.',
2124
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2125
+ epilog='Usage example\n'
2126
+ '"""""""""""""\n'
2127
+ '::\n'
2128
+ '\n'
2129
+ ' $ rucio-admin config get --section quota\n'
2130
+ ' [quota]\n'
2131
+ ' LOCALGROUPDISK=95\n'
2132
+ ' SCRATCHDISK=30\n'
2133
+ ' USERDISK=30\n'
2134
+ '\n'
2135
+ 'Note: to list other sections: rucio-admin config get.\n'
2136
+ '\n')
2137
+ get_config_parser.set_defaults(which='get_config')
2138
+ get_config_parser.add_argument('--section', dest='section', action='store', help='Section name', required=False)
2139
+ get_config_parser.add_argument('--option', dest='option', action='store', help='Option name', required=False)
2140
+
2141
+ # The set_config_option command
2142
+ set_config_parser = config_subparser.add_parser('set',
2143
+ help='Set matching configuration.',
2144
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2145
+ epilog='Usage example\n'
2146
+ '"""""""""""""\n'
2147
+ '::\n'
2148
+ '\n'
2149
+ ' $ rucio-admin config set --section limitsscratchdisk --option testlimit --value 30\n'
2150
+ ' Set configuration: limitsscratchdisk.testlimit=30\n'
2151
+ '\n'
2152
+ 'CAUTION: you might not intend to change global configuration!\n'
2153
+ '\n')
2154
+ set_config_parser.set_defaults(which='set_config_option')
2155
+ set_config_parser.add_argument('--section', dest='section', action='store', help='Section name', required=True)
2156
+ set_config_parser.add_argument('--option', dest='option', action='store', help='Option name', required=True)
2157
+ set_config_parser.add_argument('--value', dest='value', action='store', help='String-encoded value', required=True)
2158
+
2159
+ # The delete_config_option command
2160
+ delete_config_parser = config_subparser.add_parser('delete',
2161
+ help='Delete matching configuration.',
2162
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2163
+ epilog='Usage example\n'
2164
+ '"""""""""""""\n'
2165
+ '::\n'
2166
+ '\n'
2167
+ ' $ rucio-admin config delete --section limitsscratchdisk --option testlimit\n'
2168
+ ' Deleted section \'limitsscratchdisk\' option \'testlimit\'\n'
2169
+ '\n'
2170
+ 'CAUTION: you might not intend to change global configuration!\n'
2171
+ '\n')
2172
+ delete_config_parser.set_defaults(which='delete_config_option')
2173
+ delete_config_parser.add_argument('--section', dest='section', action='store', help='Section name', required=True)
2174
+ delete_config_parser.add_argument('--option', dest='option', action='store', help='Option name', required=True)
2175
+
2176
+ # The subscription parser
2177
+ subs_parser = subparsers.add_parser('subscription', help='Subscription methods. The methods for automated and regular processing of some specific rules.')
2178
+ subs_subparser = subs_parser.add_subparsers(dest='subscription_subcommand', **required_arg)
2179
+
2180
+ # The add-subscription command
2181
+ add_sub_parser = subs_subparser.add_parser('add',
2182
+ help='Add subscription',
2183
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2184
+ epilog='Usage example\n'
2185
+ '"""""""""""""\n'
2186
+ '::\n'
2187
+ '\n'
2188
+ ' $ rucio-admin subscription add --lifetime 2 --account jdoe --priority 1 jdoes_txt_files_on_datadisk\n'
2189
+ ' \'{\"scope\": [\"user.jdoe\"], \"datatype\": [\"txt\"]}\' \'[{\"copies\": 1, \"rse_expression\": \"JDOE_DATADISK\", \"lifetime\": 3600, \"activity\": \"User Subscriptions\"}]\'\n'
2190
+ ' \'keeping replica on jdoes disk for 60 mins\'\n'
2191
+ ' Subscription added 9a89cc8e692f4cabb8836fdafd884c5a\n'
2192
+ '\n'
2193
+ 'Note: priority can range from 1 to infinity. Internal share for given account.\n'
2194
+ '\n')
2195
+ add_sub_parser.set_defaults(which='add_subscription')
2196
+ add_sub_parser.add_argument(dest='name', action='store', help='Subscription name')
2197
+ add_sub_parser.add_argument(dest='filter', action='store', help='DID filter (eg \'{"scope": ["tests"], "project": ["data12_8TeV"]}\')')
2198
+ add_sub_parser.add_argument(dest='replication_rules', action='store', help='Replication rules (eg \'[{"copies": 2, "rse_expression": "tier=2", "lifetime": 3600, "activity": "Functional Tests", "weight": "mou"}]\')')
2199
+ add_sub_parser.add_argument(dest='comments', action='store', help='Comments on subscription')
2200
+ add_sub_parser.add_argument('--lifetime', dest='lifetime', action='store', type=int, help='Subscription lifetime (in days)')
2201
+ add_sub_parser.add_argument('--account', dest='subs_account', action='store', help='Account name')
2202
+ add_sub_parser.add_argument('--priority', dest='priority', action='store', help='The priority of the subscription')
2203
+ # retroactive and dry_run hard-coded for now
2204
+
2205
+ # The list-subscriptions command
2206
+ list_sub_parser = subs_subparser.add_parser('list',
2207
+ help='List subscriptions',
2208
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2209
+ epilog='Usage example\n'
2210
+ '"""""""""""""\n'
2211
+ '::\n'
2212
+ '\n'
2213
+ ' $ rucio-admin subscription list --account jdoe\n'
2214
+ ' jdoe: jdoes_txt_files_on_datadisk UPDATED\n'
2215
+ ' priority: 1\n'
2216
+ ' filter: {\'datatype\': [\'txt\'], \'scope\': [\'user.jdoe\']}\n'
2217
+ ' rules: [{\'lifetime\': 3600, \'rse_expression\': \'JDOE_DATADISK\', \'copies\': 1, \'activity\': \'User Subscriptions\'}]\n'
2218
+ ' comments: keeping replica on jdoes disk for 60 mins\n'
2219
+ '\n')
2220
+ list_sub_parser.set_defaults(which='list_subscriptions')
2221
+ list_sub_parser.add_argument('--account', dest='subs_account', action='store', help='Account name')
2222
+ list_sub_parser.add_argument('--long', dest='long', action='store_true', help='Long listing')
2223
+ list_sub_parser.add_argument(dest='name', nargs='?', action='store', help='Subscription name')
2224
+
2225
+ # The update-subscription command
2226
+ update_sub_parser = subs_subparser.add_parser('update',
2227
+ help='Update subscription',
2228
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2229
+ epilog='Usage example\n'
2230
+ '"""""""""""""\n'
2231
+ '::\n'
2232
+ '\n'
2233
+ ' $ rucio-admin subscription update --lifetime 3 --account jdoe --priority 1 jdoes_txt_files_on_datadisk\n'
2234
+ ' \'{\"scope\": [\"user.jdoe\"], \"datatype\": [\"txt\"]}\' \'[{\"copies\": 1, \"rse_expression\": \"JDOE_DATADISK\", \"lifetime\": 3600, \"activity\": \"User Subscriptions\"}]\n'
2235
+ ' keeping replica on jdoes disk for 60 mins, valid until 23.2.2018\n'
2236
+ '\n'
2237
+ 'Note: no printed stdout.\n'
2238
+ 'Note: all the input parameters are mandatory.\n'
2239
+ '::\n'
2240
+ '\n'
2241
+ ' $ rucio-admin subscription list --account jdoe\n'
2242
+ ' jdoe: jdoes_txt_files_on_datadisk UPDATED\n'
2243
+ ' priority: 1\n'
2244
+ ' filter: {\"datatype\": [\"txt\"], \"scope\": [\"user.jdoe\"]}\n'
2245
+ ' rules: [{\"lifetime\": 3600, \"rse_expression\": \"JDOE_DATADISK\", \"copies\": 1, \"activity\": \"User Subscriptions\"}]\n'
2246
+ ' comments: keeping replica on jdoes disk for 60 mins, valid until 23.2.2018\n'
2247
+ '\n')
2248
+ update_sub_parser.set_defaults(which='update_subscription')
2249
+ update_sub_parser.add_argument(dest='name', action='store', help='Subscription name')
2250
+ update_sub_parser.add_argument(dest='filter', action='store', help='DID filter (eg \'{"scope": ["tests"], "project": ["data12_8TeV"]}\')')
2251
+ update_sub_parser.add_argument(dest='replication_rules', action='store', help='Replication rules (eg \'[{"activity": "Functional Tests", "copies": 2, "rse_expression": "tier=2", "lifetime": 3600, "weight": "mou"}]\')')
2252
+ update_sub_parser.add_argument(dest='comments', action='store', help='Comments on subscription')
2253
+ update_sub_parser.add_argument('--lifetime', dest='lifetime', action='store', type=int, help='Subscription lifetime (in days)')
2254
+ update_sub_parser.add_argument('--account', dest='subs_account', action='store', help='Account name')
2255
+ update_sub_parser.add_argument('--priority', dest='priority', action='store', help='The priority of the subscription')
2256
+ # subscription policy, retroactive and dry_run hard-coded for now
2257
+
2258
+ # The reevaluate command
2259
+ reevaluate_did_for_subscription_parser = subs_subparser.add_parser('reevaluate',
2260
+ help='Reevaluate a list of DIDs against all active subscriptions',
2261
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2262
+ epilog='Usage example\n'
2263
+ '"""""""""""""\n'
2264
+ '::\n'
2265
+ '\n'
2266
+ ' $ rucio-admin subscription reevaluate user.jdoe:jdoes.test.dataset\n'
2267
+ '\n'
2268
+ 'Note: no printed stdout.\n'
2269
+ '\n')
2270
+ reevaluate_did_for_subscription_parser.set_defaults(which='reevaluate_did_for_subscription')
2271
+ reevaluate_did_for_subscription_parser.add_argument(dest='dids', action='store', help='List of DIDs (coma separated)')
2272
+
2273
+ # The replica parser
2274
+ rep_parser = subparsers.add_parser('replicas', help='Replica methods')
2275
+ rep_subparser = rep_parser.add_subparsers(dest='replicas_subcommand', **required_arg)
2276
+
2277
+ # The add-quarantined command
2278
+ quarantine_parser = rep_subparser.add_parser('quarantine', help="Add quarantined replicas",
2279
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2280
+ epilog=dedent("""\
2281
+ Usage example
2282
+ =============
2283
+ ::
2284
+ $ cat replica_list.txt
2285
+ /path/to/file_1.data
2286
+ /path/to/another/file.data
2287
+ $ rucio admin replicas quarantine --rse STORAGE --paths replica_list.txt
2288
+
2289
+ $ rucio admin replicas quarantine --rse STORAGE /path/to/a/data_file /path/to/some/other/file
2290
+ """))
2291
+ quarantine_parser.set_defaults(which='quarantine_replicas')
2292
+ quarantine_parser.add_argument("--paths", dest="paths_file", action="store", help="A file with replica paths, one path per line")
2293
+ quarantine_parser.add_argument("--rse", dest="rse", action="store", help="RSE name")
2294
+ quarantine_parser.add_argument(dest='paths_list', action='store', nargs='*', help='List of replica paths')
2295
+
2296
+ # The declare-bad command
2297
+ declare_bad_file_replicas_parser = rep_subparser.add_parser('declare-bad',
2298
+ help='Declare bad file replicas',
2299
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2300
+ epilog='Usage example\n'
2301
+ '"""""""""""""\n'
2302
+ '::\n'
2303
+ '\n'
2304
+ ' $ rucio-admin replicas declare-bad\n'
2305
+ ' srm://se.bfg.uni-freiburg.de:8443/srm/managerv2?SFN=/pnfs/bfg.uni-freiburg.de/data/atlasdatadisk/rucio/user/jdoe/e2/a7/jdoe.TXT.txt --reason \'test only\'\n'
2306
+ '\n'
2307
+ 'Note: no printed stdout.\n'
2308
+ '\n'
2309
+ 'Note: pfn can be provided, see rucio-admin replicas list-pfns or rucio list-file-replicas\n'
2310
+ '\n')
2311
+ declare_bad_file_replicas_parser.set_defaults(which='declare_bad_file_replicas')
2312
+ declare_bad_file_replicas_parser.add_argument(dest='listbadfiles', action='store', nargs='*', help='List of bad items. Each can be a PFN (for one replica) or an LFN (for all replicas of the LFN) or a collection DID (for all file replicas in the DID)')
2313
+ declare_bad_file_replicas_parser.add_argument('--reason', dest='reason', required=True, action='store', help='Reason')
2314
+ declare_bad_file_replicas_parser.add_argument('--inputfile', dest='inputfile', nargs='?', action='store', help='File containing list of bad items')
2315
+ declare_bad_file_replicas_parser.add_argument('--allow-collection', dest='allow_collection', action='store_true', help='Allow passing a collection DID as bad item')
2316
+
2317
+ declare_bad_file_replicas_parser.add_argument('--lfns', dest='lfns', nargs='?', action='store', help='File containing list of LFNs for bad replicas. Requires --rse and --scope')
2318
+ declare_bad_file_replicas_parser.add_argument('--scope', dest='scope', nargs='?', action='store', help='Common scope for bad replicas specified with LFN list, ignored without --lfns')
2319
+ declare_bad_file_replicas_parser.add_argument('--rse', dest='rse', nargs='?', action='store', help='Common RSE for bad replicas specified with LFN list, ignored without --lfns')
2320
+
2321
+ # The declare-temporary-unavailable command
2322
+ declare_temporary_unavailable_replicas_parser = rep_subparser.add_parser('declare-temporary-unavailable',
2323
+ help='Declare temporary unavailable replicas',
2324
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2325
+ epilog='Usage example\n'
2326
+ '"""""""""""""\n'
2327
+ '::\n'
2328
+ '\n'
2329
+ ' $ rucio-admin replicas declare-temporary-unavailable\n'
2330
+ ' srm://se.bfg.uni-freiburg.de/pnfs/bfg.uni-freiburg.de/data/atlasdatadisk/rucio/user/jdoe/e2/a7/jdoe.TXT.txt --duration 3600 --reason \'test only\'\n')
2331
+ declare_temporary_unavailable_replicas_parser.set_defaults(which='declare_temporary_unavailable_replicas')
2332
+ declare_temporary_unavailable_replicas_parser.add_argument(dest='listbadfiles', action='store', nargs='*', help='List of replicas. Each needs to be a proper PFN including the protocol')
2333
+ declare_temporary_unavailable_replicas_parser.add_argument('--reason', dest='reason', required=True, action='store', help='Reason')
2334
+ declare_temporary_unavailable_replicas_parser.add_argument('--inputfile', dest='inputfile', nargs='?', action='store', help='File containing list of replicas')
2335
+ declare_temporary_unavailable_replicas_parser.add_argument('--expiration-date', '--duration', new_option_string='--duration', dest='duration', required=True, action=StoreAndDeprecateWarningAction, type=int, help='Timeout in seconds when the replicas will become available again.') # NOQA: E501
2336
+
2337
+ # The list-pfns command
2338
+ list_pfns_parser = rep_subparser.add_parser('list-pfns',
2339
+ help='List the possible PFN for a file at a site.',
2340
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2341
+ epilog='Usage example\n'
2342
+ '"""""""""""""\n'
2343
+ '::\n'
2344
+ '\n'
2345
+ ' $ rucio-admin replicas list-pfns \n'
2346
+ ' user.jdoe:jdoe.TXT.txt CERN-PROD_SCRATCHDISK srm \'{\"all_states\": False, \"schemes\": [\"srm\"], \"dids\": [{\"scope\": \"user.jdoe\", \"name\": \"jdoe.TXT.txt\"}]}\'\n'
2347
+ ' srm://srm-eosatlas.cern.ch:8443/srm/v2/server?SFN=/eos/atlas/atlasscratchdisk/rucio/user/jdoe/e2/a7/jdoe.TXT.txt'
2348
+ '\n')
2349
+ list_pfns_parser.set_defaults(which='list_pfns')
2350
+ list_pfns_parser.add_argument(dest='dids', action='store', help='List of DIDs (coma separated)')
2351
+ list_pfns_parser.add_argument(dest='rse', action='store', help='RSE')
2352
+ list_pfns_parser.add_argument(dest='protocol', action='store', default='srm', help='The protocol, by default srm, can be one of [root|srm|http(s)].')
2353
+
2354
+ # The set-tombstone command
2355
+ set_tombstone_parser = rep_subparser.add_parser('set-tombstone',
2356
+ help='Set a tombstone on a replica manually to force deletion. Only works if there is no lock on the replica.',
2357
+ formatter_class=argparse.RawDescriptionHelpFormatter,
2358
+ epilog='Usage example\n'
2359
+ '"""""""""""""\n'
2360
+ '::\n'
2361
+ '\n'
2362
+ ' $ rucio-admin replicas set-tombstone mock:file --rse MOCK'
2363
+ '\n')
2364
+ set_tombstone_parser.add_argument('dids', action='store', help='One or multiple comma separated DIDs.')
2365
+ set_tombstone_parser.add_argument('--rse', action='store', required=True, help='RSE')
2366
+ set_tombstone_parser.set_defaults(which='set_tombstone')
2367
+
2368
+ return oparser
2369
+
2370
+
2371
+ if __name__ == '__main__':
2372
+ oparser = get_parser()
2373
+ if EXTRA_MODULES['argcomplete']:
2374
+ argcomplete.autocomplete(oparser)
2375
+
2376
+ if len(sys.argv) == 1:
2377
+ oparser.print_help()
2378
+ sys.exit(FAILURE)
2379
+
2380
+ args = oparser.parse_args()
2381
+
2382
+ if not hasattr(args, 'which'):
2383
+ oparser.print_help()
2384
+ sys.exit(FAILURE)
2385
+
2386
+ commands = {'add_account': add_account,
2387
+ 'list_accounts': list_accounts,
2388
+ 'list_account_attributes': list_account_attributes,
2389
+ 'add_account_attribute': add_account_attribute,
2390
+ 'delete_account_attribute': delete_account_attribute,
2391
+ 'delete_account': delete_account,
2392
+ 'info_account': info_account,
2393
+ 'ban_account': ban_account,
2394
+ 'unban_account': unban_account,
2395
+ 'update_account': update_account,
2396
+ 'get_limits': get_limits,
2397
+ 'set_limits': set_limits,
2398
+ 'delete_limits': delete_limits,
2399
+ 'list_identities': list_identities,
2400
+ 'identity_add': identity_add,
2401
+ 'identity_delete': identity_delete,
2402
+ 'add_rse': add_rse,
2403
+ 'update_rse': update_rse,
2404
+ 'set_attribute_rse': set_attribute_rse,
2405
+ 'get_attribute_rse': get_attribute_rse,
2406
+ 'delete_attribute_rse': delete_attribute_rse,
2407
+ 'add_distance_rses': add_distance_rses,
2408
+ 'update_distance_rses': update_distance_rses,
2409
+ 'get_distance_rses': get_distance_rses,
2410
+ 'delete_distance_rses': delete_distance_rses,
2411
+ 'add_protocol_rse': add_protocol_rse,
2412
+ 'del_protocol_rse': del_protocol_rse,
2413
+ 'list_rses': list_rses,
2414
+ 'disable_rse': disable_rse,
2415
+ 'add_qos_policy': add_qos_policy,
2416
+ 'delete_qos_policy': delete_qos_policy,
2417
+ 'list_qos_policies': list_qos_policies,
2418
+ 'add_scope': add_scope,
2419
+ 'list_scopes': list_scopes,
2420
+ 'info_rse': info_rse,
2421
+ 'get_config': get_config,
2422
+ 'set_config_option': set_config_option,
2423
+ 'delete_config_option': delete_config_option,
2424
+ 'add_subscription': add_subscription,
2425
+ 'list_subscriptions': list_subscriptions,
2426
+ 'update_subscription': update_subscription,
2427
+ 'reevaluate_did_for_subscription': reevaluate_did_for_subscription,
2428
+ 'declare_bad_file_replicas': declare_bad_file_replicas,
2429
+ 'quarantine_replicas': quarantine_replicas,
2430
+ 'declare_temporary_unavailable_replicas': declare_temporary_unavailable_replicas,
2431
+ 'list_pfns': list_pfns,
2432
+ 'import': import_data,
2433
+ 'export': export_data,
2434
+ 'set_tombstone': set_tombstone,
2435
+ 'set_limit_rse': set_limit_rse,
2436
+ 'delete_limit_rse': delete_limit_rse,
2437
+ }
2438
+
2439
+ if args.verbose:
2440
+ logger.setLevel(logging.DEBUG)
2441
+ start_time = time.time()
2442
+ command = commands.get(args.which)
2443
+ result = command(args)
2444
+ end_time = time.time()
2445
+ if args.verbose:
2446
+ print("Completed in %-0.4f sec." % (end_time - start_time))
2447
+ sys.exit(result)