1 # Copyright 2017 ZTE Corporation.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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 # See the License for the specific language governing permissions and
13 # limitations under the License.
19 from logging import config as log_config
21 from catalog.pub.config import config as pub_config
22 from catalog.pub.config.config import DB_NAME, DB_IP, DB_USER, DB_PASSWD, DB_PORT
24 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
25 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
27 # Quick-start development settings - unsuitable for production
28 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
30 # SECURITY WARNING: keep the secret key used in production secret!
31 SECRET_KEY = '3o-wney!99y)^h3v)0$j16l9=fdjxcb+a8g+q3tfbahcnu2b0o'
33 # SECURITY WARNING: don't run with debug turned on in production!
38 # Application definition
41 'django.contrib.auth',
42 'django.contrib.contenttypes',
43 'django.contrib.sessions',
44 'django.contrib.messages',
45 'django.contrib.staticfiles',
46 'django.contrib.admin',
48 'catalog.pub.database',
54 # TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
57 'LOGIN_URL': '/admin/login',
58 'LOGOUT_URL': '/admin/logout',
59 'DEFAULT_INFO': 'catalog.swagger.urls.swagger_info'
64 'BACKEND': 'django.template.backends.django.DjangoTemplates',
68 'context_processors': [
69 'django.template.context_processors.debug',
70 'django.template.context_processors.request',
71 'django.contrib.auth.context_processors.auth',
72 'django.contrib.messages.context_processors.messages',
79 'django.middleware.security.SecurityMiddleware',
80 'django.contrib.sessions.middleware.SessionMiddleware',
81 'django.middleware.common.CommonMiddleware',
82 'django.middleware.csrf.CsrfViewMiddleware',
83 'django.contrib.auth.middleware.AuthenticationMiddleware',
84 'django.contrib.messages.middleware.MessageMiddleware',
85 'django.middleware.clickjacking.XFrameOptionsMiddleware',
88 ROOT_URLCONF = 'catalog.urls'
90 WSGI_APPLICATION = 'catalog.wsgi.application'
93 'DEFAULT_RENDERER_CLASSES': (
94 'rest_framework.renderers.JSONRenderer',
97 'DEFAULT_PARSER_CLASSES': (
98 'rest_framework.parsers.JSONParser',
99 'rest_framework.parsers.MultiPartParser',
105 'ENGINE': 'django.db.backends.mysql',
110 'PASSWORD': DB_PASSWD,
115 # DATABASES['default'] = {
116 # 'ENGINE': 'django.db.backends.sqlite3',
117 # 'NAME': ':memory:',
120 # catalog.pub.redisco.connection_setup(host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWD, db=0)
121 # CACHE_BACKEND = 'redis_cache.cache://%s@%s:%s' % (REDIS_PASSWD, REDIS_HOST, REDIS_PORT)
125 # Static files (CSS, JavaScript, Images)
126 # https://docs.djangoproject.com/en/1.6/howto/static-files/
128 STATIC_URL = '/static/'
131 os.path.join(BASE_DIR, "static")
134 pub_config.CATALOG_ROOT_PATH = os.path.join(STATICFILES_DIRS[0], "catalog")
135 pub_config.CATALOG_URL_PATH = "static/catalog"
137 if platform.system() == 'Windows' or 'test' in sys.argv:
140 'disable_existing_loggers': True,
143 'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s',
151 'class': 'logging.handlers.RotatingFileHandler',
152 'filename': os.path.join(BASE_DIR, 'logs/runtime_catalog.log'),
153 'formatter': 'standard',
154 'maxBytes': 1024 * 1024 * 50,
159 'class': 'logging.StreamHandler',
160 'formatter': 'standard'
166 'handlers': ['catalog_handler', 'console'],
171 'handlers': ['catalog_handler'],
178 LOGGING_CONFIG = None
179 log_path = '/var/log/onap/modeling/etsicatalog'
180 if not os.path.exists(log_path):
181 os.makedirs(log_path)
183 # yaml configuration of logging
184 LOGGING_FILE = os.path.join(BASE_DIR, 'catalog/log.yml')
185 with open(file=LOGGING_FILE, mode='r', encoding="utf-8")as file:
186 logging_yaml = yaml.load(stream=file, Loader=yaml.FullLoader)
187 log_config.dictConfig(config=logging_yaml)
189 if 'test' in sys.argv:
190 pub_config.REG_TO_MSB_WHEN_START = False
193 DATABASES['default'] = {
194 'ENGINE': 'django.db.backends.sqlite3',
199 if platform.system() == 'Linux':
200 TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'
201 TEST_OUTPUT_VERBOSE = True
202 TEST_OUTPUT_DESCRIPTIONS = True
203 TEST_OUTPUT_DIR = 'test-reports'