1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
import sys
import django
import Bcfg2.Options
DATABASES = dict()
# Django < 1.2 compat
DATABASE_ENGINE = None
DATABASE_NAME = None
DATABASE_USER = None
DATABASE_PASSWORD = None
DATABASE_HOST = None
DATABASE_PORT = None
def read_config(cfile='/etc/bcfg2.conf', repo=None, quiet=False):
global DATABASE_ENGINE, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, \
DATABASE_HOST, DATABASE_PORT
setup = \
Bcfg2.Options.OptionParser(dict(repo=Bcfg2.Options.SERVER_REPOSITORY,
configfile=Bcfg2.Options.CFILE,
db_engine=Bcfg2.Options.DB_ENGINE,
db_name=Bcfg2.Options.DB_NAME,
db_user=Bcfg2.Options.DB_USER,
db_password=Bcfg2.Options.DB_PASSWORD,
db_host=Bcfg2.Options.DB_HOST,
db_port=Bcfg2.Options.DB_PORT),
quiet=quiet)
setup.parse([Bcfg2.Options.CFILE.cmd, cfile])
if repo is None:
repo = setup['repo']
DATABASES['default'] = \
dict(ENGINE=setup['db_engine'],
NAME=setup['db_name'],
USER=setup['db_user'],
PASSWORD=setup['db_password'],
HOST=setup['db_host'],
PORT=setup['db_port'])
if django.VERSION[0] == 1 and django.VERSION[1] < 2:
DATABASE_ENGINE = setup['db_engine']
DATABASE_NAME = DATABASES['default']['NAME']
DATABASE_USER = DATABASES['default']['USER']
DATABASE_PASSWORD = DATABASES['default']['PASSWORD']
DATABASE_HOST = DATABASES['default']['HOST']
DATABASE_PORT = DATABASES['default']['PORT']
# initialize settings from /etc/bcfg2.conf, or set up basic defaults.
# this lets manage.py work in all cases
read_config(quiet=True)
if django.VERSION[0] == 1 and django.VERSION[1] > 2:
TIME_ZONE = None
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ADMINS = (('Root', 'root'))
MANAGERS = ADMINS
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
INSTALLED_APPS = ('Bcfg2.Server')
|