Statistics
| Branch: | Tag: | Revision:

root / settings.py.dist @ 76a429fb

History | View | Annotate | Download (9.1 kB)

1 d7f0ad6e provetza
# -*- coding: utf-8 -*-
2 d7f0ad6e provetza
3 00b4f1be Faidon Liambotis
# Django settings for synnefo project.
4 619b1c87 Markos Gogoulos
import os
5 619b1c87 Markos Gogoulos
6 619b1c87 Markos Gogoulos
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
7 00b4f1be Faidon Liambotis
8 00b4f1be Faidon Liambotis
DEBUG = True
9 00b4f1be Faidon Liambotis
TEMPLATE_DEBUG = DEBUG
10 00b4f1be Faidon Liambotis
11 4cf8adf8 Vangelis Koukis
# A quick-n-dirty way to know if we're running unit tests
12 4cf8adf8 Vangelis Koukis
import sys
13 2280e9fe Vangelis Koukis
TEST = False
14 4cf8adf8 Vangelis Koukis
if len(sys.argv) >= 2:
15 2280e9fe Vangelis Koukis
    if os.path.basename(sys.argv[0]) == 'manage.py' and \
16 2280e9fe Vangelis Koukis
        (sys.argv[1] == 'test' or sys.argv[1] == 'hudson'):
17 2280e9fe Vangelis Koukis
            TEST = True
18 4cf8adf8 Vangelis Koukis
19 00b4f1be Faidon Liambotis
ADMINS = (
20 00b4f1be Faidon Liambotis
    # ('Your Name', 'your_email@domain.com'),
21 00b4f1be Faidon Liambotis
)
22 00b4f1be Faidon Liambotis
23 00b4f1be Faidon Liambotis
MANAGERS = ADMINS
24 00b4f1be Faidon Liambotis
25 00b4f1be Faidon Liambotis
DATABASES = {
26 00b4f1be Faidon Liambotis
    'default': {
27 e646ebe5 Dimitris Moraitis
        # 'postgresql_psycopg2', 'postgresql','mysql', 'sqlite3' or 'oracle'
28 e646ebe5 Dimitris Moraitis
        'ENGINE': 'sqlite3',
29 dd8d34ae Vangelis Koukis
         # ATTENTION: This *must* be the absolute path if using sqlite3.
30 dd8d34ae Vangelis Koukis
         # See: http://docs.djangoproject.com/en/dev/ref/settings/#name
31 619b1c87 Markos Gogoulos
        'NAME': PROJECT_PATH + 'database.sqlite',
32 00b4f1be Faidon Liambotis
        'USER': '',                      # Not used with sqlite3.
33 00b4f1be Faidon Liambotis
        'PASSWORD': '',                  # Not used with sqlite3.
34 e646ebe5 Dimitris Moraitis
        # Set to empty string for localhost. Not used with sqlite3.
35 e646ebe5 Dimitris Moraitis
        'HOST': '',
36 e646ebe5 Dimitris Moraitis
        # Set to empty string for default. Not used with sqlite3.
37 e646ebe5 Dimitris Moraitis
        'PORT': '',
38 00b4f1be Faidon Liambotis
    }
39 00b4f1be Faidon Liambotis
}
40 00b4f1be Faidon Liambotis
41 360fcf20 Faidon Liambotis
if DATABASES['default']['ENGINE'].endswith('mysql'):
42 360fcf20 Faidon Liambotis
    DATABASES['default']['OPTIONS'] = {
43 360fcf20 Faidon Liambotis
        'init_command': 'SET storage_engine=INNODB',
44 360fcf20 Faidon Liambotis
    }
