diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-07-13 22:03:42 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-07-13 22:03:42 -0400 |
commit | efef1c263ab1c473fd90f3782a785edab7d02430 (patch) | |
tree | bc5313a90762ce0b37ccd509b7d385f49f9bc2dc /cloudinit/distros | |
parent | 9f7ce5f090689b664ffce7e0b4ac78bfeafd1a79 (diff) | |
download | vyos-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/distros')
-rw-r--r-- | cloudinit/distros/__init__.py | 27 | ||||
-rw-r--r-- | cloudinit/distros/debian.py | 2 |
2 files changed, 26 insertions, 3 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 14b500f8..006a7062 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -32,6 +32,8 @@ import stat from cloudinit import importer from cloudinit import log as logging from cloudinit import net +from cloudinit.net import eni +from cloudinit.net import network_state from cloudinit import ssh_util from cloudinit import type_utils from cloudinit import util @@ -138,9 +140,30 @@ class Distro(object): return self._bring_up_interfaces(dev_names) return False + def _apply_network_from_network_config(self, netconfig, bring_up=True): + LOG.warn("apply_network_config is not currently implemented " + "for distribution '%s'. Attempting to use " + "apply_network", self.__class__) + header = '\n'.join([ + "# Converted from network_config for distro %s" % self.__class__, + "# Implmentation of _write_network_config is needed." + ]) + ns = network_state.parse_net_config_data(netconfig) + contents = eni.network_state_to_eni( + ns, header=header, render_hwaddress=True) + self.apply_network(contents, bring_up=bring_up) + def apply_network_config(self, netconfig, bring_up=False): - # Write it out - dev_names = self._write_network_config(netconfig) + # apply network config netconfig + # This method is preferred to apply_network which only takes + # a much less complete network config format (interfaces(5)). + try: + dev_names = self._write_network_config(netconfig) + except NotImplementedError: + # backwards compat until all distros have apply_network_config + return self._apply_network_from_network_config( + netconfig, bring_up=bring_up) + # Now try to bring them up if bring_up: return self._bring_up_interfaces(dev_names) diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py index 5ae9a509..4d336b5b 100644 --- a/cloudinit/distros/debian.py +++ b/cloudinit/distros/debian.py @@ -67,7 +67,7 @@ class Distro(distros.Distro): self._net_renderer = eni.Renderer({ 'eni_path': self.network_conf_fn, 'eni_header': ENI_HEADER, - 'links_prefix_path': None, + 'links_path_prefix': None, 'netrules_path': None, }) |