From 37d5aad49446adbd37519c27ce95bd65580f267d Mon Sep 17 00:00:00 2001 From: Ken Raffenetti Date: Mon, 27 Nov 2006 17:11:51 +0000 Subject: settings file now reads from bcfg2.conf git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2550 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Hostbase/settings.py | 39 ++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/lib/Server/Hostbase') diff --git a/src/lib/Server/Hostbase/settings.py b/src/lib/Server/Hostbase/settings.py index 22b755b21..50b1ae594 100644 --- a/src/lib/Server/Hostbase/settings.py +++ b/src/lib/Server/Hostbase/settings.py @@ -1,3 +1,21 @@ +from ConfigParser import ConfigParser, NoSectionError, NoOptionError +c = ConfigParser() +#This needs to be configurable one day somehow +c.read(['/etc/bcfg2.conf']) + +defaults = {'database_engine':'', + 'database_name':'', + 'database_user':'', + 'database_password':'', + 'database_host':'', + 'database_port':3306, + } + +if c.has_section('hostbase'): + options = dict(c.items('hostbase')) +else: + options = defaults + # Django settings for Hostbase project. DEBUG = True TEMPLATE_DEBUG = DEBUG @@ -7,36 +25,35 @@ ADMINS = ( MANAGERS = ADMINS # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. -DATABASE_ENGINE = '' +DATABASE_ENGINE = options['database_engine'] # Or path to database file if using sqlite3. -DATABASE_NAME = '' +DATABASE_NAME = options['database_name'] # Not used with sqlite3. -DATABASE_USER = '' +DATABASE_USER = options['database_user'] # Not used with sqlite3. -DATABASE_PASSWORD = '' +DATABASE_PASSWORD = options['database_password'] # Set to empty string for localhost. Not used with sqlite3. -DATABASE_HOST = '' +DATABASE_HOST = options['database_host'] # Set to empty string for default. Not used with sqlite3. -DATABASE_PORT = '' +DATABASE_PORT = int(options['database_port']) # Local time zone for this installation. All choices can be found here: # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE TIME_ZONE = '' # enter the defauly MX record machines will get in Hostbase # this setting may move elsewhere eventually -DEFAULT_MX = 'mailserver.somewhere.com' -PRIORITY = 30 +DEFAULT_MX = options['default_mx'] +PRIORITY = int(option['priority']) SESSION_EXPIRE_AT_BROWSER_CLOSE = True # Uncomment a backend below if you would like to use it for authentication AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', - #'Hostbase.backends.NISBackend', + 'Hostbase.backends.NISBackend', #'Hostbase.backends.LDAPBacken', ) - # enter an NIS group name you'd like to give access to edit hostbase records -AUTHORIZED_GROUP = '' +AUTHORIZED_GROUP = options['authorized_group'] #create login url area: import django.contrib.auth -- cgit v1.2.3-1-g7c22