4c6b08907869be90cebcdef66f20d1287a0e2190
[multicloud/framework.git] / multivimbroker / multivimbroker / settings.py
1 # Copyright (c) 2017 Wind River Systems, Inc.
2 # Copyright (c) 2017-2018 VMware, Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
13 import os
14 import sys
15
16 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18
19 # Quick-start development settings - unsuitable for production
20 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
21
22 # SECURITY WARNING: keep the secret key used in production secret!
23 SECRET_KEY = '3o-wney!99y)^h3v)0$j16l9=fdjxcb+a8g+q3tfbahcnu2b0o'
24
25 # SECURITY WARNING: don't run with debug turned on in production!
26 DEBUG = True
27
28 ALLOWED_HOSTS = []
29
30 # Application definition
31
32 INSTALLED_APPS = [
33     'django.contrib.auth',
34     'django.contrib.contenttypes',
35     'django.contrib.sessions',
36     'django.contrib.messages',
37     'django.contrib.staticfiles',
38     'rest_framework',
39     'multivimbroker.pub.database',
40 ]
41
42 MIDDLEWARE_CLASSES = [
43     'django.middleware.security.SecurityMiddleware',
44     'django.contrib.sessions.middleware.SessionMiddleware',
45     'django.middleware.common.CommonMiddleware',
46     'django.middleware.csrf.CsrfViewMiddleware',
47     'django.contrib.auth.middleware.AuthenticationMiddleware',
48     'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
49     'django.contrib.messages.middleware.MessageMiddleware',
50     'django.middleware.clickjacking.XFrameOptionsMiddleware',
51 ]
52
53 ROOT_URLCONF = 'multivimbroker.urls'
54
55 WSGI_APPLICATION = 'multivimbroker.wsgi.application'
56
57 REST_FRAMEWORK = {
58     'DEFAULT_RENDERER_CLASSES': (
59         'rest_framework.renderers.JSONRenderer',
60     ),
61
62     'DEFAULT_PARSER_CLASSES': (
63         'rest_framework.parsers.JSONParser',
64         'rest_framework.parsers.MultiPartParser',
65         # 'rest_framework.parsers.FormParser',
66         # 'rest_framework.parsers.FileUploadParser',
67     )
68 }
69
70 DATABASES = {
71     'default': {
72         'ENGINE': 'django.db.backends.sqlite3',
73         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
74     }
75 }
76
77 # CACHE_BACKEND = 'redis_cache.cache://%s@%s:%s' %
78 # (REDIS_PASSWD, REDIS_HOST, REDIS_PORT)
79
80 TIME_ZONE = 'UTC'
81
82 # Static files (CSS, JavaScript, Images)
83 # https://docs.djangoproject.com/en/1.6/howto/static-files/
84
85 STATIC_URL = '/static/'
86
87 LOGGING = {
88     'version': 1,
89     'disable_existing_loggers': True,
90     'formatters': {
91         'standard': {
92             'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] \
93             [%(levelname)s]:%(message)s',
94         },
95     },
96     'filters': {
97     },
98     'handlers': {
99         'multivimbroker_handler': {
100             'level': 'DEBUG',
101             'class': 'logging.handlers.RotatingFileHandler',
102             'filename': os.path.join(BASE_DIR,
103                                      'logs/runtime_multivimbroker.log'),
104             'formatter': 'standard',
105             'maxBytes': 1024 * 1024 * 50,
106             'backupCount': 5,
107         },
108     },
109
110     'loggers': {
111         'multivimbroker': {
112             'handlers': ['multivimbroker_handler'],
113             'level': 'DEBUG',
114             'propagate': False
115         },
116     }
117 }
118
119 if 'test' in sys.argv:
120     from multivimbroker.pub.config import config
121     config.REG_TO_MSB_WHEN_START = False
122     DATABASES = {}
123     DATABASES['default'] = {
124         'ENGINE': 'django.db.backends.sqlite3',
125         'NAME': ':memory:',
126     }
127     REST_FRAMEWORK = {}
128     import platform
129
130     if platform.system() == 'Linux':
131         TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'
132         TEST_OUTPUT_VERBOSE = True
133         TEST_OUTPUT_DESCRIPTIONS = True
134         TEST_OUTPUT_DIR = 'test-reports'