summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-19 15:39:54 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-19 15:39:54 -0700
commite731e0b9a06f27d705a0635e848e68f00f2b16cc (patch)
tree3d363e0e85c5452fad00b7f303b4cb631ceb45fa /cloudinit/util.py
parenta8241225f408b8df258af0e6ea0820fb6894ea29 (diff)
downloadvyos-cloud-init-e731e0b9a06f27d705a0635e848e68f00f2b16cc.tar.gz
vyos-cloud-init-e731e0b9a06f27d705a0635e848e68f00f2b16cc.zip
1. Cleanup variable names to match more of the pythonic underscore pattern
2. Seperate config loading from the actual final 'merging' process. a. A util function will now merge multiple config dictionaries after they have all been loaded instead of loading and merging at the same time, which can get confusing to follow.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 164bcea8..91d20a76 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -360,6 +360,7 @@ def get_cfg_by_path(yobj, keyp, default=None):
def fixup_output(cfg, mode):
(outfmt, errfmt) = get_output_cfg(cfg, mode)
redirect_output(outfmt, errfmt)
+ return (outfmt, errfmt)
# redirect_output(outfmt, errfmt, orig_out, orig_err)
@@ -448,6 +449,16 @@ def obj_name(obj):
return obj_name(obj.__class__)
+def mergemanydict(srcs, reverse=False):
+ if reverse:
+ srcs = reversed(srcs)
+ m_cfg = {}
+ for a_cfg in srcs:
+ if a_cfg:
+ m_cfg = mergedict(m_cfg, a_cfg)
+ return m_cfg
+
+
def mergedict(src, cand):
"""
Merge values from C{cand} into C{src}.