BACKEND_BLOCK_UMASK,
BACKEND_QUEUE_MODULE, BACKEND_QUEUE_HOSTS,
BACKEND_QUEUE_EXCHANGE,
+ PITHOS_QUOTAHOLDER_URL,
BACKEND_QUOTA, BACKEND_VERSIONING,
AUTHENTICATION_URL, AUTHENTICATION_USERS,
SERVICE_TOKEN, COOKIE_NAME)
block_umask=BACKEND_BLOCK_UMASK,
queue_module=BACKEND_QUEUE_MODULE,
queue_hosts=BACKEND_QUEUE_HOSTS,
- queue_exchange=BACKEND_QUEUE_EXCHANGE)
+ queue_exchange=BACKEND_QUEUE_EXCHANGE,
+ quotaholder_url=PITHOS_QUOTAHOLDER_URL)
backend.default_policy['quota'] = BACKEND_QUOTA
backend.default_policy['versioning'] = BACKEND_VERSIONING
return backend
import hashlib
import binascii
+from commissioning.clients.quotaholder import QuotaholderHTTP
+
from base import DEFAULT_QUOTA, DEFAULT_VERSIONING, NotAllowedError, QuotaError, BaseBackend, \
AccountExists, ContainerExists, AccountNotEmpty, ContainerNotEmpty, ItemNotExists, VersionNotExists
def __init__(self, db_module=None, db_connection=None,
block_module=None, block_path=None, block_umask=None,
queue_module=None, queue_hosts=None,
- queue_exchange=None):
+ queue_exchange=None, quotaholder_url=None):
db_module = db_module or DEFAULT_DB_MODULE
db_connection = db_connection or DEFAULT_DB_CONNECTION
block_module = block_module or DEFAULT_BLOCK_MODULE
#queue_module = queue_module or DEFAULT_QUEUE_MODULE
#queue_hosts = queue_hosts or DEFAULT_QUEUE_HOSTS
#queue_exchange = queue_exchange or DEFAULT_QUEUE_EXCHANGE
-
+
self.hash_algorithm = 'sha256'
self.block_size = 4 * 1024 * 1024 # 4MB
if queue_module and queue_hosts:
self.queue_module = load_module(queue_module)
params = {'hosts': queue_hosts,
- 'exchange': queue_exchange,
+ 'exchange': queue_exchange,
'client_id': QUEUE_CLIENT_ID}
self.queue = self.queue_module.Queue(**params)
else:
self.queue = NoQueue()
+ self.quotaholder = QuotaholderHTTP('http://127.0.0.1/api/quotaholder/v')
+
def close(self):
self.wrapper.close()
self.queue.close()
account, QUEUE_INSTANCE_ID, 'diskspace',
float(size), details))
+ serial = self.quotaholder.issue_provision()
+ self.serial.append(serial)
+
def _report_object_change(self, user, account, path, details={}):
details.update({'user': user})
logger.debug("_report_object_change: %s %s %s %s", user,
account, path, details)
self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('object',),
- account, QUEUE_INSTANCE_ID, 'object', path, details))
+ account, QUEUE_INSTANCE_ID, 'object', path, details))
def _report_sharing_change(self, user, account, path, details={}):
logger.debug("_report_permissions_change: %s %s %s %s",
user, account, path, details)
details.update({'user': user})
self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('sharing',),
- account, QUEUE_INSTANCE_ID, 'sharing', path, details))
+ account, QUEUE_INSTANCE_ID, 'sharing', path, details))
# Policy functions.