Statistics
| Branch: | Tag: | Revision:

root / settings.py.dist @ 5ad78098

History | View | Annotate | Download (8.7 kB)

1
# -*- coding: utf-8 -*-
2

    
3
# Django settings for synnefo project.
4
import os
5

    
6
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
7

    
8
DEBUG = True
9
TEMPLATE_DEBUG = DEBUG
10

    
11
# A quick-n-dirty way to know if we're running unit tests
12
import sys
13
TEST = False
14
if len(sys.argv) >= 2:
15
    if os.path.basename(sys.argv[0]) == 'manage.py' and \
16
        (sys.argv[1] == 'test' or sys.argv[1] == 'hudson'):
17
            TEST = True
18

    
19
ADMINS = (
20
    # ('Your Name', 'your_email@domain.com'),
21
)
22

    
23
MANAGERS = ADMINS
24

    
25
DATABASES = {
26
    'default': {
27
        # 'postgresql_psycopg2', 'postgresql','mysql', 'sqlite3' or 'oracle'
28
        'ENGINE': 'sqlite3',
29
         # ATTENTION: This *must* be the absolute path if using sqlite3.
30
         # See: http://docs.djangoproject.com/en/dev/ref/settings/#name
31
        'NAME': PROJECT_PATH + 'database.sqlite',
32
        'USER': '',                      # Not used with sqlite3.
33
        'PASSWORD': '',                  # Not used with sqlite3.
34
        # Set to empty string for localhost. Not used with sqlite3.
35
        'HOST': '',
36
        # Set to empty string for default. Not used with sqlite3.
37
        'PORT': '',
38
    }
39
}
40

    
41
if DATABASES['default']['ENGINE'].endswith('mysql'):
42
    DATABASES['default']['OPTIONS'] = {
43
        'init_command': 'SET storage_engine=INNODB',
44
    }
