def test_get_global_account_usage(self): """ ACCOUNT_LIMIT (CORE): Get global account usage. """ limit1 = 10 limit2 = 20 account_limit.set_global_account_limit(self.account, 'MOCK|MOCK2', limit1) account_limit.set_global_account_limit(self.account, 'MOCK4|MOCK3', limit2) results = account_limit.get_global_account_usage(account=self.account) assert len(results) == 2 results = account_limit.get_global_account_usage(account=self.account, rse_expression='MOCK|MOCK2') assert len(results) == 1
def test_get_global_account_usage(self): """ ACCOUNT_LIMIT (CORE): Get global account usage. """ rse_exp1 = 'MOCK|MOCK2' rse_exp2 = 'MOCK4|MOCK3' limit1 = 10 limit2 = 20 account_limit.set_global_account_limit(self.account, rse_exp1, limit1) account_limit.set_global_account_limit(self.account, rse_exp2, limit2) results = account_limit.get_global_account_usage(account=self.account) assert_equal(len(results), 2) results = account_limit.get_global_account_usage( account=self.account, rse_expression=rse_exp1) assert_equal(len(results), 1)
def get_global_account_usage(account, rse_expression, issuer, vo='def'): """ Get the account usage and connect it with (if available) the account limits of the account. :param account: The account to read. :param rse_expression: The rse expression to read (If none, get all). :param issuer: The issuer account. :param vo: The VO to act on. :returns: List of dicts {'rse_id', 'bytes_used', 'files_used', 'bytes_limit'} """ kwargs = {'account': account, 'rse_expression': rse_expression} if not rucio.api.permission.has_permission( issuer=issuer, vo=vo, action='get_global_account_usage', kwargs=kwargs): raise rucio.common.exception.AccessDenied( 'Account %s can not list global account usage.' % (issuer)) account = InternalAccount(account, vo=vo) if not account_exists(account=account): raise rucio.common.exception.AccountNotFound( 'Account %s does not exist' % (account)) return [ api_update_return_dict(d) for d in account_limit_core.get_global_account_usage( account=account, rse_expression=rse_expression) ]