summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Sandmann <sandmann@b1-systems.de>2021-04-09 18:05:43 +0200
committerGitHub <noreply@github.com>2021-04-09 11:05:43 -0500
commitfb38aa591bca82b7aa89187695a2bff676d687cb (patch)
tree2edf1958766635b84cf7a3fbfa55e62e01ce0204
parenta9d3664c93b14e17219a6f097e41e0e21136c865 (diff)
downloadvyos-cloud-init-fb38aa591bca82b7aa89187695a2bff676d687cb.tar.gz
vyos-cloud-init-fb38aa591bca82b7aa89187695a2bff676d687cb.zip
sysconfig: use BONDING_MODULE_OPTS on SUSE (#831)
Update sysconfig configuration to use BONDING_MODULES_OPTS instead of BONDING_OPTS when on a SUSE system. The sysconfig support requires use of BONDING_MODULE_OPTS whereas the initscript support that rhel uses requires BONDING_OPTS.
-rw-r--r--cloudinit/net/sysconfig.py20
-rw-r--r--tests/unittests/test_net.py4
2 files changed, 18 insertions, 6 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index 99a4bae4..e4607804 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -313,7 +313,8 @@ class Renderer(renderer.Renderer):
}
# If these keys exist, then their values will be used to form
- # a BONDING_OPTS grouping; otherwise no grouping will be set.
+ # a BONDING_OPTS / BONDING_MODULE_OPTS grouping; otherwise no
+ # grouping will be set.
bond_tpl_opts = tuple([
('bond_mode', "mode=%s"),
('bond_xmit_hash_policy', "xmit_hash_policy=%s"),
@@ -622,7 +623,7 @@ class Renderer(renderer.Renderer):
route_cfg[new_key] = route[old_key]
@classmethod
- def _render_bonding_opts(cls, iface_cfg, iface):
+ def _render_bonding_opts(cls, iface_cfg, iface, flavor):
bond_opts = []
for (bond_key, value_tpl) in cls.bond_tpl_opts:
# Seems like either dash or underscore is possible?
@@ -635,7 +636,18 @@ class Renderer(renderer.Renderer):
bond_opts.append(value_tpl % (bond_value))
break
if bond_opts:
- iface_cfg['BONDING_OPTS'] = " ".join(bond_opts)
+ if flavor == 'suse':
+ # suse uses the sysconfig support which requires
+ # BONDING_MODULE_OPTS see
+ # https://www.kernel.org/doc/Documentation/networking/bonding.txt
+ # 3.1 Configuration with Sysconfig Support
+ iface_cfg['BONDING_MODULE_OPTS'] = " ".join(bond_opts)
+ else:
+ # rhel uses initscript support and thus requires BONDING_OPTS
+ # this is also the old default see
+ # https://www.kernel.org/doc/Documentation/networking/bonding.txt
+ # 3.2 Configuration with Initscripts Support
+ iface_cfg['BONDING_OPTS'] = " ".join(bond_opts)
@classmethod
def _render_physical_interfaces(
@@ -663,7 +675,7 @@ class Renderer(renderer.Renderer):
for iface in network_state.iter_interfaces(bond_filter):
iface_name = iface['name']
iface_cfg = iface_contents[iface_name]
- cls._render_bonding_opts(iface_cfg, iface)
+ cls._render_bonding_opts(iface_cfg, iface, flavor)
# Ensure that the master interface (and any of its children)
# are actually marked as being bond types...
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 2bd50e72..b72a62b8 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -1654,7 +1654,7 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true
'expected_sysconfig_opensuse': {
'ifcfg-bond0': textwrap.dedent("""\
BONDING_MASTER=yes
- BONDING_OPTS="mode=active-backup """
+ BONDING_MODULE_OPTS="mode=active-backup """
"""xmit_hash_policy=layer3+4 """
"""miimon=100"
BONDING_SLAVE_0=eth1
@@ -2240,7 +2240,7 @@ iface bond0 inet6 static
'expected_sysconfig_opensuse': {
'ifcfg-bond0': textwrap.dedent("""\
BONDING_MASTER=yes
- BONDING_OPTS="mode=active-backup xmit_hash_policy=layer3+4 """
+ BONDING_MODULE_OPTS="mode=active-backup xmit_hash_policy=layer3+4 """
"""miimon=100 num_grat_arp=5 """
"""downdelay=10 updelay=20 """
"""fail_over_mac=active """