Revision 1277fb19 settings.py.dist

b/settings.py.dist
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_RECONC = "reconciliation"
188
QUEUE_DEBUG = "debug"       # Debug queue, retrieves all messages
189
QUEUES = (QUEUE_GANETI_EVENTS, QUEUE_CRON_CREDITS, QUEUE_EMAIL, QUEUE_RECONC)
190

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

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

  
208
def fix_amqp_settings(backend_prefix):
209
    """Configure AMQP-specific settings
210

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

  
215
    """
216
    global DB_HANDLER_KEY_OP, DB_HANDLER_KEY_NET, BINDINGS, QUEUES
217

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

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

  
229
# Logic dispatcher settings
230
DISPATCHER_LOG_FILE = "/var/log/synnefo/dispatcher.log"
231

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

  
236
APP_INSTALL_URL = "https://login.okeanos.grnet.gr/okeanos"
237

  
238
LOGIN_PATH = "/login"
239

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

  
245
# Minutes between reconciliations
246
RECONCILIATION_MIN = 30
247

  
248
# Max number of invitations allowed per user
249
MAX_INVITATIONS = 20
250

  
251
# Key to encrypt X-Auth-Token with when sending invitations
252
INVITATION_ENCR_KEY = '8d342f6e7a0366c632978a80257019af'
253

  
254
# Days for which an invitation is active
255
INVITATION_VALID_DAYS = 30
256

  
257
# SMTP server to use when sending out emails
258
SMTP_SERVER="127.0.0.1"
259

  
260
# The address to use in the From: field when sending out emails
261
SYSTEM_EMAIL_ADDR="noreply@grnet.gr"
262

  
263
# Enable receiving a temporary auth token (using the ?test URL parameter) that
264
# bypasses the authentication mechanism
265
#
266
# WARNING, ACHTUNG, README, etc: DO NOT ENABLE THIS ON DEPLOYED VERSIONS!
267
#
268
BYPASS_AUTHENTICATION = False
269

  
270
#
271
# Network Configuration
272
#
273
# Synnefo assigns this link id to NICs connected on the public network.
274
# An IP pool should be associated with this link by the Ganeti administrator.
275
GANETI_PUBLIC_LINK = 'snf_public'
276
# This link id is assigned to NICs that should be isolated from anything else
277
# (e.g., right before the NIC gets deleted).
278
# This value is also hardcoded in a fixture in db/fixtures/initial_data.json.
279
GANETI_NULL_LINK = 'snf_null'
280
#
281
# The pool of private network links to use is
282
# $GANETI_LINK_PREFIX{1..$GANETI_MAX_LINK_NUMBER}.
283
#
284
# The prefix to use for private network links.
285
GANETI_LINK_PREFIX = 'prv'
286
# The number of private network links to use.
287
GANETI_MAX_LINK_NUMBER = 100
288

  
289
GANETI_FIREWALL_ENABLED_TAG = 'synnefo:network:0:enabled'
290
GANETI_FIREWALL_DISABLED_TAG = 'synnefo:network:0:disabled'
291
GANETI_FIREWALL_PROTECTED_TAG = 'synnefo:network:0:protected'
292

  
293
# A list of suggested server tags (server metadata keys)
294
DEFAULT_KEYWORDS = ["OS", "Role", "Location", "Owner"]
295

  
296
# A list of allowed icons for OS Images
297
IMAGE_ICONS = ["redhat", "ubuntu", "debian", "windows", "gentoo", "archlinux",
298
               "centos", "fedora", "freebsd", "netbsd", "openbsd", "slackware",
299
               "suse"]
1
# Copyright 2011 GRNET S.A. All rights reserved.
2
# 
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
# 
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
# 
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
# 
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
# 
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.
33

  
34
import os.path
35
import glob
36

  
37
conffiles = glob.glob(os.path.join(os.path.dirname(__file__),
38
                      'settings.d', '*.conf'))
39
conffiles.sort()
40
for f in conffiles:
41
    execfile(os.path.abspath(f))

Also available in: Unified diff