Commit f3ec3dd1 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

pithos: Rename backend quotaholder properties

Refer to astakosclient instead of quotaholder
parent ad88bfaa
......@@ -14,6 +14,12 @@ v0.13next
Released: UNRELEASED
* Incorporate quotaholder in astakos
* obsolete settings:
PITHOS_USE_QUOTAHOLDER, PITHOS_QUOTAHOLDER_URL, PITHOS_QUOTAHOLDER_TOKEN
* new settins:
PITHOS_ASTAKOSCLIENT_POOLSIZE
Synnefo-wide
------------
* Create 'snf_django' Python package to hold common code for all Synnefo
......
......@@ -76,10 +76,9 @@ POOL_SIZE = 8
_pithos_backend_pool = \
PithosBackendPool(
POOL_SIZE,
quotaholder_enabled=True,
quotaholder_url=settings.ASTAKOS_URL,
quotaholder_token=settings.CYCLADES_ASTAKOS_SERVICE_TOKEN,
quotaholder_client_poolsize=settings.CYCLADES_QUOTAHOLDER_POOLSIZE,
astakos_url=settings.ASTAKOS_URL,
service_token=settings.CYCLADES_ASTAKOS_SERVICE_TOKEN,
astakosclient_poolsize=settings.CYCLADES_QUOTAHOLDER_POOLSIZE,
db_connection=settings.BACKEND_DB_CONNECTION,
block_path=settings.BACKEND_BLOCK_PATH)
......
......@@ -31,6 +31,7 @@ Configure in ``settings.py`` or a ``.conf`` file in ``/etc/synnefo`` if using sn
Name Default value Description
=============================== ================================================================ ============================================================
ASTAKOS_URL \https://<astakos.host>/ Astakos Authentication URL
PITHOS_ASTAKOSCLIENT_POOLSIZE 200 The size of the http pool for the astakos client
PITHOS_ASTAKOS_COOKIE_NAME _pithos2_a Cookie name to retrieve fallback token
PITHOS_BACKEND_DB_MODULE pithos.backends.lib.sqlalchemy
PITHOS_BACKEND_DB_CONNECTION sqlite:////tmp/pithos-backend.db SQLAlchemy database connection string
......@@ -55,9 +56,6 @@ PITHOS_PROXY_USER_SERVICES True
PITHOS_USER_CATALOG_URL \https://<astakos.host>/user_catalogs/ Astakos User Catalog URL
PITHOS_USER_FEEDBACK_URL \https://<astakos.host>/feedback/ Astakos User Feedback URL
PITHOS_USER_LOGIN_URL \https://<astakos.host>/login/ Astakos User Login URL
PITHOS_USE_QUOTAHOLDER True Enable quotaholder
PITHOS_QUOTAHOLDER_URL '' Quotaholder URL
PITHOS_QUOTAHOLDER_TOKEN '' Quotaholder token
PITHOS_PUBLIC_URL_SECURITY 16 How many random bytes to use for constructing the URL of Pithos public files
PITHOS_PUBLIC_URL_ALPHABET '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' The alphabet to use for constructing the URL of Pithos public files
=============================== ================================================================ ============================================================
......
......@@ -45,17 +45,12 @@
#PITHOS_USER_FEEDBACK_URL = 'https://accounts.example.synnefo.org/feedback/'
#PITHOS_USER_LOGIN_URL = 'https://accounts.example.synnefo.org/login/'
# Enable and configure quotaholder
#PITHOS_USE_QUOTAHOLDER = False
#PITHOS_QUOTAHOLDER_URL = ''
#PITHOS_QUOTAHOLDER_TOKEN = ''
#
# Tune the size of the http pool for the quotaholder client.
# Tune the size of the http pool for the astakos client.
# It limits the maximum number of quota changing requests
# that pithos can serve. Extra requests will be blocked
# until another has completed.
#
#PITHOS_QUOTAHOLDER_POOLSIZE = 200
#PITHOS_ASTAKOSCLIENT_POOLSIZE = 200
#
# How many random bytes to use for constructing the URL of Pithos public files.
# Lower values mean accidental reuse of (discarded) URLs is more probable.
......
......@@ -56,8 +56,8 @@ class Command(NoArgsCommand):
def handle_noargs(self, **options):
b = get_backend()
try:
pending_commissions = b.quotaholder.get_pending_commissions(
token=b.quotaholder_token)
pending_commissions = b.astakosclient.get_pending_commissions(
token=b.service_token)
if pending_commissions:
self.stdout.write(
......@@ -68,10 +68,10 @@ class Command(NoArgsCommand):
return
if options['fix']:
to_accept = b.quotaholder_serials.lookup(pending_commissions)
to_accept = b.commision_serials.lookup(pending_commissions)
to_reject = list(set(pending_commissions) - set(to_accept))
response = b.quotaholder.resolve_commissions(
token=b.quotaholder_token,
response = b.astakosclient.resolve_commissions(
token=b.service_token,
accept_serials=to_accept,
reject_serials=to_reject
)
......@@ -84,7 +84,7 @@ class Command(NoArgsCommand):
for i in failed:
self.stdout.write('%s\n' % i)
b.quotaholder_serials.delete_many(accepted)
b.commision_serials.delete_many(accepted)
except Exception, e:
logger.exception(e)
raise CommandError(e)
......
......@@ -99,8 +99,8 @@ class Command(NoArgsCommand):
size = backend.node.node_account_usage(node, CLUSTER_NORMAL)
db_usage[path] = size or 0
result = backend.quotaholder.service_get_quotas(
backend.quotaholder_token,
result = backend.astakosclient.service_get_quotas(
backend.service_token,
)
qh_usage = {}
......@@ -149,13 +149,13 @@ class Command(NoArgsCommand):
request['auto_accept'] = True
request['provisions'] = provisions
try:
serial = backend.quotaholder.issue_commission(
backend.quotaholder_token, request
serial = backend.astakosclient.issue_commission(
backend.service_token, request
)
except AstakosClientException, e:
self.stdout.write(e.details)
else:
backend.quotaholder_serials.insert_many([serial])
backend.commission_serials.insert_many([serial])
elif options['list'] and table:
output_format = options["output_format"]
if output_format != "json" and not options["headers"]:
......
......@@ -3,6 +3,7 @@ from django.conf import settings
ASTAKOS_URL = getattr(settings, "ASTAKOS_URL",
"https://accounts.example.synnefo.org/")
ASTAKOSCLIENT_POOLSIZE = getattr(settings, 'PITHOS_ASTAKOSCLIENT_POOLSIZE', 200)
COOKIE_NAME = getattr(settings, 'PITHOS_ASTAKOS_COOKIE_NAME', '_pithos2_a')
......@@ -64,12 +65,6 @@ USER_FEEDBACK_URL = getattr(settings, 'PITHOS_USER_FEEDBACK_URL',
USER_LOGIN_URL = getattr(settings, 'PITHOS_USER_LOGIN_URL',
'https://accounts.example.synnefo.org/login/')
# Set the quota holder component URI
USE_QUOTAHOLDER = getattr(settings, 'PITHOS_USE_QUOTAHOLDER', False)
QUOTAHOLDER_URL = getattr(settings, 'PITHOS_QUOTAHOLDER_URL', '')
QUOTAHOLDER_TOKEN = getattr(settings, 'PITHOS_QUOTAHOLDER_TOKEN', '')
QUOTAHOLDER_POOLSIZE = getattr(settings, 'PITHOS_QUOTAHOLDER_POOLSIZE', 200)
# Set how many random bytes to use for constructing the URL of Pithos public files
PUBLIC_URL_SECURITY = getattr(settings, 'PITHOS_PUBLIC_URL_SECURITY', 16)
# Set the alphabet to use for constructing the URL of Pithos public files
......
......@@ -55,7 +55,7 @@ from pithos.api.settings import (BACKEND_DB_MODULE, BACKEND_DB_CONNECTION,
BACKEND_BLOCK_UMASK,
BACKEND_QUEUE_MODULE, BACKEND_QUEUE_HOSTS,
BACKEND_QUEUE_EXCHANGE,
QUOTAHOLDER_POOLSIZE,
ASTAKOSCLIENT_POOLSIZE,
SERVICE_TOKEN,
ASTAKOS_URL,
BACKEND_ACCOUNT_QUOTA, BACKEND_CONTAINER_QUOTA,
......@@ -953,10 +953,9 @@ _pithos_backend_pool = PithosBackendPool(
queue_module=BACKEND_QUEUE_MODULE,
queue_hosts=BACKEND_QUEUE_HOSTS,
queue_exchange=BACKEND_QUEUE_EXCHANGE,
quotaholder_enabled=True,
quotaholder_url=ASTAKOS_URL,
quotaholder_token=SERVICE_TOKEN,
quotaholder_client_poolsize=QUOTAHOLDER_POOLSIZE,
astakos_url=ASTAKOS_URL,
service_token=SERVICE_TOKEN,
astakosclient_poolsize=ASTAKOSCLIENT_POOLSIZE,
free_versioning=BACKEND_FREE_VERSIONING,
block_params=BLOCK_PARAMS,
public_url_security=PUBLIC_URL_SECURITY,
......
......@@ -141,8 +141,8 @@ def backend_method(func=None, autocommit=1):
return ret
except:
if serials:
self.quotaholder.resolve_commissions(
token=self.quotaholder_token,
self.astakosclient.resolve_commissions(
token=self.service_token,
accept_serials=[],
reject_serials=serials)
self.wrapper.rollback()
......@@ -159,9 +159,8 @@ class ModularBackend(BaseBackend):
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,
quotaholder_enabled=False,
quotaholder_url=None, quotaholder_token=None,
quotaholder_client_poolsize=None,
astakos_url=None, service_token=None,
astakosclient_poolsize=None,
free_versioning=True, block_params=None,
public_url_security=None,
public_url_alphabet=None,
......@@ -205,7 +204,7 @@ class ModularBackend(BaseBackend):
params = {'wrapper': self.wrapper}
self.permissions = self.db_module.Permissions(**params)
self.config = self.db_module.Config(**params)
self.quotaholder_serials = self.db_module.QuotaholderSerial(**params)
self.commission_serials = self.db_module.QuotaholderSerial(**params)
for x in ['READ', 'WRITE']:
setattr(self, x, getattr(self.db_module, x))
self.node = self.db_module.Node(**params)
......@@ -237,14 +236,12 @@ class ModularBackend(BaseBackend):
self.queue = NoQueue()
self.quotaholder_enabled = quotaholder_enabled
if quotaholder_enabled:
self.quotaholder_url = quotaholder_url
self.quotaholder_token = quotaholder_token
self.quotaholder = AstakosClient(
quotaholder_url,
use_pool=True,
pool_size=quotaholder_client_poolsize)
self.astakos_url = astakos_url
self.service_token = service_token
self.astakosclient = AstakosClient(
astakos_url,
use_pool=True,
pool_size=astakosclient_poolsize)
self.serials = []
self.messages = []
......@@ -255,7 +252,7 @@ class ModularBackend(BaseBackend):
@property
def using_external_quotaholder(self):
return self.quotaholder_enabled
return True
@backend_method
def list_accounts(self, user, marker=None, limit=10000):
......@@ -1366,8 +1363,8 @@ class ModularBackend(BaseBackend):
try:
name = details['path'] if 'path' in details else ''
serial = self.quotaholder.issue_one_commission(
token=self.quotaholder_token,
serial = self.astakosclient.issue_one_commission(
token=self.service_token,
holder=account,
source=DEFAULT_SOURCE,
provisions={'pithos.diskspace': size},
......
......@@ -45,9 +45,8 @@ class PithosBackendPool(ObjectPool):
block_module=None, block_path=None, block_umask=None,
queue_module=None, queue_hosts=None,
queue_exchange=None, free_versioning=True,
quotaholder_enabled=True,
quotaholder_url=None, quotaholder_token=None,
quotaholder_client_poolsize=None,
astakos_url=None, service_token=None,
astakosclient_poolsize=None,
block_params=None,
public_url_security=None,
public_url_alphabet=None,
......@@ -65,10 +64,9 @@ class PithosBackendPool(ObjectPool):
self.block_params = block_params
self.queue_hosts = queue_hosts
self.queue_exchange = queue_exchange
self.quotaholder_enabled = quotaholder_enabled
self.quotaholder_url = quotaholder_url
self.quotaholder_token = quotaholder_token
self.quotaholder_client_poolsize = quotaholder_client_poolsize
self.astakos_url = astakos_url
self.service_token = service_token
self.astakosclient_poolsize = astakosclient_poolsize
self.free_versioning = free_versioning
self.public_url_security = public_url_security
self.public_url_alphabet = public_url_alphabet
......@@ -87,10 +85,9 @@ class PithosBackendPool(ObjectPool):
block_params=self.block_params,
queue_hosts=self.queue_hosts,
queue_exchange=self.queue_exchange,
quotaholder_enabled=self.quotaholder_enabled,
quotaholder_url=self.quotaholder_url,
quotaholder_token=self.quotaholder_token,
quotaholder_client_poolsize=self.quotaholder_client_poolsize,
astakos_url=self.astakos_url,
service_token=self.service_token,
astakosclient_poolsize=self.astakosclient_poolsize,
free_versioning=self.free_versioning,
public_url_security=self.public_url_security,
public_url_alphabet=self.public_url_alphabet,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment