summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2013-04-17 10:17:09 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2013-04-17 10:17:09 -0700
commit6ad068d1ae175d784481fe8f8e190b2721a221f5 (patch)
treef93023b84cbf94459ef7ce3f31fd5f32b70b1714 /cloudinit
parent66ea1ae9599d27686db2510f3a079485ea8292c3 (diff)
downloadvyos-cloud-init-6ad068d1ae175d784481fe8f8e190b2721a221f5.tar.gz
vyos-cloud-init-6ad068d1ae175d784481fe8f8e190b2721a221f5.zip
Altering the order of merging.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/handlers/cloud_config.py12
-rw-r--r--cloudinit/util.py23
2 files changed, 12 insertions, 23 deletions
diff --git a/cloudinit/handlers/cloud_config.py b/cloudinit/handlers/cloud_config.py
index d30d6338..7678a5b0 100644
--- a/cloudinit/handlers/cloud_config.py
+++ b/cloudinit/handlers/cloud_config.py
@@ -39,7 +39,6 @@ class CloudConfigPartHandler(handlers.Handler):
self.cloud_buf = None
self.cloud_fn = paths.get_ipath("cloud_config")
self.file_names = []
- self.mergers = [DEF_MERGERS]
def list_types(self):
return [
@@ -89,13 +88,9 @@ class CloudConfigPartHandler(handlers.Handler):
return all_mergers
def _merge_part(self, payload, headers):
- next_mergers = self._extract_mergers(payload, headers)
- # Use the merger list from the last call, since it is the one
- # that will be defining how to merge with the next payload.
- curr_mergers = list(self.mergers[-1])
- LOG.debug("Merging by applying %s", curr_mergers)
- self.mergers.append(next_mergers)
- merger = mergers.construct(curr_mergers)
+ my_mergers = self._extract_mergers(payload, headers)
+ LOG.debug("Merging by applying %s", my_mergers)
+ merger = mergers.construct(my_mergers)
if self.cloud_buf is None:
# First time through, merge with an empty dict...
self.cloud_buf = {}
@@ -105,7 +100,6 @@ class CloudConfigPartHandler(handlers.Handler):
def _reset(self):
self.file_names = []
self.cloud_buf = None
- self.mergers = [DEF_MERGERS]
def handle_part(self, _data, ctype, filename, # pylint: disable=W0221
payload, _frequency, headers): # pylint: disable=W0613
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 50de55fe..f7ff28cc 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