diff options
author | Scott Moser <smoser@ubuntu.com> | 2013-03-07 17:15:07 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2013-03-07 17:15:07 -0500 |
commit | 973747b00af47c94ba0a719452aa823fb688e5ab (patch) | |
tree | 647bbe6715ffd164726186a1fb4dfef7e6d483d9 /cloudinit/sources/DataSourceNoCloud.py | |
parent | 8013c284e82349246b2274f5475c138323fd7c55 (diff) | |
parent | 5da3984c2ca9e94b2483ab89ecdb5c93b5afb9f8 (diff) | |
download | vyos-cloud-init-973747b00af47c94ba0a719452aa823fb688e5ab.tar.gz vyos-cloud-init-973747b00af47c94ba0a719452aa823fb688e5ab.zip |
support different and user-suppliable merging algorithms for cloud-config
This adds a very useful mechanism for merging cloud-config, allowing
the user to append to lists (ie, just add more 'run_cmd') or other
things.
See doc/merging.txt for more information, it is intended to be backwards
compatible by default.
LP: #1023179
Diffstat (limited to 'cloudinit/sources/DataSourceNoCloud.py')
-rw-r--r-- | cloudinit/sources/DataSourceNoCloud.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/cloudinit/sources/DataSourceNoCloud.py b/cloudinit/sources/DataSourceNoCloud.py index 603f0155..08a853cc 100644 --- a/cloudinit/sources/DataSourceNoCloud.py +++ b/cloudinit/sources/DataSourceNoCloud.py @@ -40,9 +40,8 @@ class DataSourceNoCloud(sources.DataSource): self.supported_seed_starts = ("/", "file://") def __str__(self): - mstr = "%s [seed=%s][dsmode=%s]" % (util.obj_name(self), - self.seed, self.dsmode) - return mstr + root = sources.DataSource.__str__(self) + return "%s [seed=%s][dsmode=%s]" % (root, self.seed, self.dsmode) def get_data(self): defaults = { @@ -65,7 +64,7 @@ class DataSourceNoCloud(sources.DataSource): # Check to see if the seed dir has data. seedret = {} if util.read_optional_seed(seedret, base=self.seed_dir + "/"): - md = util.mergedict(md, seedret['meta-data']) + md = util.mergemanydict([md, seedret['meta-data']]) ud = seedret['user-data'] found.append(self.seed_dir) LOG.debug("Using seeded cache data from %s", self.seed_dir) @@ -82,7 +81,7 @@ class DataSourceNoCloud(sources.DataSource): if self.ds_cfg['user-data']: ud = self.ds_cfg['user-data'] if self.ds_cfg['meta-data'] is not False: - md = util.mergedict(md, self.ds_cfg['meta-data']) + md = util.mergemanydict([md, self.ds_cfg['meta-data']]) if 'ds_config' not in found: found.append("ds_config") @@ -100,7 +99,7 @@ class DataSourceNoCloud(sources.DataSource): LOG.debug("Attempting to use data from %s", dev) (newmd, newud) = util.mount_cb(dev, util.read_seeded) - md = util.mergedict(newmd, md) + md = util.mergemanydict([newmd, md]) ud = newud # For seed from a device, the default mode is 'net'. @@ -150,11 +149,11 @@ class DataSourceNoCloud(sources.DataSource): LOG.debug("Using seeded cache data from %s", seedfrom) # Values in the command line override those from the seed - md = util.mergedict(md, md_seed) + md = util.mergemanydict([md, md_seed]) found.append(seedfrom) # Now that we have exhausted any other places merge in the defaults - md = util.mergedict(md, defaults) + md = util.mergemanydict([md, defaults]) # Update the network-interfaces if metadata had 'network-interfaces' # entry and this is the local datasource, or 'seedfrom' was used |