Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-app / pithos / api / settings.py @ 74cbb94a

History | View | Annotate | Download (5.3 kB)

1
#coding=utf8
2
from django.conf import settings
3
from synnefo.lib import parse_base_url, join_urls
4
from synnefo.lib.services import fill_endpoints
5
from synnefo.util.keypath import get_path, set_path
6
from pithos.api.services import pithos_services as vanilla_pithos_services
7
from astakosclient import astakos_services as vanilla_astakos_services
8

    
9
from copy import deepcopy
10

    
11
# Top-level URL for Pithos. Must set.
12
BASE_URL = getattr(settings, 'PITHOS_BASE_URL',
13
                   "https://object-store.example.synnefo.org/pithos/")
14

    
15
BASE_HOST, BASE_PATH = parse_base_url(BASE_URL)
16

    
17
# Process Astakos settings
18
ASTAKOS_BASE_URL = getattr(settings, 'ASTAKOS_BASE_URL',
19
                           'https://accounts.example.synnefo.org/astakos/')
20
ASTAKOS_BASE_HOST, ASTAKOS_BASE_PATH = parse_base_url(ASTAKOS_BASE_URL)
21

    
22
pithos_services = deepcopy(vanilla_pithos_services)
23
fill_endpoints(pithos_services, BASE_URL)
24
PITHOS_PREFIX = get_path(pithos_services, 'pithos_object-store.prefix')
25
PUBLIC_PREFIX = get_path(pithos_services, 'pithos_public.prefix')
26
UI_PREFIX = get_path(pithos_services, 'pithos_ui.prefix')
27

    
28
astakos_services = deepcopy(vanilla_astakos_services)
29
fill_endpoints(astakos_services, ASTAKOS_BASE_URL)
30
CUSTOMIZE_ASTAKOS_SERVICES = \
31
        getattr(settings, 'PITHOS_CUSTOMIZE_ASTAKOS_SERVICES', ())
32
for path, value in CUSTOMIZE_ASTAKOS_SERVICES:
33
    set_path(astakos_services, path, value, createpath=True)
34

    
35
ASTAKOS_ACCOUNTS_PREFIX = get_path(astakos_services, 'astakos_account.prefix')
36
ASTAKOS_VIEWS_PREFIX = get_path(astakos_services, 'astakos_ui.prefix')
37
ASTAKOS_KEYSTONE_PREFIX = get_path(astakos_services, 'astakos_identity.prefix')
38

    
39
BASE_ASTAKOS_PROXY_PATH = getattr(settings, 'PITHOS_BASE_ASTAKOS_PROXY_PATH',
40
                                  ASTAKOS_BASE_PATH)
41
BASE_ASTAKOS_PROXY_PATH = join_urls(BASE_PATH, BASE_ASTAKOS_PROXY_PATH)
42
BASE_ASTAKOS_PROXY_PATH = BASE_ASTAKOS_PROXY_PATH.strip('/')
43

    
44

    
45
ASTAKOSCLIENT_POOLSIZE = getattr(settings, 'PITHOS_ASTAKOSCLIENT_POOLSIZE', 200)
46

    
47
COOKIE_NAME = getattr(settings, 'PITHOS_ASTAKOS_COOKIE_NAME', '_pithos2_a')
48

    
49
# SQLAlchemy (choose SQLite/MySQL/PostgreSQL).
50
BACKEND_DB_MODULE = getattr(
51
    settings, 'PITHOS_BACKEND_DB_MODULE', 'pithos.backends.lib.sqlalchemy')
52
BACKEND_DB_CONNECTION = getattr(settings, 'PITHOS_BACKEND_DB_CONNECTION',
53
                                'sqlite:////tmp/pithos-backend.db')
54

    
55
# Block storage.
56
BACKEND_BLOCK_MODULE = getattr(
57
    settings, 'PITHOS_BACKEND_BLOCK_MODULE', 'pithos.backends.lib.hashfiler')
58
BACKEND_BLOCK_PATH = getattr(
59
    settings, 'PITHOS_BACKEND_BLOCK_PATH', '/tmp/pithos-data/')
