summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Core.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-01-19 05:17:53 -0800
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-01-19 05:17:53 -0800
commit388b27cb0abc85fe3fb8169742123720adb9d6fb (patch)
tree3be0a558fc98c1cbb03e49450b54a4aafa3dbe23 /src/lib/Server/Core.py
parent3b3c0cc118977e20338c52333c6b7569226ed131 (diff)
parentbb16ce00cbca613129a3bb34ad3fc945f409a4d4 (diff)
downloadbcfg2-388b27cb0abc85fe3fb8169742123720adb9d6fb.tar.gz
bcfg2-388b27cb0abc85fe3fb8169742123720adb9d6fb.tar.bz2
bcfg2-388b27cb0abc85fe3fb8169742123720adb9d6fb.zip
Merge pull request #15 from wgen/client_config_sorting
Move sorting to the server core, rather than just in bcfg2 info
Diffstat (limited to 'src/lib/Server/Core.py')
-rw-r--r--src/lib/Server/Core.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py
index 05625cf22..38f854f66 100644
--- a/src/lib/Server/Core.py
+++ b/src/lib/Server/Core.py
@@ -37,6 +37,14 @@ except:
pass
+def sort_xml(node, key=None):
+ for child in node:
+ sort_xml(child, key)
+
+ sorted_children = sorted(node, key=key)
+ node[:] = sorted_children
+
+
class CoreInitError(Exception):
"""This error is raised when the core cannot be initialized."""
pass
@@ -315,6 +323,9 @@ class Core(Component):
except:
logger.error("error in BindStructure", exc_info=1)
self.validate_goals(meta, config)
+
+ sort_xml(config, key=lambda e: e.get('name'))
+
logger.info("Generated config for %s in %.03f seconds" % \
(client, time.time() - start))
return config