Implements NBIs of multivimbroker
[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' % (REDIS_PASSWD, REDIS_HOST, REDIS_PORT)
77
78 TIME_ZONE = 'UTC'
79
80 # Static files (CSS, JavaScript, Images)
81 # https://docs.djangoproject.com/en/1.6/howto/static-files/
82
83 STATIC_URL = '/static/'
84
85 LOGGING = {
86     'version': 1,
87     'disable_existing_loggers': True,
88     'formatters': {
89         'standard': {
90             'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s',
91         },
92     },
93     'filters': {
94     },
95     'handlers': {
96         'multivimbroker_handler': {
97             'level': 'DEBUG',
98             'class': 'logging.handlers.RotatingFileHandler',
99             'filename': os.path.join(BASE_DIR, 'logs/runtime_multivimbroker.log'),
100             'formatter': 'standard',
101             'maxBytes': 1024 * 1024 * 50,
102             'backupCount': 5,
103         },
104     },
105
106     'loggers': {
107         'multivimbroker': {
108             'handlers': ['multivimbroker_handler'],
109             'level': 'DEBUG',
110             'propagate': False
111         },
112     }
113 }
114
115 if 'test' in sys.argv:
116     from multivimbroker.pub.config import config
117     config.REG_TO_MSB_WHEN_START = False
118     DATABASES = {}
119     DATABASES['default'] = {
120         'ENGINE': 'django.db.backends.sqlite3',
121         'NAME': ':memory:',
122     }
123     REST_FRAMEWORK = {}
124     import platform
125
126     if platform.system() == 'Linux':
127         TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'
128         TEST_OUTPUT_VERBOSE = True
129         TEST_OUTPUT_DESCRIPTIONS = True
130         TEST_OUTPUT_DIR = 'test-reports'