Statistics
| Branch: | Tag: | Revision:

root / settings.py.dist @ 64938cb0

History | View | Annotate | Download (8.4 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
    'south'
136
)
137

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
235
LOGIN_PATH = "/login"
236

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

    
242
GANETI_PUBLIC_LINK = 'snf_public'
243
GANETI_LINK_PREFIX = 'prv'
244
GANETI_MAX_LINK_NUMBER = 100