summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-07-13 22:03:42 -0400
committerScott Moser <smoser@ubuntu.com>2016-07-13 22:03:42 -0400
commitefef1c263ab1c473fd90f3782a785edab7d02430 (patch)
treebc5313a90762ce0b37ccd509b7d385f49f9bc2dc /cloudinit/sources
parent9f7ce5f090689b664ffce7e0b4ac78bfeafd1a79 (diff)
downloadvyos-cloud-init-efef1c263ab1c473fd90f3782a785edab7d02430.tar.gz
vyos-cloud-init-efef1c263ab1c473fd90f3782a785edab7d02430.zip
ConfigDrive: write 'injected' files and legacy networking
Previous commit disabled the consumption of 'injected' files in configdrive (openstack server boot --file=/target/file=local-file) unless the datasource was in 'pass' mode. The default mode is 'net' so that would never happen. Also here are: a.) a fix for 'links_path_prefix' string from debian, to finally disable the rendering of systemd.link files (LP: #1594546) b.) some comments to apply_network_config c.) implement a backwards compatibility for for distros that do not yet implement apply_network_config by converting the network config into ENI format and calling apply_network. This is required because prior to the previous commit, those distros would have had 'apply_network' called with the openstack provided ENI file. But after this change they will have apply_network_config called by cloudinit's main. d.) a network_state_to_eni helper for converting net config to eni it supports the not-actually-correct 'hwaddress' field in ENI. LP: #1602373
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceConfigDrive.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/cloudinit/sources/DataSourceConfigDrive.py b/cloudinit/sources/DataSourceConfigDrive.py
index 3130e618..91d6ff13 100644
--- a/cloudinit/sources/DataSourceConfigDrive.py
+++ b/cloudinit/sources/DataSourceConfigDrive.py
@@ -107,12 +107,19 @@ class DataSourceConfigDrive(openstack.SourceMixin, sources.DataSource):
if self.dsmode == sources.DSMODE_DISABLED:
return False
- # This is legacy and sneaky. If dsmode is 'pass' then write
- # 'injected files' and apply legacy ENI network format.
prev_iid = get_previous_iid(self.paths)
cur_iid = md['instance-id']
- if prev_iid != cur_iid and self.dsmode == sources.DSMODE_PASS:
- on_first_boot(results, distro=self.distro)
+ if prev_iid != cur_iid:
+ # better would be to handle this centrally, allowing
+ # the datasource to do something on new instance id
+ # note, networking is only rendered here if dsmode is DSMODE_PASS
+ # which means "DISABLED, but render files and networking"
+ on_first_boot(results, distro=self.distro,
+ network=self.dsmode == sources.DSMODE_PASS)
+
+ # This is legacy and sneaky. If dsmode is 'pass' then do not claim
+ # the datasource was used, even though we did run on_first_boot above.
+ if self.dsmode == sources.DSMODE_PASS:
LOG.debug("%s: not claiming datasource, dsmode=%s", self,
self.dsmode)
return False
@@ -184,15 +191,16 @@ def get_previous_iid(paths):
return None
-def on_first_boot(data, distro=None):
+def on_first_boot(data, distro=None, network=True):
"""Performs any first-boot actions using data read from a config-drive."""
if not isinstance(data, dict):
raise TypeError("Config-drive data expected to be a dict; not %s"
% (type(data)))
- net_conf = data.get("network_config", '')
- if net_conf and distro:
- LOG.warn("Updating network interfaces from config drive")
- distro.apply_network(net_conf)
+ if network:
+ net_conf = data.get("network_config", '')
+ if net_conf and distro:
+ LOG.warn("Updating network interfaces from config drive")
+ distro.apply_network(net_conf)
write_injected_files(data.get('files'))