blob: cc2c62e99893eb4b1c577929db0c1aaabbdc1856 [file] [log] [blame]
srikanth116e6e82014-08-19 07:22:37 -07001#
2# Copyright (c) 2013 Big Switch Networks, Inc.
3#
4# Licensed under the Eclipse Public License, Version 1.0 (the
5# "License"); you may not use this file except in compliance with the
6# License. You may obtain a copy of the License at
7#
8# http://www.eclipse.org/legal/epl-v10.html
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13# implied. See the License for the specific language governing
14# permissions and limitations under the License.
15#
16
17# Django settings for sdncon project.
18
19import os, sys
20from cassandra.ttypes import ConsistencyLevel
21
22DEBUG = True
23DEBUG_PROPAGATE_EXCEPTIONS = DEBUG
24TEMPLATE_DEBUG = DEBUG
25
26ADMINS = (
27 # ('Your Name', 'your_email@domain.com'),
28)
29
30MANAGERS = ADMINS
31
32DATABASES = {
33 'default': {
34 'ENGINE': 'django_cassandra.db',
35 'NAME': 'sdncon',
36 'USER': '', # Not used with sqlite3.
37 'PASSWORD': '', # Not used with sqlite3.
38 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
39 'PORT': '', # Set to empty string for default. Not used with sqlite3.
40 }
41}
42
43# Settings for accessing the stats database/keyspace.
44# This does not go through the usual Django model/database layer, but
45# instead accesses Cassandra directly.
46STATS_DATABASE = {
47 'NAME': 'sdnstats',
48 #'HOST': '',
49 #'USER': '',
50 #'PASSWORD': '',
51 #'CASSANDRA_REPLICATION_FACTOR': 1
52}
53
54# Local time zone for this installation. Choices can be found here:
55# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
56# although not all choices may be available on all operating systems.
57# On Unix systems, a value of None will cause Django to use the same
58# timezone as the operating system.
59# If running in a Windows environment this must be set to the same as your
60# system time zone.
61#TIME_ZONE = 'America/Los_Angeles'
62TIME_ZONE = None
63
64# Language code for this installation. All choices can be found here:
65# http://www.i18nguy.com/unicode/language-identifiers.html
66LANGUAGE_CODE = 'en-us'
67
68SITE_ID = '1'
69
70# Tell Django where is the profile object
71#AUTH_PROFILE_MODULE = "sdncon.account.UserProfile"
72
73# If you set this to False, Django will make some optimizations so as not
74# to load the internationalization machinery.
75USE_I18N = True
76
77# If you set this to False, Django will not format dates, numbers and
78# calendars according to the current locale
79USE_L10N = True
80
81# Absolute path to the directory that holds media.
82# Example: "/home/media/media.lawrence.com/"
83SDN_ROOT = "/opt/sdnplatform" if not 'SDN_ROOT' in os.environ else os.environ['SDN_ROOT']
84MEDIA_ROOT = "%s/con/lib/python/django/contrib/admin/media/" % SDN_ROOT
85
86# URL that handles the media served from MEDIA_ROOT. Make sure to use a
87# trailing slash if there is a path component (optional in other cases).
88# Examples: "http://media.lawrence.com", "http://example.com/media/"
89MEDIA_URL = ''
90STATIC_URL = '/static/'
91
92# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
93# trailing slash.
94# Examples: "http://foo.com/media/", "/media/".
95ADMIN_MEDIA_PREFIX = '/media/'
96
97# URL prefixes exempted from login requirements
98EXEMPT_URLS = ['/coreui/static/', '/coreui/img/', '/favicon.ico']
99
100# Make this unique, and don't share it with anybody.
101SECRET_KEY = 'p+7!f6@8ry2%faunco@u@$wzq7_jpyw4w7+sn=&xpuvo%2!uw('
102
103# List of callables that know how to import templates from various sources.
104TEMPLATE_LOADERS = (
105 'django.template.loaders.filesystem.Loader',
106 'django.template.loaders.app_directories.Loader',
107# 'django.template.loaders.eggs.Loader',
108)
109
110from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as GLOBAL_TEMPLATE_CONTEXT_PROCESSORS
111TEMPLATE_CONTEXT_PROCESSORS = GLOBAL_TEMPLATE_CONTEXT_PROCESSORS + (
112 'sdncon.clusterAdmin.utils.uicontext',
113)
114
115MIDDLEWARE_CLASSES = (
116 'sdncon.HARedirectMiddleWare',
117 'django.middleware.common.CommonMiddleware',
118 'django.contrib.sessions.middleware.SessionMiddleware',
119 'django.middleware.csrf.CsrfViewMiddleware',
120 'django.contrib.auth.middleware.AuthenticationMiddleware',
121 'sdncon.clusterAdmin.middleware.ClusterAuthenticate',
122 'sdncon.clusterAdmin.middleware.RequireAuthMiddleware',
123 'django.contrib.messages.middleware.MessageMiddleware',
124 'sdncon.SDNConAppLoaderMiddleWare',
125)
126
127# Django uses browser-length cookies that expire as soon as the user closes the browser.
128SESSION_EXPIRE_AT_BROWSER_CLOSE = True
129SESSION_COOKIE_AGE = 2592000 # 30 days, in seconds
130
131ROOT_URLCONF = 'sdncon.urls'
132
133TEMPLATE_DIRS = (
134 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
135 # Always use forward slashes, even on Windows.
136 # Don't forget to use absolute paths, not relative paths.
137 os.path.dirname(__file__),
138 os.path.join(os.path.dirname(__file__),'clusterAdmin/templates'),
139)
140
141# Include applications dynamically from the apps folder
142
143APP_DIR = os.path.join(os.path.dirname(__file__),'apps')
144sys.path.append(APP_DIR)
145
146apps_array = [
147 'django.contrib.auth',
148 'django.contrib.contenttypes',
149 'django.contrib.sessions',
150 'django.contrib.staticfiles',
151 #'django.contrib.sites',
152 'django.contrib.messages',
153 # Uncomment the next line to enable the admin:
154 'django.contrib.admin',
155 'djangotoolbox',
156 'sdncon.rest',
157 'sdncon.controller',
158 'django_cassandra',
159 'sdncon.coreui',
160 'sdncon.clusterAdmin',
161 #'sdncon.account',
162 'sdncon.ui',
163 'sdncon.stats',
164 'sdncon.syncd',
165 'sdncon.statdropd'
166]
167
168directory = os.listdir(APP_DIR)
169for filename in directory:
170 if not filename.startswith('.'):
171 apps_array.append(os.path.basename(filename))
172
173INSTALLED_APPS = tuple(apps_array)
174
175STATS_METADATA_MODULES = []
176
177_stats_meatadata_dir_name = 'stats_metadata'
178_stats_metadata_dir = os.path.join(os.path.dirname(__file__), _stats_meatadata_dir_name)
179_directory = os.listdir(_stats_metadata_dir)
180
181for _filename in _directory:
182 _basename = os.path.basename(_filename)
183 if _basename.endswith('.py') and _basename != '__init__.py':
184 _module_name = os.path.splitext(_basename)[0]
185 STATS_METADATA_MODULES.append('sdncon.%s.%s' % (_stats_meatadata_dir_name, _module_name))