summaryrefslogtreecommitdiff
path: root/cloudinit/net/sysconfig.py
diff options
context:
space:
mode:
authorJames Falcon <therealfalcon@gmail.com>2021-07-01 14:43:07 -0500
committerGitHub <noreply@github.com>2021-07-01 14:43:07 -0500
commit81299de5fe3b6e491a965a6ebef66c6b8bf2c037 (patch)
treec4d2277a7f6240e306f6222769d349357510414a /cloudinit/net/sysconfig.py
parent78e89b03ecb29e7df3181b1219a0b5f44b9d7532 (diff)
downloadvyos-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/sysconfig.py')
-rw-r--r--cloudinit/net/sysconfig.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index 3a433c99..8031cd3a 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -18,8 +18,8 @@ from .network_state import (
is_ipv6_addr, net_prefix_to_ipv4_mask, subnet_is_ipv6, IPV6_DYNAMIC_TYPES)
LOG = logging.getLogger(__name__)
-NM_CFG_FILE = "/etc/NetworkManager/NetworkManager.conf"
KNOWN_DISTROS = ['almalinux', 'centos', 'fedora', 'rhel', 'rocky', 'suse']
+NM_CFG_FILE = "/etc/NetworkManager/NetworkManager.conf"
def _make_header(sep='#'):
@@ -931,7 +931,9 @@ class Renderer(renderer.Renderer):
netrules_path = subp.target_path(target, self.netrules_path)
util.write_file(netrules_path, netrules_content, file_mode)
if available_nm(target=target):
- enable_ifcfg_rh(subp.target_path(target, path=NM_CFG_FILE))
+ enable_ifcfg_rh(subp.target_path(
+ target, path=NM_CFG_FILE
+ ))
sysconfig_path = subp.target_path(target, templates.get('control'))
# Distros configuring /etc/sysconfig/network as a file e.g. Centos
@@ -978,7 +980,10 @@ def available_sysconfig(target=None):
def available_nm(target=None):
- if not os.path.isfile(subp.target_path(target, path=NM_CFG_FILE)):
+ if not os.path.isfile(subp.target_path(
+ target,
+ path=NM_CFG_FILE
+ )):
return False
return True