Revision 7ee27246

b/snf-pithos-backend/pithos/backends/modular.py
37 37
import hashlib
38 38
import binascii
39 39

  
40
from astakosclient import AstakosClient
40
try:
41
    from astakosclient import AstakosClient
42
except ImportError:
43
    AstakosClient = None
41 44

  
42 45
from base import (DEFAULT_ACCOUNT_QUOTA, DEFAULT_CONTAINER_QUOTA,
43 46
                  DEFAULT_CONTAINER_VERSIONING, NotAllowedError, QuotaError,
44 47
                  BaseBackend, AccountExists, ContainerExists, AccountNotEmpty,
45 48
                  ContainerNotEmpty, ItemNotExists, VersionNotExists)
46 49

  
50

  
51
class DisabledAstakosClient(object):
52
    def __init__(self, *args, **kwargs):
53
        self.args = args
54
        self.kwargs = kwargs
55

  
56
    def __getattr__(self, name):
57
        m = ("AstakosClient has been disabled, "
58
             "yet an attempt to access it was made")
59
        raise AssertionError(m)
60

  
61

  
47 62
# Stripped-down version of the HashMap class found in tools.
48 63

  
49 64
class HashMap(list):
......
237 252

  
238 253
        self.astakos_url = astakos_url
239 254
        self.service_token = service_token
240
        self.astakosclient = AstakosClient(
241
            astakos_url,
242
            use_pool=True,
243
            pool_size=astakosclient_poolsize)
255

  
256
        if not astakos_url or not AstakosClient:
257
            self.astakosclient = DisabledAstakosClient(
258
                astakos_url,
259
                use_pool=True,
260
                pool_size=astakosclient_poolsize)
261
        else:
262
            self.astakosclient = AstakosClient(
263
                astakos_url,
264
                use_pool=True,
265
                pool_size=astakosclient_poolsize)
244 266

  
245 267
        self.serials = []
246 268
        self.messages = []
......
251 273

  
252 274
    @property
253 275
    def using_external_quotaholder(self):
254
        return True
276
        return not isinstance(self.astakosclient, DisabledAstakosClient)
255 277

  
256 278
    @backend_method
257 279
    def list_accounts(self, user, marker=None, limit=10000):

Also available in: Unified diff