Revision ec6f741b snf-pithos-backend/pithos/backends/modular.py

b/snf-pithos-backend/pithos/backends/modular.py
120 120
ULTIMATE_ANSWER = 42
121 121

  
122 122
DEFAULT_SOURCE = 'system'
123
DEFAULT_DISKSPACE_RESOURCE = 'pithos.diskspace'
123 124

  
124 125
logger = logging.getLogger(__name__)
125 126

  
......
339 340
        start, limit = self._list_limits(allowed, marker, limit)
340 341
        return allowed[start:start + limit]
341 342

  
343
    def _get_account_quotas(self, account):
344
        """Get account usage from astakos."""
345

  
346
        quotas = self.astakosclient.service_get_quotas(account)[account]
347
        return quotas.get(DEFAULT_SOURCE, {}).get(DEFAULT_DISKSPACE_RESOURCE,
348
                                                  {})
349

  
342 350
    @debug_method
343 351
    @backend_method
344
    def get_account_meta(
345
            self, user, account, domain, until=None, include_user_defined=True,
346
            external_quota=None):
352
    def get_account_meta(self, user, account, domain, until=None,
353
                         include_user_defined=True):
347 354
        """Return a dictionary with the account metadata for the domain."""
348 355

  
349 356
        path, node = self._lookup_account(account, user == account)
......
377 384
                meta.update({'until_timestamp': tstamp})
378 385
            meta.update({'name': account, 'count': count, 'bytes': bytes})
379 386
            if self.using_external_quotaholder:
380
                external_quota = external_quota or {}
387
                external_quota = self._get_account_quotas(account)
381 388
                meta['bytes'] = external_quota.get('usage', 0)
382 389
        meta.update({'modified': modified})
383 390
        return meta
......
424 431

  
425 432
    @debug_method
426 433
    @backend_method
427
    def get_account_policy(self, user, account, external_quota=None):
434
    def get_account_policy(self, user, account):
428 435
        """Return a dictionary with the account policy."""
429 436

  
430 437
        if user != account:
......
434 441
        path, node = self._lookup_account(account, True)
435 442
        policy = self._get_policy(node, is_account_policy=True)
436 443
        if self.using_external_quotaholder:
437
            external_quota = external_quota or {}
444
            external_quota = self._get_account_quotas(account)
438 445
            policy['quota'] = external_quota.get('limit', 0)
439 446
        return policy
440 447

  

Also available in: Unified diff