コード例 #1
0
ファイル: account.py プロジェクト: pombredanne/rucio
def add_account(account, type, issuer):
    """
    Creates an account with the provided account name, contact information, etc.

    :param account: The account name.
    :param type: The account type
    :param issuer: The issuer account_core.

    """

    validate_schema(name="account", obj=account)

    kwargs = {"account": account, "type": type}
    if not rucio.api.permission.has_permission(issuer=issuer, action="add_account", kwargs=kwargs):
        raise rucio.common.exception.AccessDenied("Account %s can not add account" % (issuer))

    account_core.add_account(account, AccountType.from_sym(type))
コード例 #2
0
ファイル: account.py プロジェクト: pombredanne/rucio
def list_accounts(filter={}, session=None):
    """ Returns a list of all account names.

    :param filter: Dictionary of attributes by which the input data should be filtered
    :param session: the database session in use.

    returns: a list of all account names.
    """
    query = session.query(models.Account.account, models.Account.account_type,
                          models.Account.email).filter_by(status=AccountStatus.ACTIVE)
    if filter:
        if 'account_type' in filter:
            if (isinstance(filter['account_type'], str) or isinstance(filter['account_type'], unicode)):
                query = query.filter_by(account_type=AccountType.from_sym(filter['account_type']))
            elif isinstance(filter['account_type'], EnumSymbol):
                query = query.filter_by(account_type=filter['account_type'])

        if 'identity' in filter:
            query = query.join(models.IdentityAccountAssociation, models.Account.account == models.IdentityAccountAssociation.account).\
                filter(models.IdentityAccountAssociation.identity == filter['identity'])

    for account, account_type, email in query.order_by(models.Account.account).yield_per(25):
        yield {'account': account, 'type': account_type, 'email': email}