From 8bcd3b7d717186f14bdd2482e46c2a6feee51767 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 17 Aug 2016 17:17:22 +0200 Subject: Revert "removed duplicate plugins option" This reverts commit 30634d07d5489f260f37cc86d150315f02c40865. --- src/lib/Bcfg2/Server/models.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lib/Bcfg2/Server/models.py b/src/lib/Bcfg2/Server/models.py index 9c0153c74..65f17ee7c 100644 --- a/src/lib/Bcfg2/Server/models.py +++ b/src/lib/Bcfg2/Server/models.py @@ -4,20 +4,40 @@ import sys import logging import Bcfg2.Options import Bcfg2.Server.Plugins +from Bcfg2.Compat import walk_packages -LOGGER = logging.getLogger(__name__) +LOGGER = logging.getLogger('Bcfg2.Server.models') MODELS = [] INTERNAL_DATABASE_VERSION = None -class _OptionContainer(object): - """Options for Bcfg2 database models.""" +def _get_all_plugins(): + rv = [] + for submodule in walk_packages(path=Bcfg2.Server.Plugins.__path__, + prefix="Bcfg2.Server.Plugins."): + module = submodule[1].rsplit('.', 1)[-1] + if submodule[1] == "Bcfg2.Server.Plugins.%s" % module: + # we only include direct children of + # Bcfg2.Server.Plugins -- e.g., all_plugins should + # include Bcfg2.Server.Plugins.Cfg, but not + # Bcfg2.Server.Plugins.Cfg.CfgInfoXML + rv.append(module) + return rv + + +_ALL_PLUGINS = _get_all_plugins() + +class _OptionContainer(object): # 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 - options = [Bcfg2.Options.Common.plugins] + options = [ + Bcfg2.Options.Option( + cf=('server', 'plugins'), type=Bcfg2.Options.Types.comma_list, + default=_ALL_PLUGINS, dest="models_plugins", + action=Bcfg2.Options.PluginsAction)] @staticmethod def options_parsed_hook(): @@ -39,7 +59,7 @@ def load_models(plugins=None): global MODELS if not plugins: - plugins = Bcfg2.Options.setup.plugins + plugins = Bcfg2.Options.setup.models_plugins if MODELS: # load_models() has been called once, so first unload all of -- cgit v1.2.3-1-g7c22