summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalen Pennington <cpennington@wgen.net>2012-01-18 15:12:50 -0500
committerCalen Pennington <cpennington@wgen.net>2012-01-18 15:12:50 -0500
commit5398a001f0fb69e79503e51a3d8a9db6a3af4987 (patch)
tree91184a717f5f70feb90232199acdb4867fe93107
parent0029a502ef767e5662e2791b3ca943c3137e6452 (diff)
downloadbcfg2-5398a001f0fb69e79503e51a3d8a9db6a3af4987.tar.gz
bcfg2-5398a001f0fb69e79503e51a3d8a9db6a3af4987.tar.bz2
bcfg2-5398a001f0fb69e79503e51a3d8a9db6a3af4987.zip
Sort xml by name, so that output is consistent between runs, making diffing easier
-rwxr-xr-xsrc/sbin/bcfg2-info11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index 31b9ba0c6..7c655ebe0 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -104,6 +104,13 @@ def displayTrace(trace, num=80, sort=('time', 'calls')):
stats.sort_stats('cumulative', 'calls', 'time')
stats.print_stats(200)
+def sort_xml(node, key=None):
+ for child in node:
+ sort_xml(child, key)
+
+ sorted_children = sorted(node, key=key)
+ node[:] = sorted_children
+
class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
"""Main class for bcfg2-info."""
def __init__(self, repo, plgs, passwd, encoding, event_debug, filemonitor='default'):
@@ -207,7 +214,9 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core):
if not ofile.startswith('/tmp') and not path_force:
print("Refusing to write files outside of /tmp without -f option")
return
- lxml.etree.ElementTree(self.BuildConfiguration(client)).write(ofile,
+ client_config = self.BuildConfiguration(client)
+ sort_xml(client_config, key=lambda e: e.get('name'))
+ lxml.etree.ElementTree(client_config).write(ofile,
encoding='UTF-8', xml_declaration=True,
pretty_print=True)
else: