summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAndrew Brestick <brestick@mcs.anl.gov>2008-07-15 16:23:17 +0000
committerAndrew Brestick <brestick@mcs.anl.gov>2008-07-15 16:23:17 +0000
commitbc0f8dead7dd4e98643ee7bd3a1a50011d8c29a9 (patch)
tree0643d087e3c4a8b8f3209f68c3c56033cac42cd6 /src/lib
parentdd36afc992b78d4b03b8a2c8a0ba50cfbacc5662 (diff)
downloadbcfg2-bc0f8dead7dd4e98643ee7bd3a1a50011d8c29a9.tar.gz
bcfg2-bc0f8dead7dd4e98643ee7bd3a1a50011d8c29a9.tar.bz2
bcfg2-bc0f8dead7dd4e98643ee7bd3a1a50011d8c29a9.zip
added support for alternate metadata plugin (BB plugin)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4792 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Core.py50
-rw-r--r--src/lib/Server/Plugins/Metadata.py7
-rw-r--r--src/lib/Server/Plugins/__init__.py2
3 files changed, 34 insertions, 25 deletions
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py
index b3742e8d3..2bbbbc4f4 100644
--- a/src/lib/Server/Core.py
+++ b/src/lib/Server/Core.py
@@ -225,25 +225,11 @@ class Core(object):
self.stats = Statistics("%s/etc/statistics.xml" % (self.datastore))
[data.remove('') for data in [structures, generators] if '' in data]
-
- for plugin in structures + generators + ['Metadata']:
- if not self.plugins.has_key(plugin):
- try:
- mod = getattr(__import__("Bcfg2.Server.Plugins.%s" %
- (plugin)).Server.Plugins, plugin)
- except ImportError, e:
- logger.error("Failed to load plugin %s: %s" % (plugin, e))
- continue
- plug = getattr(mod, plugin)
- if plug.experimental:
- logger.info("Loading experimental plugin %s" % (plugin))
- logger.info("NOTE: Interface subject to change")
- try:
- self.plugins[plugin] = plug(self, self.datastore)
- except PluginInitError:
- logger.error("Failed to instantiate plugin %s" % (plugin))
- except:
- logger.error("Unexpected instantiation failure for plugin %s" % (plugin), exc_info=1)
+
+
+ for plugin in structures + generators:
+ if not self.plugins.has_key(plugin):
+ self.init_plugins(plugin)
plugins = self.plugins.values()
while True:
@@ -252,7 +238,10 @@ class Core(object):
self.metadata = plugin
break
if not plugins:
- raise CoreInitError, "No Metadata plugin loaded"
+ self.init_plugins("Metadata")
+ self.metadata = self.plugins["Metadata"]
+ break
+
for plug_names, plug_tname, plug_type, collection in \
[(structures, 'structure', Bcfg2.Server.Plugin.StructurePlugin,
self.structures),
@@ -269,7 +258,26 @@ class Core(object):
else:
logger.error("Plugin %s not loaded. Not enabled as a %s" \
% (plugin, plug_tname))
-
+
+ def init_plugins(self, plugin):
+ try:
+ mod = getattr(__import__("Bcfg2.Server.Plugins.%s" %
+ (plugin)).Server.Plugins, plugin)
+ except ImportError, e:
+ logger.error("Failed to load plugin %s: %s" % (plugin, e))
+ return
+ plug = getattr(mod, plugin)
+ if plug.experimental:
+ logger.info("Loading experimental plugin %s" % (plugin))
+ logger.info("NOTE: Interface subject to change")
+ try:
+ self.plugins[plugin] = plug(self, self.datastore)
+ except PluginInitError:
+ logger.error("Failed to instantiate plugin %s" % (plugin))
+ except:
+ logger.error("Unexpected instantiation failure for plugin %s" %
+ (plugin), exc_info=1)
+
def GetStructures(self, metadata):
'''Get all structures for client specified by metadata'''
return reduce(lambda x, y:x+y,
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index 3a2c48528..75b80459f 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -82,12 +82,13 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
__author__ = 'bcfg-dev@mcs.anl.gov'
__name__ = "Metadata"
- def __init__(self, core, datastore):
+ def __init__(self, core, datastore, watch_clients=True):
Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
- self.__name__ = 'Metadata'
+ #self.__name__ = 'Metadata'
try:
core.fam.AddMonitor("%s/%s" % (self.data, "groups.xml"), self)
- core.fam.AddMonitor("%s/%s" % (self.data, "clients.xml"), self)
+ if watch_clients:
+ core.fam.AddMonitor("%s/%s" % (self.data, "clients.xml"), self)
except:
raise Bcfg2.Server.Plugin.PluginInitError
self.states = {'groups.xml':False, 'clients.xml':False}
diff --git a/src/lib/Server/Plugins/__init__.py b/src/lib/Server/Plugins/__init__.py
index db17e5c26..6d5173fe5 100644
--- a/src/lib/Server/Plugins/__init__.py
+++ b/src/lib/Server/Plugins/__init__.py
@@ -1,6 +1,6 @@
'''imports for Bcfg2.Server.Plugins'''
__revision__ = '$Revision$'
-__all__ = ['Account', 'Base', 'Bundler', 'Cfg', 'Hostbase', 'Metadata',
+__all__ = ['Account', 'Base', 'BB', 'Bundler', 'Cfg', 'Hostbase', 'Metadata',
'Pkgmgr', 'Rules', 'SSHbase', 'Svcmgr', 'TCheetah',
'SGenshi', 'TGenshi', 'Vhost']