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