summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2013-05-10 14:26:32 -0700
committerScott Moser <smoser@ubuntu.com>2013-05-10 14:26:32 -0700
commit638cc131857582e3df0c35b8a49433c660fdd299 (patch)
treefcad890958997eff2e643f3141165e71bdd6eb71 /cloudinit/util.py
parent4697c1afcc7d05951f4717a83dad01d2360301c6 (diff)
parent9f866ff5540558bab56f10e38481e4ad2efa079b (diff)
downloadvyos-cloud-init-638cc131857582e3df0c35b8a49433c660fdd299.tar.gz
vyos-cloud-init-638cc131857582e3df0c35b8a49433c660fdd299.zip
Fixed merging capabilities.
Instead of previously having merging which was not backwards compatible with the 0.7.1 and prior methods this patch works to ensure said backwards compatible while at the same time making the new merging functionality work in a more customizable manner.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 053fa95d..b27b3567 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -543,21 +543,16 @@ def make_url(scheme, host, port=None,
def mergemanydict(srcs, reverse=False):
if reverse:
srcs = reversed(srcs)
- m_cfg = {}
- merge_how = [mergers.default_mergers()]
- for a_cfg in srcs:
- if a_cfg:
- # Take the last merger as the one that
- # will define how to merge next...
- mergers_to_apply = list(merge_how[-1])
+ merged_cfg = {}
+ for cfg in srcs:
+ if cfg:
+ # Figure out which mergers to apply...
+ mergers_to_apply = mergers.dict_extract_mergers(cfg)
+ if not mergers_to_apply:
+ mergers_to_apply = mergers.default_mergers()
merger = mergers.construct(mergers_to_apply)
- m_cfg = merger.merge(m_cfg, a_cfg)
- # If the config has now has new merger set,
- # extract them to be used next time...
- new_mergers = mergers.dict_extract_mergers(m_cfg)
- if new_mergers:
- merge_how.append(new_mergers)
- return m_cfg
+ merged_cfg = merger.merge(merged_cfg, cfg)
+ return merged_cfg
@contextlib.contextmanager