diff options
author | James Falcon <therealfalcon@gmail.com> | 2021-07-01 14:43:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-01 14:43:07 -0500 |
commit | 81299de5fe3b6e491a965a6ebef66c6b8bf2c037 (patch) | |
tree | c4d2277a7f6240e306f6222769d349357510414a /cloudinit/net/renderers.py | |
parent | 78e89b03ecb29e7df3181b1219a0b5f44b9d7532 (diff) | |
download | vyos-cloud-init-81299de5fe3b6e491a965a6ebef66c6b8bf2c037.tar.gz vyos-cloud-init-81299de5fe3b6e491a965a6ebef66c6b8bf2c037.zip |
Add new network activators to bring up interfaces (#919)
Currently _bring_up_interfaces() is a no-op for any distro using
renderers. We need to be able to support bringing up a single
interfaces, a list of interfaces, and all interfaces. This should be
independent of the renderers, as the network config is often
generated independent of the mechanism used to apply it.
Additionally, I included a refactor to remove
"_supported_write_network_config". We had a confusing call chain of
apply_network_config->_write_network_config->_supported_write_network_config.
The last two have been combined.
Diffstat (limited to 'cloudinit/net/renderers.py')
-rw-r--r-- | cloudinit/net/renderers.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/cloudinit/net/renderers.py b/cloudinit/net/renderers.py index c3931a98..822b45de 100644 --- a/cloudinit/net/renderers.py +++ b/cloudinit/net/renderers.py @@ -1,10 +1,13 @@ # This file is part of cloud-init. See LICENSE file for license information. +from typing import List, Tuple, Type + from . import eni from . import freebsd from . import netbsd from . import netplan from . import networkd +from . import renderer from . import RendererNotFoundError from . import openbsd from . import sysconfig @@ -23,7 +26,9 @@ DEFAULT_PRIORITY = ["eni", "sysconfig", "netplan", "freebsd", "netbsd", "openbsd", "networkd"] -def search(priority=None, target=None, first=False): +def search( + priority=None, target=None, first=False +) -> List[Tuple[str, Type[renderer.Renderer]]]: if priority is None: priority = DEFAULT_PRIORITY @@ -40,13 +45,13 @@ def search(priority=None, target=None, first=False): if render_mod.available(target): cur = (name, render_mod.Renderer) if first: - return cur + return [cur] found.append(cur) return found -def select(priority=None, target=None): +def select(priority=None, target=None) -> Tuple[str, Type[renderer.Renderer]]: found = search(priority, target=target, first=True) if not found: if priority is None: @@ -57,6 +62,6 @@ def select(priority=None, target=None): raise RendererNotFoundError( "No available network renderers found%s. Searched " "through list: %s" % (tmsg, priority)) - return found + return found[0] # vi: ts=4 expandtab |