45 360fcf20 Faidon Liambotis
46 db3dccf4 Dimitris Moraitis
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
47 db3dccf4 Dimitris Moraitis
48 00b4f1be Faidon Liambotis
# Local time zone for this installation. Choices can be found here:
49 00b4f1be Faidon Liambotis
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
50 00b4f1be Faidon Liambotis
# although not all choices may be available on all operating systems.
51 00b4f1be Faidon Liambotis
# On Unix systems, a value of None will cause Django to use the same
52 00b4f1be Faidon Liambotis
# timezone as the operating system.
53 00b4f1be Faidon Liambotis
# If running in a Windows environment this must be set to the same as your
54 00b4f1be Faidon Liambotis
# system time zone.
55 2a68a5ff Giorgos Verigakis
TIME_ZONE = 'UTC'   # Warning: API depends on the TIME_ZONE being UTC
56 00b4f1be Faidon Liambotis
57 00b4f1be Faidon Liambotis
# Language code for this installation. All choices can be found here:
58 00b4f1be Faidon Liambotis
# http://www.i18nguy.com/unicode/language-identifiers.html
59 00b4f1be Faidon Liambotis
LANGUAGE_CODE = 'en-us'
60 00b4f1be Faidon Liambotis
61 00b4f1be Faidon Liambotis
SITE_ID = 1
62 00b4f1be Faidon Liambotis
63 00b4f1be Faidon Liambotis
# If you set this to False, Django will make some optimizations so as not
64 00b4f1be Faidon Liambotis
# to load the internationalization machinery.
65 00b4f1be Faidon Liambotis
USE_I18N = True
66 00b4f1be Faidon Liambotis
67 00b4f1be Faidon Liambotis
# If you set this to False, Django will not format dates, numbers and
68 00b4f1be Faidon Liambotis
# calendars according to the current locale
69 00b4f1be Faidon Liambotis
USE_L10N = True
70 00b4f1be Faidon Liambotis
71 00b4f1be Faidon Liambotis
# Absolute path to the directory that holds media.
72 00b4f1be Faidon Liambotis
# Example: "/home/media/media.lawrence.com/"
73 00b4f1be Faidon Liambotis
MEDIA_ROOT = ''
74 00b4f1be Faidon Liambotis
75 00b4f1be Faidon Liambotis
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
76 00b4f1be Faidon Liambotis
# trailing slash if there is a path component (optional in other cases).
77 00b4f1be Faidon Liambotis
# Examples: "http://media.lawrence.com", "http://example.com/media/"
78 00b4f1be Faidon Liambotis
MEDIA_URL = ''
79 00b4f1be Faidon Liambotis
80 00b4f1be Faidon Liambotis
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
81 00b4f1be Faidon Liambotis
# trailing slash.
82 00b4f1be Faidon Liambotis
# Examples: "http://foo.com/media/", "/media/".
83 00b4f1be Faidon Liambotis
ADMIN_MEDIA_PREFIX = '/media/'
84 00b4f1be Faidon Liambotis
85 81357279 Faidon Liambotis
# our REST API would prefer to be explicit about trailing slashes
86 81357279 Faidon Liambotis
APPEND_SLASH = False
87 81357279 Faidon Liambotis
88 00b4f1be Faidon Liambotis
# Make this unique, and don't share it with anybody.
89 00b4f1be Faidon Liambotis
SECRET_KEY = 'ly6)mw6a7x%n)-e#zzk4jo6f2=uqu!1o%)2-(7lo+f9yd^k^bg'
90 00b4f1be Faidon Liambotis
91 00b4f1be Faidon Liambotis
# List of callables that know how to import templates from various sources.
92 00b4f1be Faidon Liambotis
TEMPLATE_LOADERS = (
93 00b4f1be Faidon Liambotis
    'django.template.loaders.filesystem.Loader',
94 00b4f1be Faidon Liambotis
    'django.template.loaders.app_directories.Loader',
95 00b4f1be Faidon Liambotis
#     'django.template.loaders.eggs.Loader',
96 00b4f1be Faidon Liambotis
)
97 00b4f1be Faidon Liambotis
98 d7f0ad6e provetza
TEMPLATE_CONTEXT_PROCESSORS = (
99 ccbd9f9b Markos Gogoulos
    'django.core.context_processors.request',
100 d7f0ad6e provetza
    'django.core.context_processors.i18n',
101 ccbd9f9b Markos Gogoulos
    'django.contrib.auth.context_processors.auth',
102 d7f0ad6e provetza
)
103 d7f0ad6e provetza
104 00b4f1be Faidon Liambotis
MIDDLEWARE_CLASSES = (
105 00b4f1be Faidon Liambotis
    'django.contrib.sessions.middleware.SessionMiddleware',
106 8f377cd6 Georgios Gousios
    'synnefo.aai.middleware.SynnefoAuthMiddleware',
107 1428a464 Georgios Gousios
    'synnefo.api.middleware.ApiAuthMiddleware',
108 d7f0ad6e provetza
    'django.middleware.locale.LocaleMiddleware',
109 421369dc user
    'django.middleware.common.CommonMiddleware',
110 8f377cd6 Georgios Gousios
    'django.contrib.messages.middleware.MessageMiddleware'
111 00b4f1be Faidon Liambotis
)
112 00b4f1be Faidon Liambotis
113 00b4f1be Faidon Liambotis
ROOT_URLCONF = 'synnefo.urls'
114 00b4f1be Faidon Liambotis
115 00b4f1be Faidon Liambotis
TEMPLATE_DIRS = (
116 e646ebe5 Dimitris Moraitis
    # Put strings here, like "/home/html/django_templates"
117 e646ebe5 Dimitris Moraitis
    # or "C:/www/django/templates".
118 00b4f1be Faidon Liambotis
    # Always use forward slashes, even on Windows.
119 00b4f1be Faidon Liambotis
    # Don't forget to use absolute paths, not relative paths.
120 00b4f1be Faidon Liambotis
)
121 00b4f1be Faidon Liambotis
122 00b4f1be Faidon Liambotis
INSTALLED_APPS = (
123 00b4f1be Faidon Liambotis
    'django.contrib.contenttypes',
124 00b4f1be Faidon Liambotis
    'django.contrib.sessions',
125 00b4f1be Faidon Liambotis
    'django.contrib.sites',
126 00b4f1be Faidon Liambotis
    'django.contrib.messages',
127 78dec216 Vassilios Karakoidas
    'django.contrib.admin',
128 00b4f1be Faidon Liambotis
    # 'django.contrib.admindocs',
129 25380811 Georgios Gousios
    'synnefo.aai',
130 00b4f1be Faidon Liambotis
    'synnefo.api',
131 0f402f77 Dimitris Moraitis
    'synnefo.ui',
132 ccbd9f9b Markos Gogoulos
    'synnefo.db',
133 fee71ba1 Markos Gogoulos
    'synnefo.ganeti',
134 8e1dcc32 Georgios Gousios
    'synnefo.logic',
135 68e6d8df Georgios Gousios
    'synnefo.invitations',
136 7a8ddf20 Vangelis Koukis
    'south'
137 00b4f1be Faidon Liambotis
)
138 253f0c82 Faidon Liambotis
139 0e3c1947 Vangelis Koukis
# The RAPI endpoint and associated credentials to use
140 0e3c1947 Vangelis Koukis
# for talking to the Ganeti backend.
141 dac67c0a Vangelis Koukis
GANETI_MASTER_IP = "62.217.120.78"
142 dac67c0a Vangelis Koukis
GANETI_CLUSTER_INFO = (GANETI_MASTER_IP, 5080, "synnefo", "ocean!")
143 e646ebe5 Dimitris Moraitis
144 0e3c1947 Vangelis Koukis
# This prefix gets used when determining the instance names
145 0e3c1947 Vangelis Koukis
# of Synnefo VMs at the Ganeti backend.
146 ae5965b6 Georgios Gousios
# The dash must always appear in the name!
147 e646ebe5 Dimitris Moraitis
BACKEND_PREFIX_ID = "snf-"
148 d7f0ad6e provetza
149 d7f0ad6e provetza
LANGUAGES = (
150 d7f0ad6e provetza
  ('el', u'Ελληνικά'),
151 d7f0ad6e provetza
  ('en', 'English'),
152 d7f0ad6e provetza
)
153 421369dc user
154 e646ebe5 Dimitris Moraitis
# needed for django. this is the class that implements the User system.
155 e646ebe5 Dimitris Moraitis
# We use this to allow users to add stuff for themselves (about, image etc)
156 275741a9 Markos Gogoulos
#http://docs.djangoproject.com/en/dev/topics/auth/#auth-profiles
157 e646ebe5 Dimitris Moraitis
AUTH_PROFILE_MODULE = 'synnefo.OceanUser'
158 e646ebe5 Dimitris Moraitis
159 b36421a6 Vangelis Koukis
# API requests from the GUI time out after that many seconds.
160 e646ebe5 Dimitris Moraitis
TIMEOUT = 10 * 1000
161 275741a9 Markos Gogoulos
162 b36421a6 Vangelis Koukis
# The API will return HTTP Bad Request if the ?changes-since
163 b36421a6 Vangelis Koukis
# parameter refers to a point in time more than POLL_LIMIT seconds ago.
164 54f8cd6d Markos Gogoulos
POLL_LIMIT = 3600
165 c7b808db Dimitris Moraitis
166 b024b97a Georgios Gousios
# Configuration for ganeti-eventd, the Ganeti notification daemon
167 b024b97a Georgios Gousios
GANETI_EVENTD_LOG_FILE = "/var/log/synnefo/ganeti-eventd.log"
168 b024b97a Georgios Gousios
GANETI_EVENTD_PID_FILE = "/var/run/synnefo/ganeti-eventd.pid"
169 b024b97a Georgios Gousios
170 7ca9e930 Vangelis Koukis
# Rabbit work queue endpoint
171 6ec8927b Vangelis Koukis
RABBIT_HOST = "62.217.120.67:5672"
172 6ec8927b Vangelis Koukis
RABBIT_USERNAME = "okeanos"
173 6ec8927b Vangelis Koukis
RABBIT_PASSWORD = "0k3@n0s"
174 6ec8927b Vangelis Koukis
RABBIT_VHOST = "/"
175 6ec8927b Vangelis Koukis
176 7ca9e930 Vangelis Koukis
# 
177 7ca9e930 Vangelis Koukis
# Queues, exchanges and bindings for AMQP
178 dac67c0a Vangelis Koukis
#
179 6ec8927b Vangelis Koukis
EXCHANGE_GANETI = "ganeti"  # Messages from Ganeti
180 6ec8927b Vangelis Koukis
EXCHANGE_CRON = "cron"      # Messages from periodically triggered tasks
181 6ec8927b Vangelis Koukis
EXCHANGE_API = "api"        # Messages from the Rest API
182 f30730c0 Georgios Gousios
EXCHANGES = (EXCHANGE_GANETI, EXCHANGE_CRON, EXCHANGE_API)
183 8d8ea051 Georgios Gousios
184 6ec8927b Vangelis Koukis
QUEUE_GANETI_EVENTS = "events"
185 6ec8927b Vangelis Koukis
QUEUE_CRON_CREDITS = "credits"
186 6ec8927b Vangelis Koukis
QUEUE_EMAIL = "email"
187 8007ba7b Georgios Gousios
QUEUE_RECONC = "reconciliation"
188 6ec8927b Vangelis Koukis
QUEUE_DEBUG = "debug"       # Debug queue, retrieves all messages
189 21bea783 Georgios Gousios
QUEUES = (QUEUE_GANETI_EVENTS, QUEUE_CRON_CREDITS, QUEUE_EMAIL, QUEUE_RECONC)
190 5d081749 Georgios Gousios
191 ae5965b6 Georgios Gousios
BINDINGS_DEBUG = [
192 6ec8927b Vangelis Koukis
    # Queue         # Exchange          # RouteKey  # Handler
193 23c84263 Georgios Gousios
    (QUEUE_DEBUG,   EXCHANGE_GANETI,    '#',        'dummy_proc'),
194 23c84263 Georgios Gousios
    (QUEUE_DEBUG,   EXCHANGE_CRON,      '#',        'dummy_proc'),
195 23c84263 Georgios Gousios
    (QUEUE_DEBUG,   EXCHANGE_API,       '#',        'dummy_proc'),
196 ae5965b6 Georgios Gousios
]
197 ae5965b6 Georgios Gousios
198 ae5965b6 Georgios Gousios
BINDINGS = [
199 7ca9e930 Vangelis Koukis
    # Queue                 # Exchange          # RouteKey            #Handler
200 7ca9e930 Vangelis Koukis
    (QUEUE_GANETI_EVENTS,   EXCHANGE_GANETI,    'ganeti.*.event.op',  'update_db'),
201 7ca9e930 Vangelis Koukis
    (QUEUE_GANETI_EVENTS,   EXCHANGE_GANETI,    'ganeti.*.event.net', 'update_net'),
202 7ca9e930 Vangelis Koukis
    (QUEUE_CRON_CREDITS,    EXCHANGE_CRON,      '*.credits.*',        'update_credits'),
203 7ca9e930 Vangelis Koukis
    (QUEUE_EMAIL,           EXCHANGE_API,       '*.email.*',          'send_email'),
204 7ca9e930 Vangelis Koukis
    (QUEUE_EMAIL,           EXCHANGE_CRON,      '*.email.*',          'send_email'),
205 8007ba7b Georgios Gousios
    (QUEUE_RECONC,          EXCHANGE_CRON,      'reconciliation.*',   'trigger_status_update'),
206 ae5965b6 Georgios Gousios
]
207 8d8ea051 Georgios Gousios
208 7ca9e930 Vangelis Koukis
def fix_amqp_settings(backend_prefix):
209 7ca9e930 Vangelis Koukis
    """Configure AMQP-specific settings
210 7ca9e930 Vangelis Koukis
211 7ca9e930 Vangelis Koukis
    Configure AMQP-specific settings based on backend_prefix.
212 7ca9e930 Vangelis Koukis
    This function *must* be called later in settings.py, with
213 7ca9e930 Vangelis Koukis
    BACKEND_PREFIX_ID as argument.
214 7ca9e930 Vangelis Koukis
215 7ca9e930 Vangelis Koukis
    """
