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