Commit 8b3df8e6 authored by Stratos Psomadakis's avatar Stratos Psomadakis
Browse files

pithos: Remove obsolete billing code

parent e38435c8
......@@ -6,6 +6,19 @@ Unified Changelog file for Synnefo versions >= 0.13
Since v0.13 most of the Synnefo components have been merged into a single
repository and have aligned versions.
.. _Changelog-0.16next:
v0.16next
=========
Released: UNRELEASED
Pithos
------
* Remove obsolete billing code
.. _Changelog-0.16:
v0.16rc2
......
......@@ -119,15 +119,6 @@ BACKEND_BLOCK_PATH = getattr(
settings, 'PITHOS_BACKEND_BLOCK_PATH', '/tmp/pithos-data/')
BACKEND_BLOCK_UMASK = getattr(settings, 'PITHOS_BACKEND_BLOCK_UMASK', 0o022)
# Queue for billing.
BACKEND_QUEUE_MODULE = getattr(settings, 'PITHOS_BACKEND_QUEUE_MODULE', None)
# Example: 'pithos.backends.lib.rabbitmq'
BACKEND_QUEUE_HOSTS = getattr(settings, 'PITHOS_BACKEND_QUEUE_HOSTS', None)
# Example: "['amqp://guest:guest@localhost:5672']"
BACKEND_QUEUE_EXCHANGE = getattr(settings, 'PITHOS_BACKEND_QUEUE_EXCHANGE',
'pithos')
# Default setting for new accounts.
BACKEND_ACCOUNT_QUOTA = getattr(
......
......@@ -35,8 +35,6 @@ from snf_django.lib.api import faults, utils
from pithos.api.settings import (BACKEND_DB_MODULE, BACKEND_DB_CONNECTION,
BACKEND_BLOCK_MODULE,
BACKEND_QUEUE_MODULE, BACKEND_QUEUE_HOSTS,
BACKEND_QUEUE_EXCHANGE,
ASTAKOSCLIENT_POOLSIZE,
SERVICE_TOKEN,
ASTAKOS_AUTH_URL,
......@@ -1030,9 +1028,6 @@ BACKEND_KWARGS = dict(
block_module=BACKEND_BLOCK_MODULE,
block_size=BACKEND_BLOCK_SIZE,
hash_algorithm=BACKEND_HASH_ALGORITHM,
queue_module=BACKEND_QUEUE_MODULE,
queue_hosts=BACKEND_QUEUE_HOSTS,
queue_exchange=BACKEND_QUEUE_EXCHANGE,
astakos_auth_url=ASTAKOS_AUTH_URL,
service_token=SERVICE_TOKEN,
astakosclient_poolsize=ASTAKOSCLIENT_POOLSIZE,
......
# Copyright (C) 2010-2014 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from queue import Queue
__all__ = ["Queue"]
# Copyright (C) 2010-2014 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
from hashlib import sha1
from random import random
from time import time
from synnefo.lib.amqp import AMQPClient
class Message(object):
def __init__(self, client, user, instance, resource, value, details={}):
self.eventVersion = '1.0'
self.occurredMillis = int(time() * 1000)
self.receivedMillis = self.occurredMillis
self.clientID = client
self.userID = user
self.instanceID = instance
self.resource = resource
self.value = value
self.details = details
hash = sha1()
hash.update(json.dumps(
[client, user, resource, value, details, random()]))
self.id = hash.hexdigest()
class Queue(object):
"""Queue.
Required constructor parameters: hosts, exchange, client_id.
"""
def __init__(self, **params):
hosts = params['hosts']
self.exchange = params['exchange']
self.client_id = params['client_id']
self.client = AMQPClient(hosts=hosts)
self.client.connect()
self.client.exchange_declare(exchange=self.exchange,
type='topic')
def send(self, message_key, user, instance, resource, value, details):
body = Message(
self.client_id, user, instance, resource, value, details)
self.client.basic_publish(exchange=self.exchange,
routing_key=message_key,
body=json.dumps(body.__dict__))
def close(self):
self.client.close()
......@@ -90,20 +90,13 @@ DEFAULT_DB_CONNECTION = 'sqlite:///backend.db'
DEFAULT_BLOCK_MODULE = 'pithos.backends.lib.hashfiler'
DEFAULT_BLOCK_SIZE = 4 * 1024 * 1024 # 4MB
DEFAULT_HASH_ALGORITHM = 'sha256'
# DEFAULT_QUEUE_MODULE = 'pithos.backends.lib.rabbitmq'
DEFAULT_BLOCK_PARAMS = {'mappool': None, 'blockpool': None}
# DEFAULT_QUEUE_HOSTS = '[amqp://guest:guest@localhost:5672]'
# DEFAULT_QUEUE_EXCHANGE = 'pithos'
DEFAULT_PUBLIC_URL_ALPHABET = ('0123456789'
'abcdefghijklmnopqrstuvwxyz'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
DEFAULT_PUBLIC_URL_SECURITY = 16
DEFAULT_ARCHIPELAGO_CONF_FILE = '/etc/archipelago/archipelago.conf'
QUEUE_MESSAGE_KEY_PREFIX = 'pithos.%s'
QUEUE_CLIENT_ID = 'pithos'
QUEUE_INSTANCE_ID = '1'
(CLUSTER_NORMAL, CLUSTER_HISTORY, CLUSTER_DELETED) = range(3)
QUOTA_POLICY = 'quota'
......@@ -227,7 +220,6 @@ class ModularBackend(BaseBackend):
def __init__(self, db_module=None, db_connection=None,
block_module=None, block_size=None, hash_algorithm=None,
queue_module=None, queue_hosts=None, queue_exchange=None,
astakos_auth_url=None, service_token=None,
astakosclient_poolsize=None,
free_versioning=True, block_params=None,
......@@ -249,7 +241,6 @@ class ModularBackend(BaseBackend):
block_params = block_params or DEFAULT_BLOCK_PARAMS
block_size = block_size or DEFAULT_BLOCK_SIZE
hash_algorithm = hash_algorithm or DEFAULT_HASH_ALGORITHM
# queue_module = queue_module or DEFAULT_QUEUE_MODULE
account_quota_policy = account_quota_policy or DEFAULT_ACCOUNT_QUOTA
container_quota_policy = container_quota_policy \
or DEFAULT_CONTAINER_QUOTA
......@@ -273,8 +264,6 @@ class ModularBackend(BaseBackend):
QUOTA_POLICY: container_quota_policy,
VERSIONING_POLICY: container_versioning_policy,
PROJECT: None}
# queue_hosts = queue_hosts or DEFAULT_QUEUE_HOSTS
# queue_exchange = queue_exchange or DEFAULT_QUEUE_EXCHANGE
self.public_url_security = (public_url_security or
DEFAULT_PUBLIC_URL_SECURITY)
......@@ -324,22 +313,6 @@ class ModularBackend(BaseBackend):
params.update(self.block_params)
self.store = self.block_module.Store(**params)
if queue_module and queue_hosts:
self.queue_module = load_module(queue_module)
params = {'hosts': queue_hosts,
'exchange': queue_exchange,
'client_id': QUEUE_CLIENT_ID}
self.queue = self.queue_module.Queue(**params)
else:
class NoQueue:
def send(self, *args):
pass
def close(self):
pass
self.queue = NoQueue()
self.astakos_auth_url = astakos_auth_url
self.service_token = service_token
......@@ -355,7 +328,6 @@ class ModularBackend(BaseBackend):
pool_size=astakosclient_poolsize)
self.serials = []
self.messages = []
self._move_object = partial(self._copy_object, is_move=True)
......@@ -379,10 +351,6 @@ class ModularBackend(BaseBackend):
def post_exec(self, success_status=True):
if success_status:
# send messages produced
for m in self.messages:
self.queue.send(*m)
# register serials
if self.serials:
self.commission_serials.insert_many(
......@@ -414,7 +382,6 @@ class ModularBackend(BaseBackend):
def close(self):
self.wrapper.close()
self.queue.close()
@property
def using_external_quotaholder(self):
......@@ -2199,9 +2166,6 @@ class ModularBackend(BaseBackend):
account_node = self._lookup_account(account, True)[1]
total = self._get_statistics(account_node, compute=True)[1]
details.update({'user': user, 'total': total})
self.messages.append(
(QUEUE_MESSAGE_KEY_PREFIX % ('resource.diskspace',),
account, QUEUE_INSTANCE_ID, 'diskspace', float(size), details))
if not self.using_external_quotaholder:
return
......@@ -2218,18 +2182,12 @@ class ModularBackend(BaseBackend):
def _report_object_change(self, user, account, path, details=None):
details = details or {}
details.update({'user': user})
self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('object',),
account, QUEUE_INSTANCE_ID, 'object', path,
details))
@debug_method
@backend_method
def _report_sharing_change(self, user, account, path, details=None):
details = details or {}
details.update({'user': user})
self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('sharing',),
account, QUEUE_INSTANCE_ID, 'sharing', path,
details))
# Policy functions.
......
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