summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2010-07-20 19:03:19 +0000
committerSol Jerome <sol.jerome@gmail.com>2010-07-30 11:53:15 -0500
commitd33b47d56ac81ec1fddd0e1b49315798c0c15d7b (patch)
tree27450b25c0bfb0b66388b8e8838e77072b96d89c /src/lib/Server/Plugins
parent9c092909ac21ac2cab170decdec4b840765012ef (diff)
downloadbcfg2-d33b47d56ac81ec1fddd0e1b49315798c0c15d7b.tar.gz
bcfg2-d33b47d56ac81ec1fddd0e1b49315798c0c15d7b.tar.bz2
bcfg2-d33b47d56ac81ec1fddd0e1b49315798c0c15d7b.zip
Cfg: Allow pull operations to update info.xml files
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5984 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugins')
-rw-r--r--src/lib/Server/Plugins/Cfg.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py
index 48e2d8bcf..dd1e792ec 100644
--- a/src/lib/Server/Plugins/Cfg.py
+++ b/src/lib/Server/Plugins/Cfg.py
@@ -3,6 +3,7 @@ __revision__ = '$Revision$'
import binascii
import logging
+import lxml
import os
import re
import tempfile
@@ -126,19 +127,27 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
logger.info("Wrote file %s" % name)
badattr = [attr for attr in ['owner', 'group', 'perms'] if attr in new_entry]
if badattr:
- if self.infoxml:
- print "InfoXML support not yet implemented"
- return
metadata_updates = {}
metadata_updates.update(self.metadata)
for attr in badattr:
metadata_updates[attr] = new_entry.get(attr)
- infofile = open(self.path + '/:info', 'w')
- for x in metadata_updates.iteritems():
- infofile.write("%s: %s\n" % x)
- infofile.close()
- if log:
- logger.info("Wrote file %s" % infofile.name)
+ if self.infoxml:
+ infoxml = lxml.etree.Element('FileInfo')
+ infotag = lxml.etree.SubElement(infoxml, 'Info')
+ [infotag.attrib.__setitem__(attr, metadata_updates[attr]) \
+ for attr in metadata_updates]
+ ofile = open(self.path + "/info.xml","w")
+ ofile.write(lxml.etree.tostring(infoxml, pretty_print=True))
+ ofile.close()
+ if log:
+ logger.info("Wrote file %s" % (self.path + "/info.xml"))
+ else:
+ infofile = open(self.path + '/:info', 'w')
+ for x in metadata_updates.iteritems():
+ infofile.write("%s: %s\n" % x)
+ infofile.close()
+ if log:
+ logger.info("Wrote file %s" % infofile.name)
class Cfg(Bcfg2.Server.Plugin.GroupSpool,
Bcfg2.Server.Plugin.PullTarget):