Skip to content

Commit fb38aa5

Browse files
authored
sysconfig: use BONDING_MODULE_OPTS on SUSE (canonical#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.
1 parent a9d3664 commit fb38aa5

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

cloudinit/net/sysconfig.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ class Renderer(renderer.Renderer):
313313
}
314314

315315
# If these keys exist, then their values will be used to form
316-
# a BONDING_OPTS grouping; otherwise no grouping will be set.
316+
# a BONDING_OPTS / BONDING_MODULE_OPTS grouping; otherwise no
317+
# grouping will be set.
317318
bond_tpl_opts = tuple([
318319
('bond_mode', "mode=%s"),
319320
('bond_xmit_hash_policy', "xmit_hash_policy=%s"),
@@ -622,7 +623,7 @@ def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets, flavor):
622623
route_cfg[new_key] = route[old_key]
623624

624625
@classmethod
625-
def _render_bonding_opts(cls, iface_cfg, iface):
626+
def _render_bonding_opts(cls, iface_cfg, iface, flavor):
626627
bond_opts = []
627628
for (bond_key, value_tpl) in cls.bond_tpl_opts:
628629
# Seems like either dash or underscore is possible?
@@ -635,7 +636,18 @@ def _render_bonding_opts(cls, iface_cfg, iface):
635636
bond_opts.append(value_tpl % (bond_value))
636637
break
637638
if bond_opts:
638-
iface_cfg['BONDING_OPTS'] = " ".join(bond_opts)
639+
if flavor == 'suse':
640+
# suse uses the sysconfig support which requires
641+
# BONDING_MODULE_OPTS see
642+
# https://www.kernel.org/doc/Documentation/networking/bonding.txt
643+
# 3.1 Configuration with Sysconfig Support
644+
iface_cfg['BONDING_MODULE_OPTS'] = " ".join(bond_opts)
645+
else:
646+
# rhel uses initscript support and thus requires BONDING_OPTS
647+
# this is also the old default see
648+
# https://www.kernel.org/doc/Documentation/networking/bonding.txt
649+
# 3.2 Configuration with Initscripts Support
650+
iface_cfg['BONDING_OPTS'] = " ".join(bond_opts)
639651

640652
@classmethod
641653
def _render_physical_interfaces(
@@ -663,7 +675,7 @@ def _render_bond_interfaces(cls, network_state, iface_contents, flavor):
663675
for iface in network_state.iter_interfaces(bond_filter):
664676
iface_name = iface['name']
665677
iface_cfg = iface_contents[iface_name]
666-
cls._render_bonding_opts(iface_cfg, iface)
678+
cls._render_bonding_opts(iface_cfg, iface, flavor)
667679

668680
# Ensure that the master interface (and any of its children)
669681
# are actually marked as being bond types...

tests/unittests/test_net.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@
16541654
'expected_sysconfig_opensuse': {
16551655
'ifcfg-bond0': textwrap.dedent("""\
16561656
BONDING_MASTER=yes
1657-
BONDING_OPTS="mode=active-backup """
1657+
BONDING_MODULE_OPTS="mode=active-backup """
16581658
"""xmit_hash_policy=layer3+4 """
16591659
"""miimon=100"
16601660
BONDING_SLAVE_0=eth1
@@ -2240,7 +2240,7 @@
22402240
'expected_sysconfig_opensuse': {
22412241
'ifcfg-bond0': textwrap.dedent("""\
22422242
BONDING_MASTER=yes
2243-
BONDING_OPTS="mode=active-backup xmit_hash_policy=layer3+4 """
2243+
BONDING_MODULE_OPTS="mode=active-backup xmit_hash_policy=layer3+4 """
22442244
"""miimon=100 num_grat_arp=5 """
22452245
"""downdelay=10 updelay=20 """
22462246
"""fail_over_mac=active """

0 commit comments

Comments
 (0)