45

    
46
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
47

    
48
# Local time zone for this installation. Choices can be found here:
49
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
50
# although not all choices may be available on all operating systems.
51
# On Unix systems, a value of None will cause Django to use the same
52
# timezone as the operating system.
53
# If running in a Windows environment this must be set to the same as your
54
# system time zone.
55
TIME_ZONE = 'UTC'   # Warning: API depends on the TIME_ZONE being UTC
56

    
57
# Language code for this installation. All choices can be found here:
58
# http://www.i18nguy.com/unicode/language-identifiers.html
59
LANGUAGE_CODE = 'en-us'
60

    
61
SITE_ID = 1
62

    
63
# If you set this to False, Django will make some optimizations so as not
64
# to load the internationalization machinery.
65
USE_I18N = True
66

    
67
# If you set this to False, Django will not format dates, numbers and
68
# calendars according to the current locale
69
USE_L10N = True
70

    
71
# Absolute path to the directory that holds media.
72
# Example: "/home/media/media.lawrence.com/"
73
MEDIA_ROOT = ''
74

    
75
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
76
# trailing slash if there is a path component (optional in other cases).
77
# Examples: "http://media.lawrence.com", "http://example.com/media/"
78
MEDIA_URL = ''
79

    
80
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
81
# trailing slash.
82
# Examples: "http://foo.com/media/", "/media/".
83
ADMIN_MEDIA_PREFIX = '/media/'
84

    
85
# our REST API would prefer to be explicit about trailing slashes
86
APPEND_SLASH = False
87

    
88
# Make this unique, and don't share it with anybody.
89
SECRET_KEY = 'ly6)mw6a7x%n)-e#zzk4jo6f2=uqu!1o%)2-(7lo+f9yd^k^bg'
90

    
91
# List of callables that know how to import templates from various sources.
92
TEMPLATE_LOADERS = (
93
    'django.template.loaders.filesystem.Loader',
94
    'django.template.loaders.app_directories.Loader',
95
#     'django.template.loaders.eggs.Loader',
96
)
97

    
98
TEMPLATE_CONTEXT_PROCESSORS = (
99
    'django.core.context_processors.request',
100
    'django.core.context_processors.i18n',
101
    'django.contrib.auth.context_processors.auth',
102
)
103

    
104
MIDDLEWARE_CLASSES = (
105
    'django.contrib.sessions.middleware.SessionMiddleware',
106
    'synnefo.aai.middleware.SynnefoAuthMiddleware',
107
    'synnefo.api.middleware.ApiAuthMiddleware',
108
    'django.middleware.locale.LocaleMiddleware',
109
    'django.middleware.common.CommonMiddleware',
110
    'django.contrib.messages.middleware.MessageMiddleware'
111
)
112

    
113
ROOT_URLCONF = 'synnefo.urls'
114

    
115
TEMPLATE_DIRS = (
116
    # Put strings here, like "/home/html/django_templates"
117
    # or "C:/www/django/templates".
118
    # Always use forward slashes, even on Windows.
119
    # Don't forget to use absolute paths, not relative paths.
120
)
121

    
122
INSTALLED_APPS = (
123
    'django.contrib.contenttypes',
124
    'django.contrib.sessions',
125
    'django.contrib.sites',
126
    'django.contrib.messages',
127
    'django.contrib.admin',
128
    # 'django.contrib.admindocs',
129
    'synnefo.aai',
130
    'synnefo.api',
131
    'synnefo.ui',
132
    'synnefo.db',
133
    'synnefo.ganeti',
134
    'synnefo.logic',
135
    'synnefo.invitations',
136
    'south'
137
)
138

    
139
# The RAPI endpoint and associated credentials to use
140
# for talking to the Ganeti backend.
141
GANETI_MASTER_IP = "62.217.120.78"
142
GANETI_CLUSTER_INFO = (GANETI_MASTER_IP, 5080, "synnefo", "ocean!")
143

    
144
# This prefix gets used when determining the instance names
145
# of Synnefo VMs at the Ganeti backend.
146
# The dash must always appear in the name!
147
BACKEND_PREFIX_ID = "snf-"
148

    
149
LANGUAGES = (
150
  ('el', u'Ελληνικά'),
151
  ('en', 'English'),
152
)
153

    
154
# needed for django. this is the class that implements the User system.
155
# We use this to allow users to add stuff for themselves (about, image etc)
156
#http://docs.djangoproject.com/en/dev/topics/auth/#auth-profiles
157
AUTH_PROFILE_MODULE = 'synnefo.OceanUser'
158

    
159
# API requests from the GUI time out after that many seconds.
160
TIMEOUT = 10 * 1000
161

    
162
# The API will return HTTP Bad Request if the ?changes-since
163
# parameter refers to a point in time more than POLL_LIMIT seconds ago.
164
POLL_LIMIT = 3600
165

    
166
# Configuration for ganeti-eventd, the Ganeti notification daemon
167
GANETI_EVENTD_LOG_FILE = "/var/log/synnefo/ganeti-eventd.log"
168
GANETI_EVENTD_PID_FILE = "/var/run/synnefo/ganeti-eventd.pid"
169

    
170
# Rabbit work queue endpoint
171
RABBIT_HOST = "62.217.120.67:5672"
172
RABBIT_USERNAME = "okeanos"
173
RABBIT_PASSWORD = "0k3@n0s"
174
RABBIT_VHOST = "/"
175

    
176
# 
177
# Queues, exchanges and bindings for AMQP
178
#
179
EXCHANGE_GANETI = "ganeti"  # Messages from Ganeti
180
EXCHANGE_CRON = "cron"      # Messages from periodically triggered tasks
181
EXCHANGE_API = "api"        # Messages from the Rest API
182
EXCHANGES = (EXCHANGE_GANETI, EXCHANGE_CRON, EXCHANGE_API)
183

    
184
QUEUE_GANETI_EVENTS = "events"
185
QUEUE_CRON_CREDITS = "credits"
186
QUEUE_EMAIL = "email"
187
QUEUE_DEBUG = "debug"       # Debug queue, retrieves all messages
188
QUEUES = (QUEUE_GANETI_EVENTS, QUEUE_CRON_CREDITS, QUEUE_EMAIL)
189

    
190
BINDINGS_DEBUG = [
191
    # Queue         # Exchange          # RouteKey  # Handler
192
    (QUEUE_DEBUG,   EXCHANGE_GANETI,    '#',        'dummy_proc'),
193
    (QUEUE_DEBUG,   EXCHANGE_CRON,      '#',        'dummy_proc'),
194
    (QUEUE_DEBUG,   EXCHANGE_API,       '#',        'dummy_proc'),
195
]
196

    
197
BINDINGS = [
198
    # Queue                 # Exchange          # RouteKey            #Handler
199
    (QUEUE_GANETI_EVENTS,   EXCHANGE_GANETI,    'ganeti.*.event.op',  'update_db'),
200
    (QUEUE_GANETI_EVENTS,   EXCHANGE_GANETI,    'ganeti.*.event.net', 'update_net'),
201
    (QUEUE_CRON_CREDITS,    EXCHANGE_CRON,      '*.credits.*',        'update_credits'),
202
    (QUEUE_EMAIL,           EXCHANGE_API,       '*.email.*',          'send_email'),
203
    (QUEUE_EMAIL,           EXCHANGE_CRON,      '*.email.*',          'send_email'),
204
]
205

    
206
def fix_amqp_settings(backend_prefix):
207
    """Configure AMQP-specific settings
208

    
209
    Configure AMQP-specific settings based on backend_prefix.
210
    This function *must* be called later in settings.py, with
211
    BACKEND_PREFIX_ID as argument.
212

    
213
    """
