Commit fec9dfac authored by Rémi Duraffort's avatar Rémi Duraffort Committed by Neil Williams

settings: simplify and allow setting any variables

Every variable that is defined in the settings.conf json file will be added
to the distro settings.
Allows admins to set existing django variables without having to modify LAVA
code.

Change-Id: I2040db9ed29d459fe650b12afffe43e72e939db5
parent 66cd46bd
......@@ -31,10 +31,9 @@ import yaml
from collections import OrderedDict
from django.contrib.sites.models import Site
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from lava_server.settings.getsettings import Settings
from lava_scheduler_app.schema import SubmissionException
DEFAULT_IRC_SERVER = "irc.freenode.net"
......@@ -386,12 +385,11 @@ def get_ldap_user_properties(ldap_user):
If given ldap_user does not exist, then raise ldap.NO_SUCH_OBJECT
"""
settings = Settings("lava-server")
server_uri = settings.get_setting("AUTH_LDAP_SERVER_URI", None)
bind_dn = settings.get_setting("AUTH_LDAP_BIND_DN", None)
bind_password = settings.get_setting("AUTH_LDAP_BIND_PASSWORD", None)
user_dn_template = settings.get_setting("AUTH_LDAP_USER_DN_TEMPLATE", None)
user_search = settings.get_setting("AUTH_LDAP_USER_SEARCH", None)
server_uri = settings.AUTH_LDAP_SERVER_URI
bind_dn = settings.AUTH_LDAP_BIND_DN
bind_password = settings.AUTH_LDAP_BIND_PASSWORD
user_dn_template = settings.AUTH_LDAP_USER_DN_TEMPLATE
user_search = settings.AUTH_LDAP_USER_SEARCH
search_scope = ldap.SCOPE_SUBTREE
# Attributes should be byte strings
......
......@@ -21,8 +21,8 @@ import os
import csv
import ldap
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from lava_server.settings.getsettings import Settings
# It is a very rarely used management command, hence many parameters are
......@@ -65,8 +65,7 @@ class Command(BaseCommand):
if filename is None:
self.stderr.write("filename not specified, writing to stdout.")
settings = Settings("lava-server")
server_uri = settings.get_setting("AUTH_LDAP_SERVER_URI", None)
server_uri = settings.AUTH_LDAP_SERVER_URI
self.stdout.write("Trying to access %s ..." % server_uri)
if LDAP_SERVER_HOST not in server_uri:
raise CommandError("This is a very rarely used management command, "
......@@ -76,8 +75,8 @@ class Command(BaseCommand):
"work with other LDAP systems."
% _get_script_path())
bind_dn = settings.get_setting("AUTH_LDAP_BIND_DN", None)
bind_password = settings.get_setting("AUTH_LDAP_BIND_PASSWORD", None)
bind_dn = settings.AUTH_LDAP_BIND_DN
bind_password = settings.AUTH_LDAP_BIND_PASSWORD
user_dn = USER_DN
search_scope = SEARCH_SCOPE
......
......@@ -24,8 +24,16 @@ import imp
from lava_scheduler_app.settings import *
# List of people who get code error notifications
# https://docs.djangoproject.com/en/1.8/ref/settings/#admins
ADMINS = [['lava-server Administrator', 'root@localhost']]
# List of people who get broken link notifications
# https://docs.djangoproject.com/en/1.8/ref/settings/#managers
MANAGERS = ADMINS
# Allow only the connection through the reverse proxy
ALLOWED_HOSTS = ['[::1]', '127.0.0.1', 'localhost']
INTERNAL_IPS = []
# Application definition
INSTALLED_APPS = [
......@@ -99,10 +107,27 @@ USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# URL that handles the media served from STATIC_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://static.lawrence.com", "http://example.com/static/"
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = "/static/"
# Absolute filesystem path to the directory that will hold static, read only
# files collected from all applications.
STATIC_ROOT = "/usr/share/lava-server/static"
# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = "/var/lib/lava-server/default/media/"
STATIC_URL = '/static/'
# Absolute filesystem path to the directory that will hold archived files.
ARCHIVE_ROOT = "/var/lib/lava-server/default/archive/"
# LOG_SIZE_LIMIT in megabytes
LOG_SIZE_LIMIT = 25
# Default URL after login
LOGIN_REDIRECT_URL = "/"
# Automatically install some applications
available_modules = list()
......@@ -140,3 +165,37 @@ CSRF_COOKIE_SECURE = True
CSRF_COOKIE_HTTPONLY = True
X_FRAME_OPTIONS = 'DENY'
HTTPS_XML_RPC = True
# Branding support
BRANDING_ALT = "Linaro logo"
BRANDING_ICON = "lava_server/images/logo.png"
BRANDING_URL = "http://www.linaro.org"
BRANDING_HEIGHT = 22
BRANDING_WIDTH = 22
BRANDING_BUG_URL = "static/docs/v2/development-intro.html#report-a-bug"
BRANDING_SOURCE_URL = "https://git.linaro.org/lava"
BRANDING_MESSAGE = ""
# Custom documentation
CUSTOM_DOCS = {}
# Logging
DJANGO_LOGFILE = "/var/log/lava-server/django.log"
# Django debug toolbar
USE_DEBUG_TOOLBAR = False
# Template caching
USE_TEMPLATE_CACHE = False
# LDAP support
AUTH_LDAP_SERVER_URI = None
AUTH_LDAP_BIND_DN = None
AUTH_LDAP_BIND_PASSWORD = None
AUTH_LDAP_USER_DN_TEMPLATE = None
AUTH_LDAP_USER_SEARCH = None
AUTH_LDAP_GROUP_SEARCH = None
AUTH_LDAP_GROUP_TYPE = None
# Debian SSO is of be default
AUTH_DEBIAN_SSO = None
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment