39 |
39 |
import hashlib
|
40 |
40 |
import binascii
|
41 |
41 |
|
|
42 |
from commissioning.clients.quotaholder import QuotaholderHTTP
|
|
43 |
|
42 |
44 |
from base import DEFAULT_QUOTA, DEFAULT_VERSIONING, NotAllowedError, QuotaError, BaseBackend, \
|
43 |
45 |
AccountExists, ContainerExists, AccountNotEmpty, ContainerNotEmpty, ItemNotExists, VersionNotExists
|
44 |
46 |
|
... | ... | |
129 |
131 |
def __init__(self, db_module=None, db_connection=None,
|
130 |
132 |
block_module=None, block_path=None, block_umask=None,
|
131 |
133 |
queue_module=None, queue_hosts=None,
|
132 |
|
queue_exchange=None):
|
|
134 |
queue_exchange=None, quotaholder_url=None):
|
133 |
135 |
db_module = db_module or DEFAULT_DB_MODULE
|
134 |
136 |
db_connection = db_connection or DEFAULT_DB_CONNECTION
|
135 |
137 |
block_module = block_module or DEFAULT_BLOCK_MODULE
|
... | ... | |
138 |
140 |
#queue_module = queue_module or DEFAULT_QUEUE_MODULE
|
139 |
141 |
#queue_hosts = queue_hosts or DEFAULT_QUEUE_HOSTS
|
140 |
142 |
#queue_exchange = queue_exchange or DEFAULT_QUEUE_EXCHANGE
|
141 |
|
|
|
143 |
|
142 |
144 |
self.hash_algorithm = 'sha256'
|
143 |
145 |
self.block_size = 4 * 1024 * 1024 # 4MB
|
144 |
146 |
|
... | ... | |
171 |
173 |
if queue_module and queue_hosts:
|
172 |
174 |
self.queue_module = load_module(queue_module)
|
173 |
175 |
params = {'hosts': queue_hosts,
|
174 |
|
'exchange': queue_exchange,
|
|
176 |
'exchange': queue_exchange,
|
175 |
177 |
'client_id': QUEUE_CLIENT_ID}
|
176 |
178 |
self.queue = self.queue_module.Queue(**params)
|
177 |
179 |
else:
|
... | ... | |
184 |
186 |
|
185 |
187 |
self.queue = NoQueue()
|
186 |
188 |
|
|
189 |
self.quotaholder = QuotaholderHTTP('http://127.0.0.1/api/quotaholder/v')
|
|
190 |
|
187 |
191 |
def close(self):
|
188 |
192 |
self.wrapper.close()
|
189 |
193 |
self.queue.close()
|
... | ... | |
1233 |
1237 |
account, QUEUE_INSTANCE_ID, 'diskspace',
|
1234 |
1238 |
float(size), details))
|
1235 |
1239 |
|
|
1240 |
serial = self.quotaholder.issue_provision()
|
|
1241 |
self.serial.append(serial)
|
|
1242 |
|
1236 |
1243 |
def _report_object_change(self, user, account, path, details={}):
|
1237 |
1244 |
details.update({'user': user})
|
1238 |
1245 |
logger.debug("_report_object_change: %s %s %s %s", user,
|
1239 |
1246 |
account, path, details)
|
1240 |
1247 |
self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('object',),
|
1241 |
|
account, QUEUE_INSTANCE_ID, 'object', path, details))
|
|
1248 |
account, QUEUE_INSTANCE_ID, 'object', path, details))
|
1242 |
1249 |
|
1243 |
1250 |
def _report_sharing_change(self, user, account, path, details={}):
|
1244 |
1251 |
logger.debug("_report_permissions_change: %s %s %s %s",
|
1245 |
1252 |
user, account, path, details)
|
1246 |
1253 |
details.update({'user': user})
|
1247 |
1254 |
self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('sharing',),
|
1248 |
|
account, QUEUE_INSTANCE_ID, 'sharing', path, details))
|
|
1255 |
account, QUEUE_INSTANCE_ID, 'sharing', path, details))
|
1249 |
1256 |
|
1250 |
1257 |
# Policy functions.
|
1251 |
1258 |
|