github.com/rvaralda/deis@v1.4.1/controller/deis/settings.py (about) 1 """ 2 Django settings for the Deis project. 3 """ 4 5 from __future__ import unicode_literals 6 import os.path 7 import sys 8 import tempfile 9 10 PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '..')) 11 12 DEBUG = False 13 TEMPLATE_DEBUG = DEBUG 14 15 ADMINS = ( 16 # ('Your Name', 'your_email@example.com'), 17 ) 18 19 MANAGERS = ADMINS 20 21 CONN_MAX_AGE = 60 * 3 22 23 # SECURITY: change this to allowed fqdn's to prevent host poisioning attacks 24 # https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts 25 ALLOWED_HOSTS = ['*'] 26 27 # Local time zone for this installation. Choices can be found here: 28 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 29 # although not all choices may be available on all operating systems. 30 # In a Windows environment this must be set to your system time zone. 31 TIME_ZONE = 'UTC' 32 33 # Language code for this installation. All choices can be found here: 34 # http://www.i18nguy.com/unicode/language-identifiers.html 35 LANGUAGE_CODE = 'en-us' 36 37 SITE_ID = 1 38 39 # If you set this to False, Django will make some optimizations so as not 40 # to load the internationalization machinery. 41 USE_I18N = True 42 43 # If you set this to False, Django will not format dates, numbers and 44 # calendars according to the current locale. 45 USE_L10N = True 46 47 # If you set this to False, Django will not use timezone-aware datetimes. 48 USE_TZ = True 49 50 # Absolute filesystem path to the directory that will hold user-uploaded files. 51 # Example: "/var/www/example.com/media/" 52 MEDIA_ROOT = '' 53 54 # URL that handles the media served from MEDIA_ROOT. Make sure to use a 55 # trailing slash. 56 # Examples: "http://example.com/media/", "http://media.example.com/" 57 MEDIA_URL = '' 58 59 # Absolute path to the directory static files should be collected to. 60 # Don't put anything in this directory yourself; store your static files 61 # in apps' "static/" subdirectories and in STATICFILES_DIRS. 62 # Example: "/var/www/example.com/static/" 63 STATIC_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', 'static')) 64 65 # URL prefix for static files. 66 # Example: "http://example.com/static/", "http://static.example.com/" 67 STATIC_URL = '/static/' 68 69 # Additional locations of static files 70 STATICFILES_DIRS = ( 71 # Put strings here, like "/home/html/static" or "C:/www/django/static". 72 # Always use forward slashes, even on Windows. 73 # Don't forget to use absolute paths, not relative paths. 74 ) 75 76 # List of finder classes that know how to find static files in 77 # various locations. 78 STATICFILES_FINDERS = ( 79 'django.contrib.staticfiles.finders.FileSystemFinder', 80 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 81 ) 82 83 # Make this unique, and don't share it with anybody. 84 SECRET_KEY = None # @UnusedVariable 85 86 # List of callables that know how to import templates from various sources. 87 TEMPLATE_LOADERS = ( 88 'django.template.loaders.filesystem.Loader', 89 'django.template.loaders.app_directories.Loader', 90 ) 91 92 TEMPLATE_CONTEXT_PROCESSORS = ( 93 "django.contrib.auth.context_processors.auth", 94 "django.core.context_processors.debug", 95 "django.core.context_processors.i18n", 96 "django.core.context_processors.media", 97 "django.core.context_processors.request", 98 "django.core.context_processors.static", 99 "django.core.context_processors.tz", 100 "django.contrib.messages.context_processors.messages", 101 "deis.context_processors.site", 102 ) 103 104 MIDDLEWARE_CLASSES = ( 105 'corsheaders.middleware.CorsMiddleware', 106 'django.middleware.common.CommonMiddleware', 107 'django.contrib.sessions.middleware.SessionMiddleware', 108 'django.contrib.auth.middleware.AuthenticationMiddleware', 109 'django.contrib.messages.middleware.MessageMiddleware', 110 'api.middleware.APIVersionMiddleware', 111 'deis.middleware.PlatformVersionMiddleware', 112 # Uncomment the next line for simple clickjacking protection: 113 # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 114 ) 115 116 ROOT_URLCONF = 'deis.urls' 117 118 # Python dotted path to the WSGI application used by Django's runserver. 119 WSGI_APPLICATION = 'deis.wsgi.application' 120 121 TEMPLATE_DIRS = ( 122 # Put strings here, like "/home/html/django_templates" 123 # or "C:/www/django/templates". 124 # Always use forward slashes, even on Windows. 125 # Don't forget to use absolute paths, not relative paths. 126 PROJECT_ROOT + '/web/templates', 127 ) 128 129 INSTALLED_APPS = ( 130 'django.contrib.admin', 131 'django.contrib.auth', 132 'django.contrib.contenttypes', 133 'django.contrib.humanize', 134 'django.contrib.messages', 135 'django.contrib.sessions', 136 'django.contrib.sites', 137 'django.contrib.staticfiles', 138 # Third-party apps 139 'guardian', 140 'json_field', 141 'gunicorn', 142 'rest_framework', 143 'rest_framework.authtoken', 144 'south', 145 'corsheaders', 146 # Deis apps 147 'api', 148 'web', 149 ) 150 151 AUTHENTICATION_BACKENDS = ( 152 "django.contrib.auth.backends.ModelBackend", 153 "guardian.backends.ObjectPermissionBackend", 154 ) 155 156 ANONYMOUS_USER_ID = -1 157 LOGIN_URL = '/v1/auth/login/' 158 LOGIN_REDIRECT_URL = '/' 159 160 SOUTH_TESTS_MIGRATE = False 161 162 CORS_ORIGIN_ALLOW_ALL = True 163 164 CORS_ALLOW_HEADERS = ( 165 'content-type', 166 'accept', 167 'origin', 168 'Authentication', 169 ) 170 171 CORS_EXPOSE_HEADERS = ( 172 'X_DEIS_VERSION', 173 'X_DEIS_RELEASE', 174 ) 175 176 REST_FRAMEWORK = { 177 'DEFAULT_MODEL_SERIALIZER_CLASS': 178 'rest_framework.serializers.ModelSerializer', 179 'DEFAULT_PERMISSION_CLASSES': ( 180 'rest_framework.permissions.IsAuthenticated', 181 ), 182 'DEFAULT_AUTHENTICATION_CLASSES': ( 183 'rest_framework.authentication.TokenAuthentication', 184 ), 185 'DEFAULT_RENDERER_CLASSES': ( 186 'rest_framework.renderers.JSONRenderer', 187 ), 188 'PAGINATE_BY': 100, 189 'TEST_REQUEST_DEFAULT_FORMAT': 'json', 190 } 191 192 # URLs that end with slashes are ugly 193 APPEND_SLASH = False 194 195 # Determine where to send syslog messages 196 if os.path.exists('/dev/log'): # Linux rsyslog 197 SYSLOG_ADDRESS = '/dev/log' 198 elif os.path.exists('/var/log/syslog'): # Mac OS X syslog 199 SYSLOG_ADDRESS = '/var/log/syslog' 200 else: # default SysLogHandler address 201 SYSLOG_ADDRESS = ('localhost', 514) 202 203 # A sample logging configuration. The only tangible logging 204 # performed by this configuration is to send an email to 205 # the site admins on every HTTP 500 error when DEBUG=False. 206 # See http://docs.djangoproject.com/en/dev/topics/logging for 207 # more details on how to customize your logging configuration. 208 LOGGING = { 209 'version': 1, 210 'disable_existing_loggers': False, 211 'formatters': { 212 'verbose': { 213 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' 214 }, 215 'simple': { 216 'format': '%(levelname)s %(message)s' 217 }, 218 }, 219 'filters': { 220 'require_debug_false': { 221 '()': 'django.utils.log.RequireDebugFalse' 222 } 223 }, 224 'handlers': { 225 'null': { 226 'level': 'DEBUG', 227 'class': 'logging.NullHandler', 228 }, 229 'console': { 230 'level': 'DEBUG', 231 'class': 'logging.StreamHandler', 232 'formatter': 'simple' 233 }, 234 'mail_admins': { 235 'level': 'ERROR', 236 'filters': ['require_debug_false'], 237 'class': 'django.utils.log.AdminEmailHandler' 238 }, 239 'rsyslog': { 240 'class': 'logging.handlers.SysLogHandler', 241 'address': SYSLOG_ADDRESS, 242 'facility': 'local0', 243 }, 244 }, 245 'loggers': { 246 'django': { 247 'handlers': ['null'], 248 'level': 'INFO', 249 'propagate': True, 250 }, 251 'django.request': { 252 'handlers': ['console', 'mail_admins'], 253 'level': 'WARNING', 254 'propagate': True, 255 }, 256 'api': { 257 'handlers': ['console', 'mail_admins', 'rsyslog'], 258 'level': 'INFO', 259 'propagate': True, 260 }, 261 } 262 } 263 TEST_RUNNER = 'api.tests.SilentDjangoTestSuiteRunner' 264 265 # etcd settings 266 ETCD_HOST, ETCD_PORT = os.environ.get('ETCD', '127.0.0.1:4001').split(',')[0].split(':') 267 268 # default deis settings 269 DEIS_LOG_DIR = os.path.abspath(os.path.join(__file__, '..', '..', 'logs')) 270 LOG_LINES = 1000 271 TEMPDIR = tempfile.mkdtemp(prefix='deis') 272 DEIS_DOMAIN = 'deisapp.local' 273 274 # standard datetime format used for logging, model timestamps, etc. 275 DEIS_DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S%Z' 276 277 # default scheduler settings 278 SCHEDULER_MODULE = 'scheduler.mock' 279 SCHEDULER_TARGET = '' # path to scheduler endpoint (e.g. /var/run/fleet.sock) 280 SCHEDULER_AUTH = '' 281 SCHEDULER_OPTIONS = {} 282 283 # security keys and auth tokens 284 SSH_PRIVATE_KEY = '' # used for SSH connections to facilitate "deis run" 285 SECRET_KEY = os.environ.get('DEIS_SECRET_KEY', 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi') 286 BUILDER_KEY = os.environ.get('DEIS_BUILDER_KEY', 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi') 287 288 # registry settings 289 REGISTRY_MODULE = 'registry.mock' 290 REGISTRY_URL = 'http://localhost:5000' 291 REGISTRY_HOST = 'localhost' 292 REGISTRY_PORT = 5000 293 294 # check if we can register users with `deis register` 295 REGISTRATION_ENABLED = True 296 297 # check if we should enable the web UI module 298 WEB_ENABLED = False 299 300 # default to sqlite3, but allow postgresql config through envvars 301 DATABASES = { 302 'default': { 303 'ENGINE': 'django.db.backends.' + os.environ.get('DATABASE_ENGINE', 'postgresql_psycopg2'), 304 'NAME': os.environ.get('DATABASE_NAME', 'deis'), 305 } 306 } 307 308 APP_URL_REGEX = '[a-z0-9-]+' 309 310 # Honor HTTPS from a trusted proxy 311 # see https://docs.djangoproject.com/en/1.6/ref/settings/#secure-proxy-ssl-header 312 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') 313 314 # Unit Hostname handling. 315 # Supports: 316 # default - Docker generated hostname 317 # application - Hostname based on application unit name (i.e. my-application.v2.web.1) 318 # server - Hostname based on CoreOS server hostname 319 UNIT_HOSTNAME = 'default' 320 321 # Create a file named "local_settings.py" to contain sensitive settings data 322 # such as database configuration, admin email, or passwords and keys. It 323 # should also be used for any settings which differ between development 324 # and production. 325 # The local_settings.py file should *not* be checked in to version control. 326 try: 327 from .local_settings import * # noqa 328 except ImportError: 329 pass 330 331 332 # have confd_settings within container execution override all others 333 # including local_settings (which may end up in the container) 334 if os.path.exists('/templates/confd_settings.py'): 335 sys.path.append('/templates') 336 from confd_settings import * # noqa