summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2010-02-21 00:56:23 +0000
committerSol Jerome <solj@ices.utexas.edu>2010-02-21 00:56:23 +0000
commitaf060544733c25a3f52f034e482394585f64da49 (patch)
tree4b609508938b16a3151339b604845a0104fea810 /tools
parent818c1d478e637b68218647b0f7bab2dbf85e8614 (diff)
downloadbcfg2-af060544733c25a3f52f034e482394585f64da49.tar.gz
bcfg2-af060544733c25a3f52f034e482394585f64da49.tar.bz2
bcfg2-af060544733c25a3f52f034e482394585f64da49.zip
tools/posixunified.py: Add more improvements for converting old configuration
Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5735 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'tools')
-rw-r--r--tools/posixunified.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/tools/posixunified.py b/tools/posixunified.py
index 45a998574..b631fb05c 100644
--- a/tools/posixunified.py
+++ b/tools/posixunified.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from copy import deepcopy
import lxml.etree
import os
import sys
@@ -13,6 +14,8 @@ if __name__ == '__main__':
setup = Bcfg2.Options.OptionParser(opts)
setup.parse(sys.argv[1:])
repo = setup['repo']
+ unifiedposixrules = "%s/Rules/unified-rules.xml" % repo
+ rulesroot = lxml.etree.Element("Rules")
for plug in ['Base', 'Bundler']:
for root, dirs, files in os.walk('%s/%s' % (repo, plug)):
@@ -24,30 +27,38 @@ if __name__ == '__main__':
for c in xdata.findall('//ConfigFile'):
parent = c.getparent()
oldc = c
- c.set('type', 'file')
c.tag = 'Path'
parent.replace(oldc, c)
# replace Directory elements
for d in xdata.findall('//Directory'):
parent = d.getparent()
oldd = d
- d.set('type', 'directory')
d.tag = 'Path'
parent.replace(oldd, d)
+ # Create new-style Rules entry
+ newd = deepcopy(d)
+ newd.set('type', 'directory')
+ rulesroot.append(newd)
# replace Permissions elements
for p in xdata.findall('//Permissions'):
parent = p.getparent()
oldp = p
- p.set('type', 'permissions')
p.tag = 'Path'
parent.replace(oldp, p)
+ # Create new-style Rules entry
+ newp = deepcopy(p)
+ newp.set('type', 'permissions')
+ rulesroot.append(newp)
# replace SymLink elements
for s in xdata.findall('//SymLink'):
parent = s.getparent()
olds = s
- s.set('type', 'symlink')
s.tag = 'Path'
parent.replace(olds, s)
+ # Create new-style Rules entry
+ news = deepcopy(s)
+ news.set('type', 'symlink')
+ rulesroot.append(news)
# write out the new bundle
try:
newbundle = open("%s/%s/new%s" % (repo, plug, filename), 'w')
@@ -56,3 +67,10 @@ if __name__ == '__main__':
continue
newbundle.write(lxml.etree.tostring(xdata, pretty_print=True))
newbundle.close()
+
+ try:
+ newrules = open(unifiedposixrules, 'w')
+ except IOError:
+ print("Failed to write %s" % filename)
+ newrules.write(lxml.etree.tostring(rulesroot, pretty_print=True))
+ newrules.close()