Ejemplo n.º 1
0
def move_replication_rule(rule_id, rse_expression, issuer):
    """
    Move a replication rule to another RSE and, once done, delete the original one.

    :param rule_id:             Rule to be moved.
    :param rse_expression:      RSE expression of the new rule.
    :param session:             The DB Session.
    :raises:                    RuleNotFound, RuleReplaceFailed
    """
    kwargs = {'rule_id': rule_id, 'rse_expression': rse_expression}
    if not has_permission(issuer=issuer, action='move_rule', kwargs=kwargs):
        raise AccessDenied('Account %s can not move this replication rule.' % (issuer))
    return rule.move_rule(rule_id=rule_id, rse_expression=rse_expression)
Ejemplo n.º 2
0
def move_replication_rule(rule_id,
                          rse_expression,
                          override,
                          issuer,
                          vo='def',
                          session=None):
    """
    Move a replication rule to another RSE and, once done, delete the original one.

    :param rule_id:                    Rule to be moved.
    :param rse_expression:             RSE expression of the new rule.
    :param override:                   Configurations to update for the new rule.
    :param session:                    The DB Session.
    :param vo:                         The VO to act on.
    :raises:                           RuleNotFound, RuleReplaceFailed, InvalidRSEExpression, AccessDenied
    """
    kwargs = {
        'rule_id': rule_id,
        'rse_expression': rse_expression,
        'override': override,
    }

    if is_multi_vo(
            session=session) and not has_permission(issuer=issuer,
                                                    vo=vo,
                                                    action='access_rule_vo',
                                                    kwargs=kwargs,
                                                    session=session):
        raise AccessDenied('Account %s can not access rules at other VOs.' %
                           (issuer))
    if not has_permission(issuer=issuer,
                          vo=vo,
                          action='move_rule',
                          kwargs=kwargs,
                          session=session):
        raise AccessDenied('Account %s can not move this replication rule.' %
                           (issuer))

    return rule.move_rule(**kwargs, session=session)
Ejemplo n.º 3
0
def move_replication_rule(rule_id, rse_expression, issuer, vo='def'):
    """
    Move a replication rule to another RSE and, once done, delete the original one.

    :param rule_id:             Rule to be moved.
    :param rse_expression:      RSE expression of the new rule.
    :param session:             The DB Session.
    :param vo:                  The VO to act on.
    :raises:                    RuleNotFound, RuleReplaceFailed
    """
    kwargs = {'rule_id': rule_id, 'rse_expression': rse_expression}
    if not has_permission(
            issuer=issuer, vo=vo, action='move_rule', kwargs=kwargs):
        raise AccessDenied('Account %s can not move this replication rule.' %
                           (issuer))

    if vo != 'def':
        if rse_expression is not None:
            rse_expression = 'vo={}&({})'.format(vo, rse_expression)
        else:
            rse_expression = 'vo={}'.format(vo)

    return rule.move_rule(rule_id=rule_id, rse_expression=rse_expression)
Ejemplo n.º 4
0
def move_replication_rule(rule_id,
                          rse_expression,
                          activity,
                          source_replica_expression,
                          issuer,
                          vo='def'):
    """
    Move a replication rule to another RSE and, once done, delete the original one.

    :param rule_id:                    Rule to be moved.
    :param rse_expression:             RSE expression of the new rule.
    :param activity:                   Activity of the new rule.
    :param source_replica_expression:  Source-Replica-Expression of the new rule.
    :param session:                    The DB Session.
    :param vo:                         The VO to act on.
    :raises:                           RuleNotFound, RuleReplaceFailed, InvalidRSEExpression, AccessDenied
    """
    kwargs = {
        'rule_id': rule_id,
        'rse_expression': rse_expression,
        'activity': activity,
        'source_replica_expression': source_replica_expression
    }
    if is_multi_vo() and not has_permission(
            issuer=issuer, vo=vo, action='access_rule_vo', kwargs=kwargs):
        raise AccessDenied('Account %s can not access rules at other VOs.' %
                           (issuer))
    if not has_permission(
            issuer=issuer, vo=vo, action='move_rule', kwargs=kwargs):
        raise AccessDenied('Account %s can not move this replication rule.' %
                           (issuer))

    return rule.move_rule(rule_id=rule_id,
                          rse_expression=rse_expression,
                          activity=activity,
                          source_replica_expression=source_replica_expression)