summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Server/Admin/__init__.py18
-rw-r--r--src/lib/Server/Core.py67
-rwxr-xr-xsrc/sbin/bcfg2-info15
-rwxr-xr-xsrc/sbin/bcfg2-server6
4 files changed, 32 insertions, 74 deletions
diff --git a/src/lib/Server/Admin/__init__.py b/src/lib/Server/Admin/__init__.py
index fdba06250..aa8169811 100644
--- a/src/lib/Server/Admin/__init__.py
+++ b/src/lib/Server/Admin/__init__.py
@@ -50,25 +50,18 @@ class Mode(object):
return hostent[0]
class MetadataCore(Mode):
- allowed = ['Metadata', 'BB']
'''Base class for admin-modes that handle metadata'''
def __init__(self, configfile, usage):
Mode.__init__(self, configfile)
- options = {'plugins': Bcfg2.Options.SERVER_PLUGINS,
- 'structures': Bcfg2.Options.SERVER_STRUCTURES,
- 'generators': Bcfg2.Options.SERVER_GENERATORS}
+ options = {'plugins': Bcfg2.Options.SERVER_PLUGINS}
setup = Bcfg2.Options.OptionParser(options)
setup.hm = usage
setup.parse(sys.argv[1:])
plugins = [plugin for plugin in setup['plugins']
if plugin in self.allowed]
- structures = [structure for structure in setup['structures']
- if structure in self.allowed]
- generators = [generator for generator in setup['generators']
- if generator in self.allowed]
try:
- self.bcore = Bcfg2.Server.Core.Core(self.get_repo_path(), plugins,
- structures, generators, [],
+ self.bcore = Bcfg2.Server.Core.Core(self.get_repo_path(),
+ setup['plugins'],
'foo', False, 'UTF-8')
except Bcfg2.Server.Core.CoreInitError, msg:
self.errExit("Core load failed because %s" % msg)
@@ -78,7 +71,4 @@ class MetadataCore(Mode):
self.metadata = self.bcore.metadata
class StructureMode(MetadataCore):
- allowed = ['Statistics', 'DBStats']
- def __init__(self, configfile, usage):
- MetadataCore.__init__(self, configfile, usage)
- self.statistics = self.bcore.stats
+ pass
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py
index 6b4df2c35..0961ed23a 100644
--- a/src/lib/Server/Core.py
+++ b/src/lib/Server/Core.py
@@ -6,7 +6,7 @@ from time import time
from Bcfg2.Server.Plugin import PluginInitError, PluginExecutionError
import Bcfg2.Server.FileMonitor
-import logging, lxml.etree, os
+import copy, logging, lxml.etree, os
import Bcfg2.Server.Plugins.Metadata
logger = logging.getLogger('Bcfg2.Core')
@@ -24,8 +24,8 @@ class CoreInitError(Exception):
class Core(object):
'''The Core object is the container for all Bcfg2 Server logic, and modules'''
- def __init__(self, repo, plugins, structures, generators, connectors,
- password, svn, encoding, filemonitor='default'):
+ def __init__(self, repo, plugins, password, svn, encoding,
+ filemonitor='default'):
object.__init__(self)
self.datastore = repo
if filemonitor not in Bcfg2.Server.FileMonitor.available:
@@ -37,9 +37,6 @@ class Core(object):
raise CoreInitError, "failed to instantiate fam driver (used %s)" % \
filemonitor
self.pubspace = {}
- self.generators = []
- self.structures = []
- self.connectors = []
self.cron = {}
self.plugins = {}
self.revision = '-1'
@@ -52,51 +49,29 @@ class Core(object):
except:
self.svn = False
- [data.remove('') for data in [plugins, structures, generators]
- if '' in data]
+ if '' in plugins:
+ plugins.remove('')
- for plugin in structures + generators + plugins + connectors:
+ for plugin in plugins:
if not plugin in self.plugins:
self.init_plugins(plugin)
- chk_plugins = self.plugins.values()
- while True:
- try:
- plugin = chk_plugins.pop()
- if isinstance(plugin, Bcfg2.Server.Plugin.Metadata):
- self.metadata = plugin
- break
- except:
- pass
- if not chk_plugins:
- self.init_plugins("Metadata")
- self.metadata = self.plugins["Metadata"]
- break
-
- for plug_names, plug_tname, plug_type, collection in \
- [(structures, 'structure', Bcfg2.Server.Plugin.Structure,
- self.structures),
- (generators, 'generator', Bcfg2.Server.Plugin.Generator,
- self.generators),
- (connectors, 'connector', Bcfg2.Server.Plugin.Connector,
- self.connectors),
- ]:
- for plugin in plug_names:
- if plugin in self.plugins:
- if not isinstance(self.plugins[plugin], plug_type):
- logger.error("Plugin %s is not a %s plugin; unloading" \
- % (plugin, plug_tname))
- del self.plugins[plugin]
- else:
- collection.append(self.plugins[plugin])
- else:
- logger.error("Plugin %s not loaded. Not enabled as a %s" \
- % (plugin, plug_tname))
-
+ mlist = [p for p in self.plugins.values() if \
+ isinstance(p, Bcfg2.Server.Plugin.Metadata)]
+ if len(mlist) == 1:
+ self.metadata = mlist[0]
+ else:
+ raise CoreInitError, "No Metadata Plugin"
self.statistics = [plugin for plugin in self.plugins.values() \
if isinstance(plugin, Bcfg2.Server.Plugin.Statistics)]
self.pull_sources = [plugin for plugin in self.statistics if \
isinstance(plugin, Bcfg2.Server.Plugin.PullSource)]
+ self.generators = [plugin for plugin in self.plugins.values() if \
+ isinstance(plugin, Bcfg2.Server.Plugin.Generator)]
+ self.structures = [plugin for plugin in self.plugins.values() if \
+ isinstance(plugin, Bcfg2.Server.Plugin.Structure)]
+ self.connectors = [plugin for plugin in self.plugins.values() if \
+ isinstance(plugin, Bcfg2.Server.Plugin.Connector)]
def init_plugins(self, plugin):
try:
@@ -274,11 +249,13 @@ class Core(object):
state = statistics.find(".//Statistics")
if state.get('version') >= '2.0':
for plugin in self.statistics:
+ mc = copy.deepcopy(meta)
+ ms = copy.deepcopy(statistics)
try:
- plugin.process_statistics(meta, statistics)
+ plugin.process_statistics(mc, ms)
except:
logger.error("Plugin %s failed to process stats from %s" \
- % (plugin.name, metadata.hostname),
+ % (plugin.name, mc.hostname),
exc_info=1)
logger.info("Client %s reported state %s" % (client_name,
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index cd868ef0d..a4c3be83b 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -24,12 +24,11 @@ def printTabular(rows):
class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
- def __init__(self, repo, plgs, struct, gens, conn, passwd, svn,
- encoding, event_debug):
+ def __init__(self, repo, plgs, passwd, svn, encoding, event_debug):
cmd.Cmd.__init__(self)
try:
- Bcfg2.Server.Core.Core.__init__(self, repo, plgs, struct, gens,
- conn, passwd, svn, encoding)
+ Bcfg2.Server.Core.Core.__init__(self, repo, plgs, passwd, svn,
+ encoding)
if event_debug:
self.fam.debug = True
except Bcfg2.Server.Core.CoreInitError, msg:
@@ -296,17 +295,13 @@ if __name__ == '__main__':
optinfo.update({'repo': Bcfg2.Options.SERVER_REPOSITORY,
'svn': Bcfg2.Options.SERVER_SVN,
'plugins': Bcfg2.Options.SERVER_PLUGINS,
- 'structures': Bcfg2.Options.SERVER_STRUCTURES,
- 'generators': Bcfg2.Options.SERVER_GENERATORS,
'password': Bcfg2.Options.SERVER_PASSWORD,
'event debug': Bcfg2.Options.DEBUG,
- 'encoding': Bcfg2.Options.ENCODING,
- 'connectors': Bcfg2.Options.SERVER_MCONNECT})
+ 'encoding': Bcfg2.Options.ENCODING})
setup = Bcfg2.Options.OptionParser(optinfo)
setup.parse(sys.argv[1:])
print setup
- loop = infoCore(setup['repo'], setup['plugins'], setup['structures'],
- setup['generators'], setup['connectors'],
+ loop = infoCore(setup['repo'], setup['plugins'],
setup['password'], setup['svn'], setup['encoding'],
'-d' in sys.argv)
if "args" in setup and setup['args']:
diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server
index 5d0b9d6bb..98274be4a 100755
--- a/src/sbin/bcfg2-server
+++ b/src/sbin/bcfg2-server
@@ -33,8 +33,7 @@ class Bcfg2Serv(Bcfg2.Component.Component):
def __init__(self, setup):
try:
- self.Core = Core(setup['repo'], setup['plugins'], setup['structures'],
- setup['generators'], setup['connectors'],
+ self.Core = Core(setup['repo'], setup['plugins'],
setup['password'],
setup['svn'], setup['encoding'], setup['filemonitor'])
except CoreInitError, msg:
@@ -200,8 +199,6 @@ if __name__ == '__main__':
OPTINFO.update({'repo': Bcfg2.Options.SERVER_REPOSITORY,
'svn': Bcfg2.Options.SERVER_SVN,
'plugins': Bcfg2.Options.SERVER_PLUGINS,
- 'structures': Bcfg2.Options.SERVER_STRUCTURES,
- 'generators': Bcfg2.Options.SERVER_GENERATORS,
'password': Bcfg2.Options.SERVER_PASSWORD,
'filemonitor': Bcfg2.Options.SERVER_FILEMONITOR,
})
@@ -211,7 +208,6 @@ if __name__ == '__main__':
'static' : Bcfg2.Options.SERVER_STATIC,
'encoding' : Bcfg2.Options.ENCODING,
'filelog' : Bcfg2.Options.LOGGING_FILE_PATH,
- 'connectors': Bcfg2.Options.SERVER_MCONNECT,
})