216 7ca9e930 Vangelis Koukis
    global DB_HANDLER_KEY_OP, DB_HANDLER_KEY_NET, BINDINGS, QUEUES
217 7ca9e930 Vangelis Koukis
218 7ca9e930 Vangelis Koukis
    prefix = backend_prefix.split('-')[0]
219 7ca9e930 Vangelis Koukis
    DB_HANDLER_KEY_OP ='ganeti.%s.event.op' % prefix    # notifications of type "ganeti-op-status"
220 7ca9e930 Vangelis Koukis
    DB_HANDLER_KEY_NET ='ganeti.%s.event.net' % prefix  # notifications of type "ganeti-net-status"
221 7ca9e930 Vangelis Koukis
    BINDINGS[0] = ("events-%s-op" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_OP, 'update_db')
222 7ca9e930 Vangelis Koukis
    BINDINGS[1] = ("events-%s-net" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_NET, 'update_net')
223 7ca9e930 Vangelis Koukis
    QUEUES += ("events-%s-op" % prefix, "events-%s-net" % prefix)
224 7ca9e930 Vangelis Koukis
225 7ca9e930 Vangelis Koukis
# Fix up the AMQP-specific settings based on BACKEND_PREFIX_ID
226 7ca9e930 Vangelis Koukis
# Make sure to call it again, if you modify it at some later point
227 7ca9e930 Vangelis Koukis
fix_amqp_settings(BACKEND_PREFIX_ID)
228 7ca9e930 Vangelis Koukis
229 6ec8927b Vangelis Koukis
# Logic dispatcher settings
230 b9eef123 Vangelis Koukis
DISPATCHER_LOG_FILE = "/var/log/synnefo/dispatcher.log"
231 b36421a6 Vangelis Koukis
232 b36421a6 Vangelis Koukis
# The API implementation needs to accept and return absolute references
233 b36421a6 Vangelis Koukis
# to its resources. Thus, it needs to know its public URL.
234 d8e50a39 Giorgos Verigakis
API_ROOT_URL = 'http://127.0.0.1:8000/api/'
235 b36421a6 Vangelis Koukis
236 63efc637 Georgios Gousios
APP_INSTALL_URL = "https://login.okeanos.grnet.gr/okeanos"
237 63efc637 Georgios Gousios
238 63efc637 Georgios Gousios
LOGIN_PATH = "/login"
239 dbf97ed2 Georgios Gousios
240 97e56881 Vangelis Koukis
# Number of hours during which a user token is active
241 97e56881 Vangelis Koukis
# ACHTUNG: The test token distributed in db/initial_data.json will cease to
242 97e56881 Vangelis Koukis
#          work after this many hours after 2011/05/10
243 97e56881 Vangelis Koukis
AUTH_TOKEN_DURATION = 30 * 24
244 8f377cd6 Georgios Gousios
245 8007ba7b Georgios Gousios
# Minutes between reconciliations
246 604b2bf8 Georgios Gousios
RECONCILIATION_MIN = 30
247 65bf328b Georgios Gousios
248 03e70572 Georgios Gousios
#Max number of invitations allowed per user
249 e6d6603a Georgios Gousios
MAX_INVITATIONS = 20
250 e6d6603a Georgios Gousios
251 e6d6603a Georgios Gousios
#Key to encrypt X-Auth-Token with when sending invitations
252 e6d6603a Georgios Gousios
INVITATION_ENCR_KEY = '8d342f6e7a0366c632978a80257019af'
253 e6d6603a Georgios Gousios
254 e6d6603a Georgios Gousios
#Days during which an invitation is active
255 e6d6603a Georgios Gousios
INVITATION_VALID_DAYS = 30
256 e6d6603a Georgios Gousios
257 e6d6603a Georgios Gousios
#SMTP server for the system
258 e6d6603a Georgios Gousios
SMTP_SERVER="127.0.0.1"
259 e6d6603a Georgios Gousios
260 5ad78098 Georgios Gousios
#Email account to use for system emails
261 5ad78098 Georgios Gousios
SYSTEM_EMAIL_ADDR="noreply@grnet.gr"
262 e6d6603a Georgios Gousios
263 6ff84e93 Georgios Gousios
#Enable receiving a temporary auth token (using the ?test URL parameter) that
264 6ff84e93 Georgios Gousios
#bypasses the authentication mechanism
265 6ff84e93 Georgios Gousios
#WARNING, ACHTUNG, README, XXX ,etc: DO NOT ENABLE THIS ON DEPLOYED VERSIONS
266 6ff84e93 Georgios Gousios
BYPASS_AUTHENTICATION = False