summaryrefslogtreecommitdiff
path: root/cloudinit/distros/debian.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-03-15 14:33:45 -0400
committerScott Moser <smoser@brickies.net>2017-03-17 21:31:56 -0400
commit5beecdf88b630a397b3722ddb299e9a37ff02737 (patch)
tree620b47c50cd392789bcd8afd3dc355bcbbf751bc /cloudinit/distros/debian.py
parent58cc8f7521725d4f007ce90001a28326bc240231 (diff)
downloadvyos-cloud-init-5beecdf88b630a397b3722ddb299e9a37ff02737.tar.gz
vyos-cloud-init-5beecdf88b630a397b3722ddb299e9a37ff02737.zip
net: add renderers for automatically selecting the renderer.
Previously, the distro had hard coded which network renderer it would use. This adds support for just picking the right renderer based on what is available. Now, that can be set via a priority in system_info, but should generally work. That config looks like: system_info: network: renderers: ["eni", "sysconfig"] When no renderers are found, a specific RendererNotFoundError is raised. stages.py is modified to catch that and log it at error level. This path should not really be exercised, but could occur if for example an Ubuntu system did not have ifupdown, or a rhel system did not have sysconfig. In such a system previously we would have quietly rendered ENI configuration but that would have been ignored. This is one step better in that we at least log the error.
Diffstat (limited to 'cloudinit/distros/debian.py')
-rw-r--r--cloudinit/distros/debian.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py
index 48ccec8c..1101f02d 100644
--- a/cloudinit/distros/debian.py
+++ b/cloudinit/distros/debian.py
@@ -13,8 +13,6 @@ import os
from cloudinit import distros
from cloudinit import helpers
from cloudinit import log as logging
-from cloudinit.net import eni
-from cloudinit.net.network_state import parse_net_config_data
from cloudinit import util
from cloudinit.distros.parsers.hostname import HostnameConf
@@ -38,11 +36,18 @@ ENI_HEADER = """# This file is generated from information provided by
# network: {config: disabled}
"""
+NETWORK_CONF_FN = "/etc/network/interfaces.d/50-cloud-init.cfg"
+
class Distro(distros.Distro):
hostname_conf_fn = "/etc/hostname"
locale_conf_fn = "/etc/default/locale"
- network_conf_fn = "/etc/network/interfaces.d/50-cloud-init.cfg"
+ renderer_configs = {
+ 'eni': {
+ 'eni_path': NETWORK_CONF_FN,
+ 'eni_header': ENI_HEADER,
+ }
+ }
def __init__(self, name, cfg, paths):
distros.Distro.__init__(self, name, cfg, paths)
@@ -51,12 +56,6 @@ class Distro(distros.Distro):
# should only happen say once per instance...)
self._runner = helpers.Runners(paths)
self.osfamily = 'debian'
- self._net_renderer = eni.Renderer({
- 'eni_path': self.network_conf_fn,
- 'eni_header': ENI_HEADER,
- 'links_path_prefix': None,
- 'netrules_path': None,
- })
def apply_locale(self, locale, out_fn=None):
if not out_fn:
@@ -76,14 +75,12 @@ class Distro(distros.Distro):
self.package_command('install', pkgs=pkglist)
def _write_network(self, settings):
- util.write_file(self.network_conf_fn, settings)
+ util.write_file(NETWORK_CONF_FN, settings)
return ['all']
def _write_network_config(self, netconfig):
- ns = parse_net_config_data(netconfig)
- self._net_renderer.render_network_state("/", ns)
_maybe_remove_legacy_eth0()
- return []
+ return self._supported_write_network_config(netconfig)
def _bring_up_interfaces(self, device_names):
use_all = False