Exemplo n.º 1
0
def import_accounts(accounts, vo='def', session=None):
    vo_filter = {'account': InternalAccount(account='*', vo=vo)}
    old_accounts = {account['account']: account for account in account_module.list_accounts(filter_=vo_filter, session=session)}
    missing_accounts = [account for account in accounts if account['account'] not in old_accounts]
    outdated_accounts = [account for account in accounts if account['account'] in old_accounts]
    to_be_removed_accounts = [old_account for old_account in old_accounts if old_account not in [account['account'] for account in accounts]]
    old_identities = identity_module.list_identities(session=session)
    old_identity_account = session.query(models.IdentityAccountAssociation.identity, models.IdentityAccountAssociation.identity_type, models.IdentityAccountAssociation.account).all()

    # add missing accounts
    for account_dict in missing_accounts:
        account = account_dict['account']
        email = account_dict['email']
        account_module.add_account(account=account, type_=AccountType.USER, email=email, session=session)
        identities = account_dict.get('identities', [])
        if identities:
            import_identities(identities, account, old_identities, old_identity_account, email, session=session)

    # remove left over accounts
    for account in to_be_removed_accounts:
        if account.external != 'root':
            account_module.del_account(account=account, session=session)

    # update existing accounts
    for account_dict in outdated_accounts:
        account = account_dict['account']
        email = account_dict['email']
        old_account = old_accounts[account]
        if email and old_account['email'] != email:
            account_module.update_account(account, key='email', value=email, session=session)

        identities = account_dict.get('identities', [])
        if identities:
            import_identities(identities, account, old_identities, old_identity_account, email, session=session)
Exemplo n.º 2
0
def list_accounts(filter={}):
    """
    Lists all the Rucio account names.

    REST API: http://<host>:<port>/rucio/accounts

    :param filter: Dictionary of attributes by which the input data should be filtered

    :returns: List of all accounts.
    """
    return account_core.list_accounts(filter=filter)
Exemplo n.º 3
0
def list_accounts(filter={}):
    """
    Lists all the Rucio account names.

    REST API: http://<host>:<port>/rucio/accounts

    :param filter: Dictionary of attributes by which the input data should be filtered

    :returns: List of all accounts.
    """
    return account_core.list_accounts(filter=filter)
Exemplo n.º 4
0
def list_accounts(filter={}, vo='def'):
    """
    Lists all the Rucio account names.

    REST API: http://<host>:<port>/rucio/accounts

    :param filter: Dictionary of attributes by which the input data should be filtered
    :param vo: The VO to act on.

    :returns: List of all accounts.
    """
    if 'account' in filter:
        filter['account'] = InternalAccount(filter['account'], vo=vo)
    else:
        filter['account'] = InternalAccount(account='*', vo=vo)
    for result in account_core.list_accounts(filter=filter):
        yield api_update_return_dict(result)
Exemplo n.º 5
0
def list_accounts(filter_={}, vo='def'):
    """
    Lists all the Rucio account names.

    REST API: http://<host>:<port>/rucio/accounts

    :param filter_: Dictionary of attributes by which the input data should be filtered
    :param vo: The VO to act on.

    :returns: List of all accounts.
    """
    # If filter is empty, create a new dict to avoid overwriting the function's default
    if not filter_:
        filter_ = {}

    if 'account' in filter_:
        filter_['account'] = InternalAccount(filter_['account'], vo=vo)
    else:
        filter_['account'] = InternalAccount(account='*', vo=vo)
    for result in account_core.list_accounts(filter_=filter_):
        yield api_update_return_dict(result)