diff options
author | Tim Laszlo <tim.laszlo@gmail.com> | 2012-05-18 17:17:47 -0500 |
---|---|---|
committer | Tim Laszlo <tim.laszlo@gmail.com> | 2012-05-18 17:17:47 -0500 |
commit | cb35bada0faa9f8fa489fd625a7a7464918fb4c0 (patch) | |
tree | 7c20ecd6c8a1de39f549bc1a0fcc759395904c97 /src/lib/Bcfg2 | |
parent | afeebe721ce4bacf1bfec532816b3cd5d1e2de83 (diff) | |
download | bcfg2-cb35bada0faa9f8fa489fd625a7a7464918fb4c0.tar.gz bcfg2-cb35bada0faa9f8fa489fd625a7a7464918fb4c0.tar.bz2 bcfg2-cb35bada0faa9f8fa489fd625a7a7464918fb4c0.zip |
Reports: Use config file from the command line
If a config file is specified on the command line, use it
in settings.py instead of the hardcoded ones.
Diffstat (limited to 'src/lib/Bcfg2')
-rw-r--r-- | src/lib/Bcfg2/Options.py | 1 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Reports/settings.py | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py index d8a6d4125..129a6c31e 100644 --- a/src/lib/Bcfg2/Options.py +++ b/src/lib/Bcfg2/Options.py @@ -150,6 +150,7 @@ class OptionSet(dict): self.hm = self.buildHelpMessage() if 'configfile' in kwargs: self.cfile = kwargs['configfile'] + os.environ['BCFG2_CONFIG_FILE'] = self.cfile else: self.cfile = DEFAULT_CONFIG_LOCATION self.cfp = DefaultConfigParser() diff --git a/src/lib/Bcfg2/Server/Reports/settings.py b/src/lib/Bcfg2/Server/Reports/settings.py index 26bd5076e..9eb558ac8 100644 --- a/src/lib/Bcfg2/Server/Reports/settings.py +++ b/src/lib/Bcfg2/Server/Reports/settings.py @@ -1,11 +1,16 @@ import django +import os import sys # Compatibility import from Bcfg2.Bcfg2Py3k import ConfigParser # Django settings for bcfg2 reports project. c = ConfigParser.ConfigParser() -if len(c.read(['/etc/bcfg2.conf', '/etc/bcfg2-web.conf'])) == 0: +if 'BCFG2_CONFIG_FILE' in os.environ: + cfiles=os.environ['BCFG2_CONFIG_FILE'] +else: + cfiles=['/etc/bcfg2.conf', '/etc/bcfg2-web.conf'] +if len(c.read(cfiles)) == 0: raise ImportError("Please check that bcfg2.conf or bcfg2-web.conf exists " "and is readable by your web server.") |