Revision b17e5550
b/snf-cyclades-app/synnefo/plankton/backend.py | ||
---|---|---|
76 | 76 |
_pithos_backend_pool = \ |
77 | 77 |
PithosBackendPool( |
78 | 78 |
POOL_SIZE, |
79 |
quotaholder_enabled=settings.CYCLADES_USE_QUOTAHOLDER,
|
|
80 |
quotaholder_url=settings.CYCLADES_QUOTAHOLDER_URL,
|
|
81 |
quotaholder_token=settings.CYCLADES_QUOTAHOLDER_TOKEN,
|
|
79 |
quotaholder_enabled=True,
|
|
80 |
quotaholder_url=settings.ASTAKOS_URL,
|
|
81 |
quotaholder_token=settings.CYCLADES_ASTAKOS_SERVICE_TOKEN,
|
|
82 | 82 |
quotaholder_client_poolsize=settings.CYCLADES_QUOTAHOLDER_POOLSIZE, |
83 | 83 |
db_connection=settings.BACKEND_DB_CONNECTION, |
84 | 84 |
block_path=settings.BACKEND_BLOCK_PATH) |
b/snf-pithos-app/pithos/api/management/commands/pithos-reconcile-commissions.py | ||
---|---|---|
57 | 57 |
b = get_backend() |
58 | 58 |
try: |
59 | 59 |
pending_commissions = b.quotaholder.get_pending_commissions( |
60 |
clientkey=CLIENTKEY |
|
61 |
) |
|
60 |
token=b.quotaholder_token) |
|
62 | 61 |
|
63 | 62 |
if pending_commissions: |
64 | 63 |
self.stdout.write( |
... | ... | |
70 | 69 |
|
71 | 70 |
if options['fix']: |
72 | 71 |
to_accept = b.quotaholder_serials.lookup(pending_commissions) |
73 |
b.quotaholder.accept_commission(
|
|
74 |
context = {},
|
|
75 |
clientkey = CLIENTKEY,
|
|
76 |
serials = to_accept
|
|
77 |
)
|
|
78 |
self.stdout.write("Accepted commissions: %s\n" % to_accept)
|
|
72 |
response = b.quotaholder.resolve_commissions(
|
|
73 |
token=b.quotaholder_token,
|
|
74 |
accept_serials=to_accept,
|
|
75 |
reject_serials=[])
|
|
76 |
accepted = response['accepted']
|
|
77 |
self.stdout.write("Accepted commissions: %s\n" % accepted)
|
|
79 | 78 |
|
80 | 79 |
b.quotaholder_serials.delete_many(to_accept) |
81 | 80 |
self.stdout.write("Deleted serials: %s\n" % to_accept) |
82 | 81 |
|
83 | 82 |
to_reject = list(set(pending_commissions) - set(to_accept)) |
84 |
b.quotaholder.reject_commission(
|
|
85 |
context = {},
|
|
86 |
clientkey = CLIENTKEY,
|
|
87 |
serials = to_reject
|
|
88 |
)
|
|
89 |
self.stdout.write("Rejected commissions: %s\n" % to_reject)
|
|
83 |
response = b.quotaholder.resolve_commissions(
|
|
84 |
token=b.quotaholder_token,
|
|
85 |
accept_serials=[],
|
|
86 |
reject_serials=to_reject)
|
|
87 |
rejected = response['rejected']
|
|
88 |
self.stdout.write("Rejected commissions: %s\n" % rejected)
|
|
90 | 89 |
except Exception, e: |
91 | 90 |
logger.exception(e) |
92 | 91 |
raise CommandError(e) |
b/snf-pithos-app/pithos/api/util.py | ||
---|---|---|
54 | 54 |
BACKEND_BLOCK_MODULE, BACKEND_BLOCK_PATH, |
55 | 55 |
BACKEND_BLOCK_UMASK, |
56 | 56 |
BACKEND_QUEUE_MODULE, BACKEND_QUEUE_HOSTS, |
57 |
BACKEND_QUEUE_EXCHANGE, USE_QUOTAHOLDER, |
|
58 |
QUOTAHOLDER_URL, QUOTAHOLDER_TOKEN, |
|
57 |
BACKEND_QUEUE_EXCHANGE, |
|
59 | 58 |
QUOTAHOLDER_POOLSIZE, |
59 |
SERVICE_TOKEN, |
|
60 | 60 |
ASTAKOS_URL, |
61 | 61 |
BACKEND_ACCOUNT_QUOTA, BACKEND_CONTAINER_QUOTA, |
62 | 62 |
BACKEND_VERSIONING, |
... | ... | |
953 | 953 |
queue_module=BACKEND_QUEUE_MODULE, |
954 | 954 |
queue_hosts=BACKEND_QUEUE_HOSTS, |
955 | 955 |
queue_exchange=BACKEND_QUEUE_EXCHANGE, |
956 |
quotaholder_enabled=USE_QUOTAHOLDER,
|
|
957 |
quotaholder_url=QUOTAHOLDER_URL,
|
|
958 |
quotaholder_token=QUOTAHOLDER_TOKEN,
|
|
956 |
quotaholder_enabled=True,
|
|
957 |
quotaholder_url=ASTAKOS_URL,
|
|
958 |
quotaholder_token=SERVICE_TOKEN,
|
|
959 | 959 |
quotaholder_client_poolsize=QUOTAHOLDER_POOLSIZE, |
960 | 960 |
free_versioning=BACKEND_FREE_VERSIONING, |
961 | 961 |
block_params=BLOCK_PARAMS, |
... | ... | |
1009 | 1009 |
user_info = user_for_token(token, astakos_url, usage=True) |
1010 | 1010 |
usage = user_info.get("usage", []) |
1011 | 1011 |
for u in usage: |
1012 |
if u.get('name') == 'pithos+.diskspace':
|
|
1012 |
if u.get('name') == 'pithos.diskspace': |
|
1013 | 1013 |
return u |
1014 | 1014 |
|
1015 | 1015 |
|
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
37 | 37 |
import hashlib |
38 | 38 |
import binascii |
39 | 39 |
|
40 |
from synnefo.lib.quotaholder import QuotaholderClient
|
|
40 |
from astakosclient import AstakosClient
|
|
41 | 41 |
|
42 | 42 |
from base import (DEFAULT_ACCOUNT_QUOTA, DEFAULT_CONTAINER_QUOTA, |
43 | 43 |
DEFAULT_CONTAINER_VERSIONING, NotAllowedError, QuotaError, |
... | ... | |
46 | 46 |
|
47 | 47 |
# Stripped-down version of the HashMap class found in tools. |
48 | 48 |
|
49 |
|
|
50 | 49 |
class HashMap(list): |
51 | 50 |
|
52 | 51 |
def __init__(self, blocksize, blockhash): |
... | ... | |
99 | 98 |
|
100 | 99 |
ULTIMATE_ANSWER = 42 |
101 | 100 |
|
101 |
DEFAULT_SOURCE = 'system' |
|
102 | 102 |
|
103 | 103 |
logger = logging.getLogger(__name__) |
104 | 104 |
|
... | ... | |
141 | 141 |
return ret |
142 | 142 |
except: |
143 | 143 |
if serials: |
144 |
self.quotaholder.reject_commission(
|
|
145 |
context = {},
|
|
146 |
clientkey = 'pithos',
|
|
147 |
serials = serials)
|
|
144 |
self.quotaholder.resolve_commissions(
|
|
145 |
token=self.quotaholder_token,
|
|
146 |
accept_serials=[],
|
|
147 |
reject_serials=serials)
|
|
148 | 148 |
self.wrapper.rollback() |
149 | 149 |
raise |
150 | 150 |
return fn |
... | ... | |
241 | 241 |
if quotaholder_enabled: |
242 | 242 |
self.quotaholder_url = quotaholder_url |
243 | 243 |
self.quotaholder_token = quotaholder_token |
244 |
self.quotaholder = QuotaholderClient(
|
|
245 |
quotaholder_url,
|
|
246 |
token=quotaholder_token,
|
|
247 |
poolsize=quotaholder_client_poolsize)
|
|
244 |
self.quotaholder = AstakosClient(
|
|
245 |
quotaholder_url, |
|
246 |
use_pool=True,
|
|
247 |
pool_size=quotaholder_client_poolsize)
|
|
248 | 248 |
|
249 | 249 |
self.serials = [] |
250 | 250 |
self.messages = [] |
... | ... | |
1365 | 1365 |
return |
1366 | 1366 |
|
1367 | 1367 |
try: |
1368 |
serial = self.quotaholder.issue_commission( |
|
1369 |
context = {}, |
|
1370 |
target = account, |
|
1371 |
key = '1', |
|
1372 |
clientkey = 'pithos', |
|
1373 |
ownerkey = '', |
|
1374 |
name = details['path'] if 'path' in details else '', |
|
1375 |
provisions = (('pithos+', 'pithos+.diskspace', size),) |
|
1376 |
) |
|
1368 |
name = details['path'] if 'path' in details else '' |
|
1369 |
serial = self.quotaholder.issue_one_commission( |
|
1370 |
token=self.quotaholder_token, |
|
1371 |
holder=account, |
|
1372 |
source=DEFAULT_SOURCE, |
|
1373 |
provisions={'pithos.diskspace': size}, |
|
1374 |
name=name |
|
1375 |
) |
|
1377 | 1376 |
except BaseException, e: |
1378 | 1377 |
raise QuotaError(e) |
1379 | 1378 |
else: |
Also available in: Unified diff