diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Bcfg2/Options.py | 17 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Admin/Syncdb.py | 7 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Core.py | 3 | ||||
-rw-r--r-- | src/lib/Bcfg2/settings.py | 30 |
4 files changed, 33 insertions, 24 deletions
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py index edebd10b3..3af5885bb 100644 --- a/src/lib/Bcfg2/Options.py +++ b/src/lib/Bcfg2/Options.py @@ -477,6 +477,11 @@ DB_PORT = \ deprecated_cf=('statistics', 'database_port')) # Django options +WEB_CFILE = \ + Option('Web interface configuration file', + default="/etc/bcfg2-web.conf", + cmd='-W', + cf=('statistics', 'config'),) DJANGO_TIME_ZONE = \ Option('Django timezone', default=None, @@ -894,6 +899,7 @@ SERVER_COMMON_OPTIONS = dict(repo=SERVER_REPOSITORY, cert=SERVER_CERT, ca=SERVER_CA, protocol=SERVER_PROTOCOL, + web_configfile=WEB_CFILE, backend=SERVER_BACKEND) CRYPT_OPTIONS = dict(encrypt=ENCRYPT, @@ -969,6 +975,17 @@ CLIENT_COMMON_OPTIONS = \ CLIENT_COMMON_OPTIONS.update(DRIVER_OPTIONS) CLIENT_COMMON_OPTIONS.update(CLI_COMMON_OPTIONS) +DATABASE_COMMON_OPTIONS = dict(web_configfile=WEB_CFILE, + db_engine=DB_ENGINE, + db_name=DB_NAME, + db_user=DB_USER, + db_password=DB_PASSWORD, + db_host=DB_HOST, + db_port=DB_PORT, + time_zone=DJANGO_TIME_ZONE, + django_debug=DJANGO_DEBUG, + web_prefix=DJANGO_WEB_PREFIX) + class OptionParser(OptionSet): """ diff --git a/src/lib/Bcfg2/Server/Admin/Syncdb.py b/src/lib/Bcfg2/Server/Admin/Syncdb.py index 72d3d469e..bff232b05 100644 --- a/src/lib/Bcfg2/Server/Admin/Syncdb.py +++ b/src/lib/Bcfg2/Server/Admin/Syncdb.py @@ -8,12 +8,9 @@ class Syncdb(Bcfg2.Server.Admin.Mode): __shorthelp__ = ("Sync the Django ORM with the configured database") __longhelp__ = __shorthelp__ + "\n\nbcfg2-admin syncdb" __usage__ = "bcfg2-admin syncdb" - options = {'configfile': Bcfg2.Options.CFILE, + options = {'web_configfile': Bcfg2.Options.WEB_CFILE, 'repo': Bcfg2.Options.SERVER_REPOSITORY} - def __init__(self, setup): - Bcfg2.Server.Admin.Mode.__init__(self, setup) - def __call__(self, args): import Bcfg2.Server.Admin Bcfg2.Server.Admin.Mode.__call__(self, args) @@ -26,7 +23,7 @@ class Syncdb(Bcfg2.Server.Admin.Mode): # the syncdb command, but we have to wait to set up the # environment until we've read the config, which has to wait # until we've parsed options. it's a windy, twisting road. - Bcfg2.settings.read_config(cfile=self.opts['configfile'], + Bcfg2.settings.read_config(cfile=self.opts['web_configfile'], repo=self.opts['repo']) setup_environ(Bcfg2.settings) import Bcfg2.Server.models diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index 3cb4854bd..377932614 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -106,7 +106,8 @@ class BaseCore(object): # generate Django ORM settings. this must be done _before_ we # load plugins - Bcfg2.settings.read_config(cfile=self.cfile, repo=self.datastore) + Bcfg2.settings.read_config(cfile=self.setup['web_configfile'], + repo=self.datastore) self._database_available = False # verify our database schema diff --git a/src/lib/Bcfg2/settings.py b/src/lib/Bcfg2/settings.py index ae0cff070..ab71bbae5 100644 --- a/src/lib/Bcfg2/settings.py +++ b/src/lib/Bcfg2/settings.py @@ -1,6 +1,4 @@ -# TODO -# since were merging configs load and warn on deprecated fields - +import os import sys import Bcfg2.Options @@ -27,26 +25,22 @@ TEMPLATE_DEBUG = DEBUG MEDIA_URL = '/site_media' +# default config file is /etc/bcfg2-web.conf, UNLESS /etc/bcfg2.conf +# exists AND /etc/bcfg2-web.conf does not exist. +DEFAULT_CONFIG = Bcfg2.Options.WEB_CFILE.default +if (not os.path.exists(Bcfg2.Options.WEB_CFILE.default) and + os.path.exists(Bcfg2.Options.CFILE.default)): + DEFAULT_CONFIG = Bcfg2.Options.CFILE.default -def read_config(cfile='/etc/bcfg2.conf', repo=None, quiet=False): +def read_config(cfile=DEFAULT_CONFIG, repo=None, quiet=False): global DATABASE_ENGINE, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, \ DATABASE_HOST, DATABASE_PORT, DEBUG, TEMPLATE_DEBUG, TIME_ZONE, \ MEDIA_URL - 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, - time_zone=Bcfg2.Options.DJANGO_TIME_ZONE, - django_debug=Bcfg2.Options.DJANGO_DEBUG, - web_prefix=Bcfg2.Options.DJANGO_WEB_PREFIX), - quiet=quiet) - setup.parse([Bcfg2.Options.CFILE.cmd, '/etc/bcfg2-web.conf', cfile]) + optinfo = Bcfg2.Options.DATABASE_COMMON_OPTIONS + optinfo['repo'] = Bcfg2.Options.SERVER_REPOSITORY + setup = Bcfg2.Options.OptionParser(optinfo, quiet=quiet) + setup.parse([Bcfg2.Options.WEB_CFILE.cmd, cfile]) if repo is None: repo = setup['repo'] |