rucio-clients 32.8.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rucio-clients might be problematic. Click here for more details.

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