summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Server/Core.py7
-rw-r--r--src/lib/Server/Lint/Deltas.py (renamed from src/lib/Bcfg2/Server/Lint/Deltas.py)0
-rw-r--r--src/lib/Server/Plugins/BB.py4
-rw-r--r--src/lib/Server/Plugins/Bundler.py5
-rw-r--r--src/lib/Server/Plugins/FileProbes.py5
-rw-r--r--src/lib/Server/Plugins/Metadata.py25
-rw-r--r--src/lib/Server/Plugins/NagiosGen.py5
-rw-r--r--src/lib/Server/Plugins/Probes.py8
-rw-r--r--src/lib/Server/Plugins/SGenshi.py5
-rw-r--r--src/lib/Server/Plugins/SSLCA.py6
-rw-r--r--src/lib/Server/__init__.py6
11 files changed, 52 insertions, 24 deletions
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py
index 8f02e0a40..9fa42cfd1 100644
--- a/src/lib/Server/Core.py
+++ b/src/lib/Server/Core.py
@@ -17,6 +17,7 @@ except ImportError:
from Bcfg2.Component import Component, exposed
from Bcfg2.Server.Plugin import PluginInitError, PluginExecutionError
+import Bcfg2.Server
import Bcfg2.Server.FileMonitor
import Bcfg2.Server.Plugins.Metadata
# Compatibility imports
@@ -413,7 +414,8 @@ class Core(Component):
# clear dynamic groups
self.metadata.cgroups[meta.hostname] = []
try:
- xpdata = lxml.etree.XML(probedata.encode('utf-8'))
+ xpdata = lxml.etree.XML(probedata.encode('utf-8'),
+ parser=Bcfg2.Server.XMLParser)
except:
self.logger.error("Failed to parse probe data from client %s" % \
(address[0]))
@@ -462,7 +464,8 @@ class Core(Component):
@exposed
def RecvStats(self, address, stats):
"""Act on statistics upload."""
- sdata = lxml.etree.XML(stats.encode('utf-8'))
+ sdata = lxml.etree.XML(stats.encode('utf-8'),
+ parser=Bcfg2.Server.XMLParser)
client = self.metadata.resolve_client(address)
self.process_statistics(client, sdata)
return "<ok/>"
diff --git a/src/lib/Bcfg2/Server/Lint/Deltas.py b/src/lib/Server/Lint/Deltas.py
index cf91d1d13..cf91d1d13 100644
--- a/src/lib/Bcfg2/Server/Lint/Deltas.py
+++ b/src/lib/Server/Lint/Deltas.py
diff --git a/src/lib/Server/Plugins/BB.py b/src/lib/Server/Plugins/BB.py
index 137142b66..0df6be4e8 100644
--- a/src/lib/Server/Plugins/BB.py
+++ b/src/lib/Server/Plugins/BB.py
@@ -1,4 +1,5 @@
import lxml.etree
+import Bcfg2.Server
import Bcfg2.Server.Plugin
import glob
import os
@@ -16,7 +17,8 @@ class BBfile(Bcfg2.Server.Plugin.XMLFileBacked):
"""Build data into an xml object."""
try:
- self.data = lxml.etree.XML(self.data)
+ self.data = lxml.etree.XML(self.data,
+ parser=Bcfg2.Server.XMLParser)
except lxml.etree.XMLSyntaxError:
Bcfg2.Server.Plugin.logger.error("Failed to parse %s" % self.name)
return
diff --git a/src/lib/Server/Plugins/Bundler.py b/src/lib/Server/Plugins/Bundler.py
index a58257712..c795d7f90 100644
--- a/src/lib/Server/Plugins/Bundler.py
+++ b/src/lib/Server/Plugins/Bundler.py
@@ -7,7 +7,7 @@ import os
import os.path
import re
import sys
-
+import Bcfg2.Server
import Bcfg2.Server.Plugin
try:
@@ -53,7 +53,8 @@ class Bundler(Bcfg2.Server.Plugin.Plugin,
raise Bcfg2.Server.Plugin.PluginInitError
def template_dispatch(self, name):
- bundle = lxml.etree.parse(name)
+ bundle = lxml.etree.parse(name,
+ parser=Bcfg2.Server.XMLParser)
nsmap = bundle.getroot().nsmap
if name.endswith('.xml'):
if have_genshi and \
diff --git a/src/lib/Server/Plugins/FileProbes.py b/src/lib/Server/Plugins/FileProbes.py
index c58040b65..2332a1d40 100644
--- a/src/lib/Server/Plugins/FileProbes.py
+++ b/src/lib/Server/Plugins/FileProbes.py
@@ -11,6 +11,7 @@ import errno
import binascii
import lxml.etree
import Bcfg2.Options
+import Bcfg2.Server
import Bcfg2.Server.Plugin
probecode = """#!/usr/bin/env python
@@ -104,7 +105,9 @@ class FileProbes(Bcfg2.Server.Plugin.Plugin,
(data.get('name'), metadata.hostname))
else:
try:
- self.write_data(lxml.etree.XML(data.text), metadata)
+ self.write_data(lxml.etree.XML(data.text,
+ parser=Bcfg2.Server.XMLParser),
+ metadata)
except lxml.etree.XMLSyntaxError:
# if we didn't get XML back from the probe, assume
# it's an error message
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index cc1f78456..4f0ca9686 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -8,11 +8,10 @@ import copy
import fcntl
import lxml.etree
import os
-import os.path
import socket
import sys
import time
-
+import Bcfg2.Server
import Bcfg2.Server.FileMonitor
import Bcfg2.Server.Plugin
@@ -74,7 +73,8 @@ class XMLMetadataConfig(object):
def load_xml(self):
"""Load changes from XML"""
try:
- xdata = lxml.etree.parse("%s/%s" % (self.basedir, self.basefile))
+ xdata = lxml.etree.parse(os.path.join(self.basedir, self.basefile),
+ parser=Bcfg2.Server.XMLParser)
except lxml.etree.XMLSyntaxError:
self.logger.error('Failed to parse %s' % (self.basefile))
return
@@ -146,10 +146,13 @@ class XMLMetadataConfig(object):
"""Try to find the data in included files"""
for included in self.extras:
try:
- xdata = lxml.etree.parse("%s/%s" % (self.basedir, included))
+ xdata = lxml.etree.parse(os.path.join(self.basedir,
+ included),
+ parser=Bcfg2.Server.XMLParser)
cli = xdata.xpath(xpath)
if len(cli) > 0:
- return {'filename': "%s/%s" % (self.basedir, included),
+ return {'filename': os.path.join(self.basedir,
+ included),
'xmltree': xdata,
'xquery': cli}
except lxml.etree.XMLSyntaxError:
@@ -283,7 +286,8 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
def get_groups(self):
'''return groups xml tree'''
- groups_tree = lxml.etree.parse(self.data + "/groups.xml")
+ groups_tree = lxml.etree.parse(self.data + "/groups.xml",
+ parser=Bcfg2.Server.XMLParser)
root = groups_tree.getroot()
return root
@@ -341,7 +345,8 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
def add_bundle(self, bundle_name):
"""Add bundle to groups.xml."""
- tree = lxml.etree.parse(self.data + "/groups.xml")
+ tree = lxml.etree.parse(self.data + "/groups.xml",
+ parser=Bcfg2.Server.XMLParser)
root = tree.getroot()
element = lxml.etree.Element("Bundle", name=bundle_name)
node = self.search_group(bundle_name, tree)
@@ -364,7 +369,8 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
def remove_bundle(self, bundle_name):
"""Remove a bundle."""
- tree = lxml.etree.parse(self.data + "/groups.xml")
+ tree = lxml.etree.parse(self.data + "/groups.xml",
+ parser=Bcfg2.Server.XMLParser)
root = tree.getroot()
node = self.search_group(bundle_name, tree)
if node == None:
@@ -815,7 +821,8 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
def include_group(group):
return not only_client or group in clientmeta.groups
- groups_tree = lxml.etree.parse(self.data + "/groups.xml")
+ groups_tree = lxml.etree.parse(self.data + "/groups.xml",
+ parser=Bcfg2.Server.XMLParser)
try:
groups_tree.xinclude()
except lxml.etree.XIncludeError:
diff --git a/src/lib/Server/Plugins/NagiosGen.py b/src/lib/Server/Plugins/NagiosGen.py
index 8a76c130d..287e1b0d3 100644
--- a/src/lib/Server/Plugins/NagiosGen.py
+++ b/src/lib/Server/Plugins/NagiosGen.py
@@ -7,7 +7,7 @@ import glob
import socket
import logging
import lxml.etree
-
+import Bcfg2.Server
import Bcfg2.Server.Plugin
LOGGER = logging.getLogger('Bcfg2.Plugins.NagiosGen')
@@ -85,7 +85,8 @@ class NagiosGen(Bcfg2.Server.Plugin.Plugin,
LOGGER.warn("Parsing deprecated NagiosGen/parents.xml. "
"Update to the new-style config with "
"nagiosgen-convert.py.")
- parents = lxml.etree.parse(pfile)
+ parents = lxml.etree.parse(pfile,
+ parser=Bcfg2.Server.XMLParser)
for el in parents.xpath("//Depend[@name='%s']" % metadata.hostname):
if 'parent' in xtra:
xtra['parent'] += "," + el.get("on")
diff --git a/src/lib/Server/Plugins/Probes.py b/src/lib/Server/Plugins/Probes.py
index ae1ed4c2b..2c24d6cc4 100644
--- a/src/lib/Server/Plugins/Probes.py
+++ b/src/lib/Server/Plugins/Probes.py
@@ -2,6 +2,8 @@ import time
import lxml.etree
import operator
import re
+import os
+import Bcfg2.Server
try:
import json
@@ -93,7 +95,8 @@ class ProbeData(object):
def xdata(self):
if self._xdata is None:
try:
- self._xdata = lxml.etree.XML(self.data)
+ self._xdata = lxml.etree.XML(self.data,
+ parser=Bcfg2.Server.XMLParser)
except lxml.etree.XMLSyntaxError:
pass
return self._xdata
@@ -221,7 +224,8 @@ class Probes(Bcfg2.Server.Plugin.Plugin,
def load_data(self):
try:
- data = lxml.etree.parse(self.data + '/probed.xml').getroot()
+ data = lxml.etree.parse(os.path.join(self.data, 'probed.xml'),
+ parser=Bcfg2.Server.XMLParser).getroot()
except:
self.logger.error("Failed to read file probed.xml")
return
diff --git a/src/lib/Server/Plugins/SGenshi.py b/src/lib/Server/Plugins/SGenshi.py
index f6a98c141..ae2623d29 100644
--- a/src/lib/Server/Plugins/SGenshi.py
+++ b/src/lib/Server/Plugins/SGenshi.py
@@ -8,7 +8,7 @@ import logging
import copy
import sys
import os.path
-
+import Bcfg2.Server
import Bcfg2.Server.Plugin
import Bcfg2.Server.Plugins.TGenshi
@@ -29,7 +29,8 @@ class SGenshiTemplateFile(Bcfg2.Server.Plugins.TGenshi.TemplateFile,
try:
stream = self.template.generate(metadata=metadata).filter( \
Bcfg2.Server.Plugins.TGenshi.removecomment)
- data = lxml.etree.XML(stream.render('xml', strip_whitespace=False))
+ data = lxml.etree.XML(stream.render('xml', strip_whitespace=False),
+ parser=Bcfg2.Server.XMLParser)
bundlename = os.path.splitext(os.path.basename(self.name))[0]
bundle = lxml.etree.Element('Bundle', name=bundlename)
for item in self.Match(metadata, data):
diff --git a/src/lib/Server/Plugins/SSLCA.py b/src/lib/Server/Plugins/SSLCA.py
index 7b4a08ae1..e5bc38fba 100644
--- a/src/lib/Server/Plugins/SSLCA.py
+++ b/src/lib/Server/Plugins/SSLCA.py
@@ -43,14 +43,16 @@ class SSLCA(Bcfg2.Server.Plugin.GroupSpool):
if event.filename.endswith('.xml'):
if action in ['exists', 'created', 'changed']:
if event.filename.endswith('key.xml'):
- key_spec = dict(list(lxml.etree.parse(epath).find('Key').items()))
+ key_spec = dict(list(lxml.etree.parse(epath,
+ parser=Bcfg2.Server.XMLParser).find('Key').items()))
self.key_specs[ident] = {
'bits': key_spec.get('bits', 2048),
'type': key_spec.get('type', 'rsa')
}
self.Entries['Path'][ident] = self.get_key
elif event.filename.endswith('cert.xml'):
- cert_spec = dict(list(lxml.etree.parse(epath).find('Cert').items()))
+ cert_spec = dict(list(lxml.etree.parse(epath,
+ parser=Bcfg2.Server.XMLParser).find('Cert').items()))
ca = cert_spec.get('ca', 'default')
self.cert_specs[ident] = {
'ca': ca,
diff --git a/src/lib/Server/__init__.py b/src/lib/Server/__init__.py
index 25f397565..bca73ded7 100644
--- a/src/lib/Server/__init__.py
+++ b/src/lib/Server/__init__.py
@@ -1,6 +1,10 @@
# $Id$
"""This is the set of modules for Bcfg2.Server."""
+import lxml.etree
+
__revision__ = '$Revision$'
__all__ = ["Admin", "Core", "FileMonitor", "Plugin", "Plugins",
- "Hostbase", "Reports", "Snapshots"]
+ "Hostbase", "Reports", "Snapshots", "XMLParser"]
+
+XMLParser = lxml.etree.XMLParser(remove_blank_text=True)