-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathsettings.py
310 lines (261 loc) · 9.15 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
"""
Django settings for cloudlaunch project.
Generated by 'django-admin startproject' using Django 1.9.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# Django site id
SITE_ID = 1
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'CHANGEthisONinstall'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['*']
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_EMAIL_REQUIRED = False
LOGIN_REDIRECT_URL = "/catalog"
# Begin: django-cors-headers settings
CORS_ORIGIN_ALLOW_ALL = True
# Django filters out headers with an underscore by default, so make sure they
# have dashes instead.
from corsheaders.defaults import default_headers
CORS_ALLOW_HEADERS = default_headers + (
'cl-credentials-id',
'cl-os-username',
'cl-os-password',
'cl-os-tenant-name',
'cl-os-project-name',
'cl-os-project-domain-name',
'cl-os-user-domain-name',
'cl-os-identity-api-version',
'cl-aws-access-key',
'cl-aws-secret-key',
'cl-azure-subscription-id'
'cl-azure-client-id',
'cl-azure-secret',
'cl-azure-tenant',
'cl-azure-resource-group',
'cl-azure-storage-account',
'cl-azure-vm-default-username',
'cl-gcp-credentials-json',
'cl-gcp-vm-default-username',
)
# End: django-cors-headers settings
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# Application definition
INSTALLED_APPS = [
# Django auto complete light - for autocompleting foreign keys in admin
'dal',
'dal_select2',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'django.contrib.sites',
'nested_admin',
'corsheaders',
'rest_auth',
'allauth',
'allauth.account',
'rest_auth.registration',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.github',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.twitter',
'djcloudbridge',
'public_appliances',
'cloudlaunch',
# rest framework must come after cloudlaunch so templates can be overridden
'rest_framework',
'django_celery_results',
'django_celery_beat',
'django_countries',
'django_filters',
'polymorphic',
'cloudlaunchserver'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'cloudlaunchserver.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'cloudlaunchserver.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.' + os.environ.get('CLOUDLAUNCH_DB_ENGINE', 'sqlite3'),
'NAME': os.environ.get('CLOUDLAUNCH_DB_NAME', os.path.join(BASE_DIR, 'db.sqlite3')),
# The following settings are not used with sqlite3:
'USER': os.environ.get('CLOUDLAUNCH_DB_USER'),
'HOST': os.environ.get('CLOUDLAUNCH_DB_HOST'), # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': os.environ.get('CLOUDLAUNCH_DB_PORT'), # Set to empty string for default.
'PASSWORD': os.environ.get('CLOUDLAUNCH_DB_PASSWORD'),
}
}
SITE_ID = 1
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
AUTHENTICATION_BACKENDS = [
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'US/Eastern'
USE_I18N = False
USE_L10N = True
USE_TZ = True
CLOUDLAUNCH_PATH_PREFIX = os.environ.get('CLOUDLAUNCH_PATH_PREFIX', '')
FORCE_SCRIPT_NAME = CLOUDLAUNCH_PATH_PREFIX
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = CLOUDLAUNCH_PATH_PREFIX + '/cloudlaunch/static/'
# Installed apps settings
REST_FRAMEWORK = {
'PAGE_SIZE': 50,
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'DEFAULT_AUTHENTICATION_CLASSES': (
# 'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
'cloudlaunch.authentication.TokenAuthentication'
),
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'
}
REST_AUTH_SERIALIZERS = {
'USER_DETAILS_SERIALIZER': 'djcloudbridge.serializers.UserSerializer'
}
REST_AUTH_TOKEN_MODEL = 'cloudlaunch.models.AuthToken'
REST_AUTH_TOKEN_CREATOR = 'cloudlaunch.authentication.default_create_token'
REST_SESSION_LOGIN = True
REST_SCHEMA_BASE_URL = CLOUDLAUNCH_PATH_PREFIX + '/cloudlaunch/'
SENTRY_DSN = os.environ.get('SENTRY_DSN', '')
sentry_sdk.init(
# dsn="https://<key>@sentry.io/<project>",
dsn=SENTRY_DSN,
integrations=[DjangoIntegration()]
)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(asctime)s %(levelname)s %(pathname)s:%(lineno)d - %(message)s'
},
},
'filters': {
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
},
},
'handlers': {
'console': {
'filters': ['require_debug_true'],
'class': 'logging.StreamHandler',
'formatter': 'verbose',
'level': 'DEBUG',
},
'file-cloudlaunch': {
'class': 'logging.FileHandler',
'formatter': 'verbose',
'level': 'INFO',
'filename': 'cloudlaunch.log',
},
'file-django': {
'class': 'logging.FileHandler',
'formatter': 'verbose',
'level': 'WARNING',
'filename': 'cloudlaunch-django.log',
}
},
'loggers': {
'django': {
'handlers': ['console', 'file-django'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
},
'django.db.backends': {
'handlers': ['file-django'],
'level': 'INFO',
},
'django.template': {
'handlers': ['console', 'file-django'],
'level': 'INFO',
'propagate': True,
},
'django.server': {
'handlers': ['console', 'file-django'],
'level': 'ERROR',
'propagate': True,
},
'cloudlaunch': {
'handlers': ['console', 'file-cloudlaunch'],
'level': 'DEBUG',
'propagate': False
}
}
}
# CloudLaunch specific settings
CLOUDLAUNCH_APP_REGISTRY_URL = 'https://raw.githubusercontent.com/galaxyproject/' \
'cloudlaunch-registry/master/app-registry.yaml'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'
# Allow settings to be overridden in a cloudlaunch/settings_local.py
try:
from cloudlaunchserver.settings_local import * # noqa
except ImportError:
pass