X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=dashboard%2Fsrc%2Fpharos_dashboard%2Fsettings.py;h=793eec74fa8408390534d6a108bc721a714f05e3;hb=8c14ce442ff11f024c0d7318120dad71e7e91215;hp=240f68e83283db4e1bca71434489f5d5b8d40a01;hpb=37fa445afe6d63d44a3a52c2a89e4e21ae67b5a6;p=pharos-tools.git diff --git a/dashboard/src/pharos_dashboard/settings.py b/dashboard/src/pharos_dashboard/settings.py index 240f68e..793eec7 100644 --- a/dashboard/src/pharos_dashboard/settings.py +++ b/dashboard/src/pharos_dashboard/settings.py @@ -1,3 +1,11 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## import os from datetime import timedelta @@ -5,16 +13,21 @@ from datetime import timedelta BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +# NOTE: os.environ only returns strings, so making a comparison to +# 'True' here will convert it to the correct Boolean value. +DEBUG = os.environ['DEBUG'] == 'True' +TESTING = os.environ['TEST'] == 'True' # Application definition INSTALLED_APPS = [ 'dashboard', + 'resource_inventory', 'booking', 'account', - 'jenkins', 'notifier', + 'workflow', + 'api', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -44,11 +57,11 @@ ROOT_URLCONF = 'pharos_dashboard.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')] - , + 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ + 'dashboard.context_processors.debug', 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', @@ -58,6 +71,10 @@ TEMPLATES = [ }, ] +TEMPLATE_CONTEXT_PROCESSORS = [ + 'dashboard.context_processors.debug', +] + WSGI_APPLICATION = 'pharos_dashboard.wsgi.application' # Password validation @@ -126,13 +143,12 @@ DATABASES = { } } - # Rest API Settings REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' ], - 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',), + 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.FilterSet',), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.TokenAuthentication', @@ -163,34 +179,27 @@ OAUTH_CALLBACK_URL = os.environ['DASHBOARD_URL'] + '/accounts/authenticated' CELERY_TIMEZONE = 'UTC' RABBITMQ_URL = 'rabbitmq' -RABBITMQ_USER = os.environ['RABBITMQ_USER'] -RABBITMQ_PASSWORD = os.environ['RABBITMQ_PASSWORD'] +RABBITMQ_DEFAULT_USER = os.environ['RABBITMQ_DEFAULT_USER'] +RABBITMQ_DEFAULT_PASS = os.environ['RABBITMQ_DEFAULT_PASS'] -BROKER_URL = 'amqp://' + RABBITMQ_USER + ':' + RABBITMQ_PASSWORD + '@rabbitmq:5672//' +BROKER_URL = 'amqp://' + RABBITMQ_DEFAULT_USER + ':' + RABBITMQ_DEFAULT_PASS + '@rabbitmq:5672//' CELERYBEAT_SCHEDULE = { - 'sync-jenkins': { - 'task': 'jenkins.tasks.sync_jenkins', - 'schedule': timedelta(minutes=5) - }, - 'send-booking-notifications': { - 'task': 'notification.tasks.send_booking_notifications', - 'schedule': timedelta(minutes=5) + 'booking_poll': { + 'task': 'dashboard.tasks.booking_poll', + 'schedule': timedelta(minutes=1) }, - 'clean-database': { - 'task': 'dashboard.tasks.database_cleanup', - 'schedule': timedelta(hours=24) + 'free_hosts': { + 'task': 'dashboard.tasks.free_hosts', + 'schedule': timedelta(minutes=1) }, } -# Jenkins Settings -ALL_SLAVES_URL = os.environ['JENKINS_URL'] + '/computer/api/json?tree=computer[displayName,offline,idle]' -CI_SLAVES_URL = os.environ['JENKINS_URL'] + '/label/ci-pod/api/json?tree=nodes[nodeName,offline,idle]' -ALL_JOBS_URL = os.environ['JENKINS_URL'] + '/api/json?tree=jobs[displayName,url,lastBuild[fullDisplayName,building,builtOn,timestamp,result]' -GET_SLAVE_URL = os.environ['JENKINS_URL'] + '/computer/' # Notifier Settings EMAIL_HOST = os.environ['EMAIL_HOST'] EMAIL_PORT = os.environ['EMAIL_PORT'] EMAIL_HOST_USER = os.environ['EMAIL_HOST_USER'] EMAIL_HOST_PASSWORD = os.environ['EMAIL_HOST_PASSWORD'] -EMAIL_USE_TLS=True +EMAIL_USE_TLS = True +DEFAULT_EMAIL_FROM = os.environ.get('DEFAULT_EMAIL_FROM', 'webmaster@localhost') +SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"