Skip to content

Commit

Permalink
fix(nm): Ensure bond property name formatting matches schema definiti…
Browse files Browse the repository at this point in the history
…on (canonical#5383)

The cloud-init network config version 1 schema defines the bond
properties with underscores, prepended with 'bond-'. This change
ensures consistency with the schema for the bond property names.

canonicalGH-5366
  • Loading branch information
jcmoore3 committed Aug 14, 2024
1 parent 90a3190 commit d79050d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 41 deletions.
12 changes: 7 additions & 5 deletions cloudinit/net/network_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,18 @@ def render_interface(self, iface, network_state, renderer):

# These are the interface properties that map nicely
# to NetworkManager properties
# NOTE: Please ensure these items are formatted so as
# to match the schema in schema-network-config-v1.json
_prop_map = {
"bond": {
"mode": "bond-mode",
"miimon": "bond_miimon",
"xmit_hash_policy": "bond-xmit-hash-policy",
"num_grat_arp": "bond-num-grat-arp",
"miimon": "bond-miimon",
"xmit_hash_policy": "bond-xmit_hash_policy",
"num_grat_arp": "bond-num_grat_arp",
"downdelay": "bond-downdelay",
"updelay": "bond-updelay",
"fail_over_mac": "bond-fail-over-mac",
"primary_reselect": "bond-primary-reselect",
"fail_over_mac": "bond-fail_over_mac",
"primary_reselect": "bond-primary_reselect",
"primary": "bond-primary",
},
"bridge": {
Expand Down
53 changes: 20 additions & 33 deletions tests/unittests/net/network_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2160,8 +2160,6 @@
[bond]
mode=active-backup
miimon=100
xmit_hash_policy=layer3+4
[ipv6]
method=auto
Expand Down Expand Up @@ -3055,13 +3053,13 @@
params:
bond-mode: active-backup
bond_miimon: 100
bond-xmit-hash-policy: "layer3+4"
bond-num-grat-arp: 5
bond-xmit_hash_policy: "layer3+4"
bond-num_grat_arp: 5
bond-downdelay: 10
bond-updelay: 20
bond-fail-over-mac: active
bond-fail_over_mac: active
bond-primary: bond0s0
bond-primary-reselect: always
bond-primary_reselect: always
subnets:
- type: static
address: 192.168.0.2/24
Expand Down Expand Up @@ -3138,42 +3136,42 @@
auto bond0s0
iface bond0s0 inet manual
bond-downdelay 10
bond-fail-over-mac active
bond-fail_over_mac active
bond-master bond0
bond-mode active-backup
bond-num-grat-arp 5
bond-num_grat_arp 5
bond-primary bond0s0
bond-primary-reselect always
bond-primary_reselect always
bond-updelay 20
bond-xmit-hash-policy layer3+4
bond-xmit_hash_policy layer3+4
bond_miimon 100
auto bond0s1
iface bond0s1 inet manual
bond-downdelay 10
bond-fail-over-mac active
bond-fail_over_mac active
bond-master bond0
bond-mode active-backup
bond-num-grat-arp 5
bond-num_grat_arp 5
bond-primary bond0s0
bond-primary-reselect always
bond-primary_reselect always
bond-updelay 20
bond-xmit-hash-policy layer3+4
bond-xmit_hash_policy layer3+4
bond_miimon 100
auto bond0
iface bond0 inet static
address 192.168.0.2/24
gateway 192.168.0.1
bond-downdelay 10
bond-fail-over-mac active
bond-fail_over_mac active
bond-mode active-backup
bond-num-grat-arp 5
bond-num_grat_arp 5
bond-primary bond0s0
bond-primary-reselect always
bond-primary_reselect always
bond-slaves none
bond-updelay 20
bond-xmit-hash-policy layer3+4
bond-xmit_hash_policy layer3+4
bond_miimon 100
hwaddress aa:bb:cc:dd:e8:ff
mtu 9000
Expand All @@ -3199,12 +3197,8 @@
"ifcfg-bond0": textwrap.dedent(
"""\
BONDING_MASTER=yes
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 """
"""primary=bond0s0 """
"""primary_reselect=always"
BONDING_MODULE_OPTS="mode=active-backup miimon=100 """
"""downdelay=10 updelay=20 primary=bond0s0"
BONDING_SLAVE_0=bond0s0
BONDING_SLAVE_1=bond0s1
BOOTPROTO=static
Expand Down Expand Up @@ -3237,12 +3231,8 @@
"ifcfg-bond0": textwrap.dedent(
"""\
BONDING_MASTER=yes
BONDING_OPTS="mode=active-backup xmit_hash_policy=layer3+4 """
"""miimon=100 num_grat_arp=5 """
"""downdelay=10 updelay=20 """
"""fail_over_mac=active """
"""primary=bond0s0 """
"""primary_reselect=always"
BONDING_OPTS="mode=active-backup miimon=100 """
"""downdelay=10 updelay=20 primary=bond0s0"
BONDING_SLAVE0=bond0s0
BONDING_SLAVE1=bond0s1
BOOTPROTO=none
Expand Down Expand Up @@ -3361,7 +3351,6 @@
[bond]
mode=active-backup
miimon=100
xmit_hash_policy=layer3+4
num_grat_arp=5
downdelay=10
Expand Down Expand Up @@ -3719,8 +3708,6 @@
[bond]
mode=active-backup
miimon=100
xmit_hash_policy=layer3+4
num_grat_arp=5
downdelay=10
updelay=20
Expand Down
4 changes: 4 additions & 0 deletions tests/unittests/net/test_network_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def test_bond_dns_baseline(self, tmpdir):
[bond]
mode=802.3ad
miimon=100
xmit_hash_policy=layer3+4
[ipv4]
method=disabled
Expand Down Expand Up @@ -286,6 +288,8 @@ def test_bond_dns_redacted_with_method_disabled(self, tmpdir):
[bond]
mode=802.3ad
miimon=100
xmit_hash_policy=layer3+4
[ipv4]
method=disabled
Expand Down
6 changes: 3 additions & 3 deletions tests/unittests/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
bond-miimon: 100
bond-mode: 802.3ad
bond-updelay: 0
bond-xmit-hash-policy: layer3+4
bond-xmit_hash_policy: layer3+4
subnets:
- address: 10.101.10.47/23
gateway: 10.101.11.254
Expand Down Expand Up @@ -254,7 +254,7 @@
bond-miimon: 100
bond-mode: 802.3ad
bond-updelay: 0
bond-xmit-hash-policy: layer3+4
bond-xmit_hash_policy: layer3+4
subnets:
- type: manual
type: bond
Expand Down Expand Up @@ -296,7 +296,7 @@
bond-miimon: 100
bond-mode: 802.3ad
bond-updelay: 0
bond-xmit-hash-policy: layer3+4
bond-xmit_hash_policy: layer3+4
subnets:
- address: 10.101.8.65/26
routes:
Expand Down

0 comments on commit d79050d

Please sign in to comment.