Skip to content

Commit

Permalink
Rules: added option to update comment in update_rule command Fix ruci…
Browse files Browse the repository at this point in the history
  • Loading branch information
dynamic-entropy committed Mar 20, 2021
1 parent 54830db commit 21a32ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bin/rucio
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,8 @@ def update_rule(args):
options['locked'] = True
elif args.locked == "False":
options['locked'] = False
if args.comment:
options['comment'] = args.comment
if args.rule_account:
options['account'] = args.rule_account
if args.state_stuck:
Expand Down Expand Up @@ -2285,6 +2287,7 @@ You can filter by account::
update_rule_parser.add_argument('--suspend', dest='state_suspended', action='store_true', help='Set state to SUSPENDED.')
update_rule_parser.add_argument('--activity', dest='rule_activity', action='store', help='Activity of the rule.')
update_rule_parser.add_argument('--source-replica-expression', dest='source_replica_expression', action='store', help='Source replica expression of the rule.')
update_rule_parser.add_argument('--comment', dest='comment', action='store', help="Update comment for the rule")
update_rule_parser.add_argument('--cancel-requests', dest='cancel_requests', action='store_true', help='Cancel requests when setting rules to stuck.')
update_rule_parser.add_argument('--priority', dest='priority', action='store', help='Priority of the requests of the rule.')
update_rule_parser.add_argument('--child-rule-id', dest='child_rule_id', action='store', help='Child rule id of the rule.')
Expand Down
8 changes: 6 additions & 2 deletions lib/rucio/core/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ def add_rule(dids, account, copies, rse_expression, grouping, weight, lifetime,
insert_rule_history(rule=new_rule, recent=True, longterm=True, session=session)

if use_new_rule_algorithm:
logger(logging.INFO, "Created rule %s [%d/%d/%d] with new algorithm for did %s:%s in state %s", str(new_rule.id), new_rule.locks_ok_cnt, new_rule.locks_replicating_cnt, new_rule.locks_stuck_cnt, new_rule.scope, new_rule.name, str(new_rule.state))
logger(logging.INFO, "Created rule %s [%d/%d/%d] with new algorithm for did %s:%s in state %s", str(new_rule.id), new_rule.locks_ok_cnt,
new_rule.locks_replicating_cnt, new_rule.locks_stuck_cnt, new_rule.scope, new_rule.name, str(new_rule.state))
else:
logger(logging.INFO, "Created rule %s [%d/%d/%d] for did %s:%s in state %s", str(new_rule.id), new_rule.locks_ok_cnt, new_rule.locks_replicating_cnt, new_rule.locks_stuck_cnt, new_rule.scope, new_rule.name, str(new_rule.state))

Expand Down Expand Up @@ -1282,7 +1283,7 @@ def update_rule(rule_id, options, session=None):
:raises: RuleNotFound if no Rule can be found, InputValidationError if invalid option is used, ScratchDiskLifetimeConflict if wrong ScratchDiskLifetime is used.
"""

valid_options = ['locked', 'lifetime', 'account', 'state', 'activity', 'source_replica_expression', 'cancel_requests', 'priority', 'child_rule_id', 'eol_at', 'meta', 'purge_replicas']
valid_options = ['comment', 'locked', 'lifetime', 'account', 'state', 'activity', 'source_replica_expression', 'cancel_requests', 'priority', 'child_rule_id', 'eol_at', 'meta', 'purge_replicas']

for key in options:
if key not in valid_options:
Expand All @@ -1303,6 +1304,9 @@ def update_rule(rule_id, options, session=None):
if key == 'source_replica_expression':
rule.source_replica_expression = options['source_replica_expression']

if key == 'comment':
rule.comments = options['comment']

if key == 'activity':
validate_schema('activity', options['activity'], vo=rule.account.vo)
rule.activity = options['activity']
Expand Down

0 comments on commit 21a32ab

Please sign in to comment.