214
    global DB_HANDLER_KEY_OP, DB_HANDLER_KEY_NET, BINDINGS, QUEUES
215

    
216
    prefix = backend_prefix.split('-')[0]
217
    DB_HANDLER_KEY_OP ='ganeti.%s.event.op' % prefix    # notifications of type "ganeti-op-status"
218
    DB_HANDLER_KEY_NET ='ganeti.%s.event.net' % prefix  # notifications of type "ganeti-net-status"
219
    BINDINGS[0] = ("events-%s-op" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_OP, 'update_db')
220
    BINDINGS[1] = ("events-%s-net" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_NET, 'update_net')
221
    QUEUES += ("events-%s-op" % prefix, "events-%s-net" % prefix)
222

    
223
# Fix up the AMQP-specific settings based on BACKEND_PREFIX_ID
224
# Make sure to call it again, if you modify it at some later point
225
fix_amqp_settings(BACKEND_PREFIX_ID)
226

    
227
# Logic dispatcher settings
228
DISPATCHER_LOG_FILE = "/var/log/synnefo/dispatcher.log"
229

    
230
# The API implementation needs to accept and return absolute references
231
# to its resources. Thus, it needs to know its public URL.
232
API_ROOT_URL = 'http://127.0.0.1:8000/api/'
233

    
234
APP_INSTALL_URL = "https://login.okeanos.grnet.gr/okeanos"
235

    
236
LOGIN_PATH = "/login"
237

    
238
# Number of hours during which a user token is active
239
# ACHTUNG: The test token distributed in db/initial_data.json will cease to
240
#          work after this many hours after 2011/05/10
241
AUTH_TOKEN_DURATION = 30 * 24
242

    
243
#Max number of invitations allowed per user
244
MAX_INVITATIONS = 20
245

    
246
#Key to encrypt X-Auth-Token with when sending invitations
247
INVITATION_ENCR_KEY = '8d342f6e7a0366c632978a80257019af'
248

    
249
#Days during which an invitation is active
250
INVITATION_VALID_DAYS = 30
251

    
252
#SMTP server for the system
253
SMTP_SERVER="127.0.0.1"
254

    
255
#Email account to use for system emails
256
SYSTEM_EMAIL_ADDR="noreply@grnet.gr"
257