summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/models.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-16 13:28:06 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-17 09:25:45 -0500
commitebe7542db7217c2fac3d7111e80f94caedfb69e2 (patch)
tree964db7ae511795d80b3ae50f3e14bc9f3344756a /src/lib/Bcfg2/Server/models.py
parentae58c24f72a8ed72327fbc3f7305bd69ec6a13db (diff)
downloadbcfg2-ebe7542db7217c2fac3d7111e80f94caedfb69e2.tar.gz
bcfg2-ebe7542db7217c2fac3d7111e80f94caedfb69e2.tar.bz2
bcfg2-ebe7542db7217c2fac3d7111e80f94caedfb69e2.zip
added module-level OptionParser to avoid passing it as an argument or global all over
Diffstat (limited to 'src/lib/Bcfg2/Server/models.py')
-rw-r--r--src/lib/Bcfg2/Server/models.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lib/Bcfg2/Server/models.py b/src/lib/Bcfg2/Server/models.py
index 0328c6bea..4ac2be43b 100644
--- a/src/lib/Bcfg2/Server/models.py
+++ b/src/lib/Bcfg2/Server/models.py
@@ -1,6 +1,7 @@
""" Django database models for all plugins """
import sys
+import copy
import logging
import Bcfg2.Options
import Bcfg2.Server.Plugins
@@ -19,14 +20,12 @@ def load_models(plugins=None, cfile='/etc/bcfg2.conf', quiet=True):
# we want to provide a different default plugin list --
# namely, _all_ plugins, so that the database is guaranteed to
# work, even if /etc/bcfg2.conf isn't set up properly
- plugin_opt = Bcfg2.Options.SERVER_PLUGINS
+ plugin_opt = copy.deepcopy(Bcfg2.Options.SERVER_PLUGINS)
plugin_opt.default = Bcfg2.Server.Plugins.__all__
-
- setup = \
- Bcfg2.Options.OptionParser(dict(plugins=plugin_opt,
- configfile=Bcfg2.Options.CFILE),
- quiet=quiet)
- setup.parse([Bcfg2.Options.CFILE.cmd, cfile])
+ setup = Bcfg2.Options.get_option_parser()
+ setup.add_option("plugins", plugin_opt)
+ setup.add_option("configfile", Bcfg2.Options.CFILE)
+ setup.reparse(argv=[Bcfg2.Options.CFILE.cmd, cfile])
plugins = setup['plugins']
if MODELS: