github.com/ahjdzx/deis@v1.1.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 # Hosts/domain names that are valid for this site; required if DEBUG is False 24 # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts 25 ALLOWED_HOSTS = ['localhost'] 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 'django_fsm', 140 'guardian', 141 'json_field', 142 'gunicorn', 143 'rest_framework', 144 'rest_framework.authtoken', 145 'south', 146 'corsheaders', 147 # Deis apps 148 'api', 149 'web', 150 ) 151 152 AUTHENTICATION_BACKENDS = ( 153 "django.contrib.auth.backends.ModelBackend", 154 "guardian.backends.ObjectPermissionBackend", 155 ) 156 157 ANONYMOUS_USER_ID = -1 158 ACCOUNT_EMAIL_REQUIRED = True 159 ACCOUNT_EMAIL_VERIFICATION = 'none' 160 ACCOUNT_LOGOUT_ON_GET = True 161 ACCOUNT_USERNAME_BLACKLIST = ['system'] 162 LOGIN_URL = '/v1/auth/login/' 163 LOGIN_REDIRECT_URL = '/' 164 165 SOUTH_TESTS_MIGRATE = False 166 167 CORS_ORIGIN_ALLOW_ALL = True 168 169 CORS_ALLOW_HEADERS = ( 170 'content-type', 171 'accept', 172 'origin', 173 'Authentication', 174 ) 175 176 CORS_EXPOSE_HEADERS = ( 177 'X_DEIS_VERSION', 178 'X_DEIS_RELEASE', 179 ) 180 181 REST_FRAMEWORK = { 182 'DEFAULT_MODEL_SERIALIZER_CLASS': 183 'rest_framework.serializers.ModelSerializer', 184 'DEFAULT_PERMISSION_CLASSES': ( 185 'rest_framework.permissions.IsAuthenticated', 186 ), 187 'DEFAULT_AUTHENTICATION_CLASSES': ( 188 'rest_framework.authentication.TokenAuthentication', 189 ), 190 'PAGINATE_BY': 100, 191 } 192 193 # URLs that end with slashes are ugly 194 APPEND_SLASH = False 195 196 # Determine where to send syslog messages 197 if os.path.exists('/dev/log'): # Linux rsyslog 198 SYSLOG_ADDRESS = '/dev/log' 199 elif os.path.exists('/var/log/syslog'): # Mac OS X syslog 200 SYSLOG_ADDRESS = '/var/log/syslog' 201 else: # default SysLogHandler address 202 SYSLOG_ADDRESS = ('localhost', 514) 203 204 # A sample logging configuration. The only tangible logging 205 # performed by this configuration is to send an email to 206 # the site admins on every HTTP 500 error when DEBUG=False. 207 # See http://docs.djangoproject.com/en/dev/topics/logging for 208 # more details on how to customize your logging configuration. 209 LOGGING = { 210 'version': 1, 211 'disable_existing_loggers': False, 212 'formatters': { 213 'verbose': { 214 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' 215 }, 216 'simple': { 217 'format': '%(levelname)s %(message)s' 218 }, 219 }, 220 'filters': { 221 'require_debug_false': { 222 '()': 'django.utils.log.RequireDebugFalse' 223 } 224 }, 225 'handlers': { 226 'null': { 227 'level': 'DEBUG', 228 'class': 'logging.NullHandler', 229 }, 230 'console': { 231 'level': 'DEBUG', 232 'class': 'logging.StreamHandler', 233 'formatter': 'simple' 234 }, 235 'mail_admins': { 236 'level': 'ERROR', 237 'filters': ['require_debug_false'], 238 'class': 'django.utils.log.AdminEmailHandler' 239 }, 240 'rsyslog': { 241 'class': 'logging.handlers.SysLogHandler', 242 'address': SYSLOG_ADDRESS, 243 'facility': 'local0', 244 }, 245 }, 246 'loggers': { 247 'django': { 248 'handlers': ['null'], 249 'level': 'INFO', 250 'propagate': True, 251 }, 252 'django.request': { 253 'handlers': ['console', 'mail_admins'], 254 'level': 'WARNING', 255 'propagate': True, 256 }, 257 'api': { 258 'handlers': ['console', 'mail_admins', 'rsyslog'], 259 'level': 'INFO', 260 'propagate': True, 261 }, 262 } 263 } 264 TEST_RUNNER = 'api.tests.SilentDjangoTestSuiteRunner' 265 266 # etcd settings 267 ETCD_HOST, ETCD_PORT = os.environ.get('ETCD', '127.0.0.1:4001').split(',')[0].split(':') 268 269 # default deis settings 270 DEIS_LOG_DIR = os.path.abspath(os.path.join(__file__, '..', '..', 'logs')) 271 LOG_LINES = 1000 272 TEMPDIR = tempfile.mkdtemp(prefix='deis') 273 DEFAULT_BUILD = 'deis/helloworld' 274 DEIS_DOMAIN = 'deisapp.local' 275 276 # standard datetime format used for logging, model timestamps, etc. 277 DEIS_DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S%Z' 278 279 # default scheduler settings 280 SCHEDULER_MODULE = 'mock' 281 SCHEDULER_TARGET = '' # path to scheduler endpoint (e.g. /var/run/fleet.sock) 282 SCHEDULER_AUTH = '' 283 SCHEDULER_OPTIONS = {} 284 285 # security keys and auth tokens 286 SSH_PRIVATE_KEY = '' # used for SSH connections to facilitate "deis run" 287 SECRET_KEY = os.environ.get('DEIS_SECRET_KEY', 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi') 288 BUILDER_KEY = os.environ.get('DEIS_BUILDER_KEY', 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi') 289 290 # registry settings 291 REGISTRY_MODULE = 'registry.mock' 292 REGISTRY_URL = 'http://localhost:5000' 293 REGISTRY_HOST = 'localhost' 294 REGISTRY_PORT = 5000 295 296 # check if we can register users with `deis register` 297 REGISTRATION_ENABLED = True 298 299 # check if we should enable the web UI module 300 WEB_ENABLED = False 301 302 # default to sqlite3, but allow postgresql config through envvars 303 DATABASES = { 304 'default': { 305 'ENGINE': 'django.db.backends.' + os.environ.get('DATABASE_ENGINE', 'postgresql_psycopg2'), 306 'NAME': os.environ.get('DATABASE_NAME', 'deis'), 307 } 308 } 309 310 APP_URL_REGEX = '[a-z0-9-]+' 311 312 # SECURITY: change this to allowed fqdn's to prevent host poisioning attacks 313 # see https://docs.djangoproject.com/en/1.5/ref/settings/#std:setting-ALLOWED_HOSTS 314 ALLOWED_HOSTS = ['*'] 315 316 # Honor HTTPS from a trusted proxy 317 # see https://docs.djangoproject.com/en/1.6/ref/settings/#secure-proxy-ssl-header 318 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') 319 320 # Create a file named "local_settings.py" to contain sensitive settings data 321 # such as database configuration, admin email, or passwords and keys. It 322 # should also be used for any settings which differ between development 323 # and production. 324 # The local_settings.py file should *not* be checked in to version control. 325 try: 326 from .local_settings import * # noqa 327 except ImportError: 328 pass 329 330 331 # have confd_settings within container execution override all others 332 # including local_settings (which may end up in the container) 333 if os.path.exists('/templates/confd_settings.py'): 334 sys.path.append('/templates') 335 from confd_settings import * # noqa