update link to upper-constraints.txt
[multicloud/framework.git] / multivimbroker / multivimbroker / settings.py
index be887b9..850694e 100644 (file)
@@ -12,9 +12,9 @@
 
 import os
 import sys
-from logging import config
-from onaplogging import monkey
-monkey.patch_all()
+import platform
+import yaml
+from logging import config as log_config
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -26,9 +26,9 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 SECRET_KEY = '3o-wney!99y)^h3v)0$j16l9=fdjxcb+a8g+q3tfbahcnu2b0o'
 
 # SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
+DEBUG = True
 
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = ['*']
 
 # Application definition
 
@@ -70,12 +70,6 @@ REST_FRAMEWORK = {
     )
 }
 
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
-    }
-}
 
 # CACHE_BACKEND = 'redis_cache.cache://%s@%s:%s' %
 # (REDIS_PASSWD, REDIS_HOST, REDIS_PORT)
@@ -87,20 +81,51 @@ TIME_ZONE = 'UTC'
 
 STATIC_URL = '/static/'
 
-
-LOGGING_CONFIG = None
-# yaml configuration of logging
-LOGGING_FILE = os.path.join(BASE_DIR, 'multivimbroker/pub/config/log.yml')
-config.yamlConfig(filepath=LOGGING_FILE, watchDog=True)
-
+if platform.system() == 'Windows' or 'test' in sys.argv:
+    LOGGING = {
+        'version': 1,
+        'disable_existing_loggers': True,
+        'formatters': {
+            'standard': {
+                'format': '%(asctime)s:[%(name)s]:[%(filename)s]'
+                + '-[%(lineno)d] [%(levelname)s]:%(message)s',
+            },
+        },
+        'filters': {
+        },
+        'handlers': {
+            'file_handler': {
+                'level': 'DEBUG',
+                'class': 'logging.handlers.RotatingFileHandler',
+                'filename': os.path.join(BASE_DIR, 'logs/test.log'),
+                'formatter': 'standard',
+                'maxBytes': 1024 * 1024 * 50,
+                'backupCount': 5,
+            },
+        },
+
+        'loggers': {
+            'common': {
+                'handlers': ['file_handler'],
+                'level': 'DEBUG',
+                'propagate': False
+            },
+        }
+    }
+else:
+    log_path = "/var/log/onap/multicloud/multivimbroker"
+    if not os.path.exists(log_path):
+        os.makedirs(log_path)
+
+    LOGGING_CONFIG = None
+    # yaml configuration of logging
+    LOGGING_FILE = os.path.join(BASE_DIR, 'multivimbroker/pub/config/log.yml')
+    with open(file=LOGGING_FILE, mode='r', encoding="utf-8")as file:
+        logging_yaml = yaml.load(stream=file, Loader=yaml.FullLoader)
+    log_config.dictConfig(config=logging_yaml)
 
 if 'test' in sys.argv:
-    from multivimbroker.pub.config import config
-    DATABASES = {}
-    DATABASES['default'] = {
-        'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': ':memory:',
-    }
+    # from multivimbroker.pub.config import config
     REST_FRAMEWORK = {}
     import platform