update link to upper-constraints.txt
[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 import platform
16 import yaml
17 from logging import config as log_config
18
19 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
20 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
21
22 # Quick-start development settings - unsuitable for production
23 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
24
25 # SECURITY WARNING: keep the secret key used in production secret!
26 SECRET_KEY = '3o-wney!99y)^h3v)0$j16l9=fdjxcb+a8g+q3tfbahcnu2b0o'
27
28 # SECURITY WARNING: don't run with debug turned on in production!
29 # DEBUG = True
30
31 ALLOWED_HOSTS = ['*']
32
33 # Application definition
34
35 INSTALLED_APPS = [
36     'django.contrib.auth',
37     'django.contrib.contenttypes',
38     'django.contrib.sessions',
39     'django.contrib.messages',
40     'django.contrib.staticfiles',
41     'rest_framework',
42     'multivimbroker.pub.database',
43 ]
44
45 MIDDLEWARE_CLASSES = [
46     'django.middleware.security.SecurityMiddleware',
47     'django.contrib.sessions.middleware.SessionMiddleware',
48     'django.middleware.common.CommonMiddleware',
49     'django.middleware.csrf.CsrfViewMiddleware',
50     'django.contrib.auth.middleware.AuthenticationMiddleware',
51     'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
52     'django.contrib.messages.middleware.MessageMiddleware',
53     'django.middleware.clickjacking.XFrameOptionsMiddleware',
54 ]
55
56 ROOT_URLCONF = 'multivimbroker.urls'
57
58 WSGI_APPLICATION = 'multivimbroker.wsgi.application'
59
60 REST_FRAMEWORK = {
61     'DEFAULT_RENDERER_CLASSES': (
62         'rest_framework.renderers.JSONRenderer',
63     ),
64
65     'DEFAULT_PARSER_CLASSES': (
66         'rest_framework.parsers.JSONParser',
67         'rest_framework.parsers.MultiPartParser',
68         # 'rest_framework.parsers.FormParser',
69         # 'rest_framework.parsers.FileUploadParser',
70     )
71 }
72
73
74 # CACHE_BACKEND = 'redis_cache.cache://%s@%s:%s' %
75 # (REDIS_PASSWD, REDIS_HOST, REDIS_PORT)
76
77 TIME_ZONE = 'UTC'
78
79 # Static files (CSS, JavaScript, Images)
80 # https://docs.djangoproject.com/en/1.6/howto/static-files/
81
82 STATIC_URL = '/static/'
83
84 if platform.system() == 'Windows' or 'test' in sys.argv:
85     LOGGING = {
86         'version': 1,
87         'disable_existing_loggers': True,
88         'formatters': {
89             'standard': {
90                 'format': '%(asctime)s:[%(name)s]:[%(filename)s]'
91                 + '-[%(lineno)d] [%(levelname)s]:%(message)s',
92             },
93         },
94         'filters': {
95         },
96         'handlers': {
97             'file_handler': {
98                 'level': 'DEBUG',
99                 'class': 'logging.handlers.RotatingFileHandler',
100                 'filename': os.path.join(BASE_DIR, 'logs/test.log'),
101                 'formatter': 'standard',
102                 'maxBytes': 1024 * 1024 * 50,
103                 'backupCount': 5,
104             },
105         },
106
107         'loggers': {
108             'common': {
109                 'handlers': ['file_handler'],
110                 'level': 'DEBUG',
111                 'propagate': False
112             },
113         }
114     }
115 else:
116     log_path = "/var/log/onap/multicloud/multivimbroker"
117     if not os.path.exists(log_path):
118         os.makedirs(log_path)
119
120     LOGGING_CONFIG = None
121     # yaml configuration of logging
122     LOGGING_FILE = os.path.join(BASE_DIR, 'multivimbroker/pub/config/log.yml')
123     with open(file=LOGGING_FILE, mode='r', encoding="utf-8")as file:
124         logging_yaml = yaml.load(stream=file, Loader=yaml.FullLoader)
125     log_config.dictConfig(config=logging_yaml)
126
127 if 'test' in sys.argv:
128     # from multivimbroker.pub.config import config
129     REST_FRAMEWORK = {}
130     import platform
131
132     if platform.system() == 'Linux':
133         TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'
134         TEST_OUTPUT_VERBOSE = True
135         TEST_OUTPUT_DESCRIPTIONS = True
136         TEST_OUTPUT_DIR = 'test-reports'