summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2011-01-28 12:20:50 -0600
committerTim Laszlo <tim.laszlo@gmail.com>2011-01-28 12:20:50 -0600
commitdd58837acd6240d20d00af9ff89f768cbece0164 (patch)
treedb8b4faf74f7fbd382bb3f5ac98d96b4faec26b6 /src
parente1c429eafbd3ba1b462d75330100684ae26cc1ba (diff)
downloadbcfg2-dd58837acd6240d20d00af9ff89f768cbece0164.tar.gz
bcfg2-dd58837acd6240d20d00af9ff89f768cbece0164.tar.bz2
bcfg2-dd58837acd6240d20d00af9ff89f768cbece0164.zip
Metadata: Handle writes to XInclude files in bootstrap mode
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugins/Metadata.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index 3aeda0952..1ced3f8f3 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -767,12 +767,28 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
try:
self.clientdata_original = lxml.etree.parse(self.data + "/clients.xml")
except Exception, e:
- self.logger.error("Metadata: Failed to relad clients.xml. %s" % e)
+ self.logger.error("Metadata: Failed to read clients.xml. %s" % e)
raise MetadataConsistencyError
cli = self.clientdata_original.xpath('.//Client[@name="%s"]' \
% (client))
- cli[0].set('auth', 'cert')
- self.write_back_clients()
+ if len(cli) > 0:
+ cli[0].set('auth', 'cert')
+ self.write_back_clients()
+ else:
+ """Try to find the client in included files"""
+ for included in self.extra['clients.xml']:
+ try:
+ xdata = lxml.etree.parse("%s/%s" % (self.data, included))
+ cli = xdata.xpath('.//Client[@name="%s"]' % (client))
+ if len(cli) > 0:
+ cli[0].set('auth', 'cert')
+ self.write_back_xml(included, xdata)
+ break
+ except lxml.etree.XMLSyntaxError:
+ self.logger.error('Failed to parse %s' % (included))
+ else:
+ self.logger.error("Metadata: Unable to update profile for client %s. Use of Xinclude?" % client)
+ raise MetadataConsistencyError
def viz(self, hosts, bundles, key, colors):
"""Admin mode viz support."""