diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-07-30 10:24:12 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-07-30 10:24:12 -0400 |
commit | 8b438fda3ae2d9516dbfb6014c280b68036c17e1 (patch) | |
tree | b8acb22b313e4b57797a227b42f69b95b54bd976 /src/lib/Bcfg2/settings.py | |
parent | 7a008a0b1b4d3b819da5a6544ac15faab3cbb28a (diff) | |
download | bcfg2-8b438fda3ae2d9516dbfb6014c280b68036c17e1.tar.gz bcfg2-8b438fda3ae2d9516dbfb6014c280b68036c17e1.tar.bz2 bcfg2-8b438fda3ae2d9516dbfb6014c280b68036c17e1.zip |
Metadata and other improvements:
* Added support for Client tag in groups.xml
* Added support for nested Group tags in groups.xml
* Added support for negated groups in groups.xml
* Added DatabaseBacked plugin mixin to easily allow plugins to connect
to a database specified in global database settings in bcfg2.conf
* Added DBMetadata plugin that uses relational DB to store client
records instead of writing to clients.xml
Diffstat (limited to 'src/lib/Bcfg2/settings.py')
-rw-r--r-- | src/lib/Bcfg2/settings.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/settings.py b/src/lib/Bcfg2/settings.py new file mode 100644 index 000000000..5de590fec --- /dev/null +++ b/src/lib/Bcfg2/settings.py @@ -0,0 +1,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') + |