60
BACKEND_BLOCK_UMASK = getattr(settings, 'PITHOS_BACKEND_BLOCK_UMASK', 0o022)
61

    
62
# Queue for billing.
63
BACKEND_QUEUE_MODULE = getattr(settings, 'PITHOS_BACKEND_QUEUE_MODULE',
64
                               None)  # Example: 'pithos.backends.lib.rabbitmq'
65
BACKEND_QUEUE_HOSTS = getattr(settings, 'PITHOS_BACKEND_QUEUE_HOSTS', None) # Example: "['amqp://guest:guest@localhost:5672']"
66
BACKEND_QUEUE_EXCHANGE = getattr(settings, 'PITHOS_BACKEND_QUEUE_EXCHANGE', 'pithos')
67

    
68
# Default setting for new accounts.
69
BACKEND_ACCOUNT_QUOTA = getattr(
70
    settings, 'PITHOS_BACKEND_ACCOUNT_QUOTA', 50 * 1024 * 1024 * 1024)
71
BACKEND_CONTAINER_QUOTA = getattr(
72
    settings, 'PITHOS_BACKEND_CONTAINER_QUOTA', 0)
73
BACKEND_VERSIONING = getattr(settings, 'PITHOS_BACKEND_VERSIONING', 'auto')
74
BACKEND_FREE_VERSIONING = getattr(settings, 'PITHOS_BACKEND_FREE_VERSIONING', True)
75

    
76
# Enable backend pooling
77
BACKEND_POOL_ENABLED = getattr(settings, 'PITHOS_BACKEND_POOL_ENABLED', True)
78

    
79
# Default backend pool size
80
BACKEND_POOL_SIZE = getattr(settings, 'PITHOS_BACKEND_POOL_SIZE', 5)
81

    
82
# Update object checksums.
83
UPDATE_MD5 = getattr(settings, 'PITHOS_UPDATE_MD5', False)
84

    
85
# Service Token acquired by identity provider.
86
SERVICE_TOKEN = getattr(settings, 'PITHOS_SERVICE_TOKEN', '')
87

    
88
RADOS_STORAGE = getattr(settings, 'PITHOS_RADOS_STORAGE', False)
89
RADOS_POOL_BLOCKS= getattr(settings, 'PITHOS_RADOS_POOL_BLOCKS', 'blocks')
90
RADOS_POOL_MAPS = getattr(settings, 'PITHOS_RADOS_POOL_MAPS', 'maps')
91

    
92
# This enables a ui compatibility layer for the introduction of UUIDs in
93
# identity management.  WARNING: Setting to True will break your installation.
94
TRANSLATE_UUIDS = getattr(settings, 'PITHOS_TRANSLATE_UUIDS', False)
95

    
96
# Set PROXY_USER_SERVICES to True to have snf-pithos-app handle all Astakos
97
# user-visible services (feedback, login, etc.) by proxying them to a running
98
# Astakos.
99
# Set to False if snf astakos-app is running on the same machine, so it handles
100
# the requests on its own.
101
PROXY_USER_SERVICES = getattr(settings, 'PITHOS_PROXY_USER_SERVICES', True)
102

    
103
# Set how many random bytes to use for constructing the URL of Pithos public files
104
PUBLIC_URL_SECURITY =  getattr(settings, 'PITHOS_PUBLIC_URL_SECURITY', 16)
105
# Set the alphabet to use for constructing the URL of Pithos public files
106
PUBLIC_URL_ALPHABET =  getattr(
107
    settings,
108
    'PITHOS_PUBLIC_URL_ALPHABET',
109
    '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
110
)
111

    
112
# The maximum number or items returned by the listing api methods
113
API_LIST_LIMIT = getattr(settings, 'PITHOS_API_LIST_LIMIT', 10000)
114

    
115
# The backend block size
116
BACKEND_BLOCK_SIZE = getattr(
117
    settings, 'PITHOS_BACKEND_BLOCK_SIZE', 4 * 1024 * 1024)
118

    
119
# The backend block hash algorithm
120
BACKEND_HASH_ALGORITHM = getattr(
121
    settings, 'PITHOS_BACKEND_HASH_ALGORITHM', 'sha256')