summaryrefslogtreecommitdiffstats
path: root/tools/posixunified.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-11 13:27:07 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-11 13:27:17 -0400
commitafeeb2b6430875cc3979ae4ad690d2a3efc0ac68 (patch)
tree8e68a03334c5f21cd0974c757b49ef75413d1c18 /tools/posixunified.py
parentc5b4bfd842a6f03a4c840cd32c3a99bcc57a8c48 (diff)
downloadbcfg2-afeeb2b6430875cc3979ae4ad690d2a3efc0ac68.tar.gz
bcfg2-afeeb2b6430875cc3979ae4ad690d2a3efc0ac68.tar.bz2
bcfg2-afeeb2b6430875cc3979ae4ad690d2a3efc0ac68.zip
moved plugin-specific configs to main config file; propagate "setup" object to server Core
Diffstat (limited to 'tools/posixunified.py')
-rw-r--r--tools/posixunified.py115
1 files changed, 0 insertions, 115 deletions
diff --git a/tools/posixunified.py b/tools/posixunified.py
deleted file mode 100644
index 8eb4ed734..000000000
--- a/tools/posixunified.py
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/env python
-
-from copy import deepcopy
-import lxml.etree
-import os
-import sys
-
-import Bcfg2.Options
-
-"""
-NOTE: This script takes a conservative approach when it comes to
- updating your Rules. It creates a new unified-rules.xml file
- without the attributes you have defined in your current rules. The
- reason for this is to keep this script simple so we don't have
- to go through and determine the priorities associated with your
- current rules definitions.
-"""
-
-if __name__ == '__main__':
- opts = {
- 'repo': Bcfg2.Options.SERVER_REPOSITORY,
- }
- 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)):
- if '.svn' in dirs:
- dirs.remove('.svn')
- for filename in files:
- if filename.startswith('new'):
- continue
- xdata = lxml.etree.parse(os.path.join(root, filename))
- # replace ConfigFile elements
- for c in xdata.findall('//ConfigFile'):
- parent = c.getparent()
- oldc = c
- c.tag = 'Path'
- parent.replace(oldc, c)
- # replace Directory elements
- for d in xdata.findall('//Directory'):
- parent = d.getparent()
- oldd = d
- d.tag = 'Path'
- parent.replace(oldd, d)
- # Create new-style Rules entry
- newd = deepcopy(d)
- newd.set('type', 'directory')
- rulesroot.append(newd)
- # replace BoundDirectory elements
- for d in xdata.findall('//BoundDirectory'):
- parent = d.getparent()
- oldd = d
- d.tag = 'BoundPath'
- parent.replace(oldd, d)
- # Create new-style entry
- newd = deepcopy(d)
- newd.set('type', 'directory')
- # replace Permissions elements
- for p in xdata.findall('//Permissions'):
- parent = p.getparent()
- oldp = p
- p.tag = 'Path'
- parent.replace(oldp, p)
- # Create new-style Rules entry
- newp = deepcopy(p)
- newp.set('type', 'permissions')
- rulesroot.append(newp)
- # replace BoundPermissions elements
- for p in xdata.findall('//BoundPermissions'):
- parent = p.getparent()
- oldp = p
- p.tag = 'BoundPath'
- parent.replace(oldp, p)
- # Create new-style entry
- newp = deepcopy(p)
- newp.set('type', 'permissions')
- # replace SymLink elements
- for s in xdata.findall('//SymLink'):
- parent = s.getparent()
- olds = s
- s.tag = 'Path'
- parent.replace(olds, s)
- # Create new-style Rules entry
- news = deepcopy(s)
- news.set('type', 'symlink')
- rulesroot.append(news)
- # replace BoundSymLink elements
- for s in xdata.findall('//BoundSymLink'):
- parent = s.getparent()
- olds = s
- s.tag = 'BoundPath'
- parent.replace(olds, s)
- # Create new-style entry
- news = deepcopy(s)
- news.set('type', 'symlink')
- # write out the new bundle
- try:
- newbundle = open("%s/%s/new%s" % (repo, plug, filename), 'w')
- except IOError:
- print("Failed to write %s" % filename)
- continue
- newbundle.write(lxml.etree.tostring(xdata, pretty_print=True))
- newbundle.close()
-
- try:
- newrules = open(unifiedposixrules, 'w')
- rulesroot.set('priority', '1')
- newrules.write(lxml.etree.tostring(rulesroot, pretty_print=True))
- newrules.close()
- except IOError:
- print("Failed to write %s" % unifiedposixrules)