summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-06-25 14:36:33 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-06-25 14:36:33 -0400
commit94788714a2867ebc2fcc5b80ba8a0939dcb9aa48 (patch)
tree33517e12a58c85aac619a81a89b240927321c702 /src/lib/Bcfg2/Server/Plugins
parente93478e013d1cda7f77771f622f5c99ac0199979 (diff)
downloadbcfg2-94788714a2867ebc2fcc5b80ba8a0939dcb9aa48.tar.gz
bcfg2-94788714a2867ebc2fcc5b80ba8a0939dcb9aa48.tar.bz2
bcfg2-94788714a2867ebc2fcc5b80ba8a0939dcb9aa48.zip
unified [Single]XMLFileBacked, enabled xinclude pretty much everywhere
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Bundler.py5
-rw-r--r--src/lib/Bcfg2/Server/Plugins/FileProbes.py14
-rw-r--r--src/lib/Bcfg2/Server/Plugins/GroupPatterns.py13
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Metadata.py9
-rw-r--r--src/lib/Bcfg2/Server/Plugins/NagiosGen.py17
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py13
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Properties.py3
-rw-r--r--src/lib/Bcfg2/Server/Plugins/PuppetENC.py3
8 files changed, 26 insertions, 51 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Bundler.py b/src/lib/Bcfg2/Server/Plugins/Bundler.py
index 6289439c6..a7b5dccde 100644
--- a/src/lib/Bcfg2/Server/Plugins/Bundler.py
+++ b/src/lib/Bcfg2/Server/Plugins/Bundler.py
@@ -19,7 +19,6 @@ except:
class BundleFile(Bcfg2.Server.Plugin.StructFile):
-
def get_xml_value(self, metadata):
bundlename = os.path.splitext(os.path.basename(self.name))[0]
bundle = lxml.etree.Element('Bundle', name=bundlename)
@@ -50,7 +49,7 @@ class Bundler(Bcfg2.Server.Plugin.Plugin,
self.logger.error("Failed to load Bundle repository")
raise Bcfg2.Server.Plugin.PluginInitError
- def template_dispatch(self, name):
+ def template_dispatch(self, name, _):
bundle = lxml.etree.parse(name,
parser=Bcfg2.Server.XMLParser)
nsmap = bundle.getroot().nsmap
@@ -63,7 +62,7 @@ class Bundler(Bcfg2.Server.Plugin.Plugin,
else:
raise Bcfg2.Server.Plugin.PluginExecutionError("Genshi not available: %s" % name)
else:
- return BundleFile(name)
+ return BundleFile(name, self.fam)
def BuildStructures(self, metadata):
"""Build all structures for client (metadata)."""
diff --git a/src/lib/Bcfg2/Server/Plugins/FileProbes.py b/src/lib/Bcfg2/Server/Plugins/FileProbes.py
index 556965fca..f95c05d42 100644
--- a/src/lib/Bcfg2/Server/Plugins/FileProbes.py
+++ b/src/lib/Bcfg2/Server/Plugins/FileProbes.py
@@ -37,14 +37,6 @@ data.text = binascii.b2a_base64(open(path).read())
print lxml.etree.tostring(data)
"""
-class FileProbesConfig(Bcfg2.Server.Plugin.SingleXMLFileBacked,
- Bcfg2.Server.Plugin.StructFile):
- """ Config file handler for FileProbes """
- def __init__(self, filename, fam):
- Bcfg2.Server.Plugin.SingleXMLFileBacked.__init__(self, filename, fam)
- Bcfg2.Server.Plugin.StructFile.__init__(self, filename)
-
-
class FileProbes(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.Probing):
""" This module allows you to probe a client for a file, which is then
@@ -60,8 +52,10 @@ class FileProbes(Bcfg2.Server.Plugin.Plugin,
def __init__(self, core, datastore):
Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
Bcfg2.Server.Plugin.Probing.__init__(self)
- self.config = FileProbesConfig(os.path.join(self.data, 'config.xml'),
- core.fam)
+ self.config = Bcfg2.Server.Plugin.StructFile(os.path.join(self.data,
+ 'config.xml'),
+ fam=core.fam,
+ should_monitor=True)
self.entries = dict()
self.probes = dict()
diff --git a/src/lib/Bcfg2/Server/Plugins/GroupPatterns.py b/src/lib/Bcfg2/Server/Plugins/GroupPatterns.py
index e883143ec..bea3baee3 100644
--- a/src/lib/Bcfg2/Server/Plugins/GroupPatterns.py
+++ b/src/lib/Bcfg2/Server/Plugins/GroupPatterns.py
@@ -73,16 +73,17 @@ class PatternMap(object):
return ret
-class PatternFile(Bcfg2.Server.Plugin.SingleXMLFileBacked):
+class PatternFile(Bcfg2.Server.Plugin.XMLFileBacked):
__identifier__ = None
- def __init__(self, filename, fam):
- Bcfg2.Server.Plugin.SingleXMLFileBacked.__init__(self, filename, fam)
+ def __init__(self, filename, fam=None):
+ Bcfg2.Server.Plugin.XMLFileBacked.__init__(self, filename, fam=fam,
+ should_monitor=True)
self.patterns = []
self.logger = logging.getLogger(self.__class__.__name__)
def Index(self):
- Bcfg2.Server.Plugin.SingleXMLFileBacked.Index(self)
+ Bcfg2.Server.Plugin.XMLFileBacked.Index(self)
self.patterns = []
for entry in self.xdata.xpath('//GroupPattern'):
try:
@@ -119,8 +120,8 @@ class GroupPatterns(Bcfg2.Server.Plugin.Plugin,
def __init__(self, core, datastore):
Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
Bcfg2.Server.Plugin.Connector.__init__(self)
- self.config = PatternFile(self.data + '/config.xml',
- core.fam)
+ self.config = PatternFile(os.path.join(self.data, 'config.xml'),
+ fam=core.fam)
def get_additional_groups(self, metadata):
return self.config.process_patterns(metadata.hostname)
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py
index 50604f5cb..9786466bc 100644
--- a/src/lib/Bcfg2/Server/Plugins/Metadata.py
+++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py
@@ -35,17 +35,16 @@ class MetadataRuntimeError(Exception):
pass
-class XMLMetadataConfig(Bcfg2.Server.Plugin.SingleXMLFileBacked):
+class XMLMetadataConfig(Bcfg2.Server.Plugin.XMLFileBacked):
"""Handles xml config files and all XInclude statements"""
def __init__(self, metadata, watch_clients, basefile):
- # we tell SingleXMLFileBacked _not_ to add a monitor for this
+ # we tell XMLFileBacked _not_ to add a monitor for this
# file, because the main Metadata plugin has already added
# one. then we immediately set should_monitor to the proper
# value, so that XIinclude'd files get properly watched
fpath = os.path.join(metadata.data, basefile)
- Bcfg2.Server.Plugin.SingleXMLFileBacked.__init__(self, fpath,
- metadata.core.fam,
- should_monitor=False)
+ Bcfg2.Server.Plugin.XMLFileBacked.__init__(self, fpath,
+ fam=metadata.core.fam)
self.should_monitor = watch_clients
self.metadata = metadata
self.fam = metadata.core.fam
diff --git a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
index 4e8b09f30..f2b8336e0 100644
--- a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
+++ b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
@@ -14,25 +14,16 @@ LOGGER = logging.getLogger('Bcfg2.Plugins.NagiosGen')
line_fmt = '\t%-32s %s'
-class NagiosGenConfig(Bcfg2.Server.Plugin.SingleXMLFileBacked,
- Bcfg2.Server.Plugin.StructFile):
+class NagiosGenConfig(Bcfg2.Server.Plugin.StructFile):
def __init__(self, filename, fam):
# create config.xml if missing
if not os.path.exists(filename):
LOGGER.warning("NagiosGen: %s missing. "
"Creating empty one for you." % filename)
- f = open(filename, "w")
- f.write("<NagiosGen></NagiosGen>")
- f.close()
+ open(filename, "w").write("<NagiosGen></NagiosGen>")
- try:
- Bcfg2.Server.Plugin.SingleXMLFileBacked.__init__(self,
- filename,
- fam)
- except OSError:
- LOGGER.error("NagiosGen: Failed to read configuration file: %s" % err)
- raise Bcfg2.Server.Plugin.PluginInitError(msg)
- Bcfg2.Server.Plugin.StructFile.__init__(self, filename)
+ Bcfg2.Server.Plugin.StructFile.__init__(self, filename, fam=fam,
+ should_monitor=True)
class NagiosGen(Bcfg2.Server.Plugin.Plugin,
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py b/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py
index e2af287db..3ca96c0a4 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py
@@ -4,17 +4,15 @@ import lxml.etree
import Bcfg2.Server.Plugin
from Bcfg2.Server.Plugins.Packages.Source import SourceInitError
-class PackagesSources(Bcfg2.Server.Plugin.SingleXMLFileBacked,
- Bcfg2.Server.Plugin.StructFile,
+class PackagesSources(Bcfg2.Server.Plugin.StructFile,
Bcfg2.Server.Plugin.Debuggable):
__identifier__ = None
def __init__(self, filename, cachepath, fam, packages, setup):
Bcfg2.Server.Plugin.Debuggable.__init__(self)
try:
- Bcfg2.Server.Plugin.SingleXMLFileBacked.__init__(self,
- filename,
- fam)
+ Bcfg2.Server.Plugin.StructFile.__init__(self, filename, fam=fam,
+ should_monitor=True)
except OSError:
err = sys.exc_info()[1]
msg = "Packages: Failed to read configuration file: %s" % err
@@ -22,7 +20,6 @@ class PackagesSources(Bcfg2.Server.Plugin.SingleXMLFileBacked,
msg += " Have you created it?"
self.logger.error(msg)
raise Bcfg2.Server.Plugin.PluginInitError(msg)
- Bcfg2.Server.Plugin.StructFile.__init__(self, filename)
self.cachepath = cachepath
self.setup = setup
if not os.path.exists(self.cachepath):
@@ -42,7 +39,7 @@ class PackagesSources(Bcfg2.Server.Plugin.SingleXMLFileBacked,
source.toggle_debug()
def HandleEvent(self, event=None):
- Bcfg2.Server.Plugin.SingleXMLFileBacked.HandleEvent(self, event=event)
+ Bcfg2.Server.Plugin.XMLFileBacked.HandleEvent(self, event=event)
if event and event.filename != self.name:
for fname in self.extras:
fpath = None
@@ -65,7 +62,7 @@ class PackagesSources(Bcfg2.Server.Plugin.SingleXMLFileBacked,
return sorted(list(self.parsed)) == sorted(self.extras)
def Index(self):
- Bcfg2.Server.Plugin.SingleXMLFileBacked.Index(self)
+ Bcfg2.Server.Plugin.XMLFileBacked.Index(self)
self.entries = []
for xsource in self.xdata.findall('.//Source'):
source = self.source_from_xml(xsource)
diff --git a/src/lib/Bcfg2/Server/Plugins/Properties.py b/src/lib/Bcfg2/Server/Plugins/Properties.py
index 6d1c21328..a879b064f 100644
--- a/src/lib/Bcfg2/Server/Plugins/Properties.py
+++ b/src/lib/Bcfg2/Server/Plugins/Properties.py
@@ -26,9 +26,6 @@ def passphrases():
class PropertyFile(Bcfg2.Server.Plugin.StructFile):
"""Class for properties files."""
- def __init__(self, name):
- Bcfg2.Server.Plugin.StructFile.__init__(self, name)
-
def write(self):
""" Write the data in this data structure back to the property
file """
diff --git a/src/lib/Bcfg2/Server/Plugins/PuppetENC.py b/src/lib/Bcfg2/Server/Plugins/PuppetENC.py
index c75c0b076..46182e9a2 100644
--- a/src/lib/Bcfg2/Server/Plugins/PuppetENC.py
+++ b/src/lib/Bcfg2/Server/Plugins/PuppetENC.py
@@ -15,9 +15,6 @@ class PuppetENCFile(Bcfg2.Server.Plugin.FileBacked):
def HandleEvent(self, event=None):
return
- def __str__(self):
- return "%s: %s" % (self.__class__.__name__, self.name)
-
class PuppetENC(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.Connector,