Skip to content

Commit

Permalink
nmcli: Fix bond option xmit_hash_policy (#6527)
Browse files Browse the repository at this point in the history
* nmcli_bond_xmit_fix

* Create 6527-nmcli-bond-fix-xmit_hash_policy.yml

add changelog

* Update changelogs/fragments/6527-nmcli-bond-fix-xmit_hash_policy.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* unit tests extend

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit cb1e637)
  • Loading branch information
psvmcc authored and patchback[bot] committed May 21, 2023
1 parent fe7b151 commit e062a78
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/6527-nmcli-bond-fix-xmit_hash_policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- nmcli - fix bond option ``xmit_hash_policy`` (https://github.com/ansible-collections/community.general/pull/6527).
3 changes: 3 additions & 0 deletions plugins/modules/nmcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2046,6 +2046,9 @@ def connection_update(self, nmcli_command):
if key in self.SECRET_OPTIONS:
self.edit_commands += ['set %s %s' % (key, value)]
continue
if key == 'xmit_hash_policy':
cmd.extend(['+bond.options', 'xmit_hash_policy=%s' % value])
continue
cmd.extend([key, value])

return self.execute_command(cmd)
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/plugins/modules/test_nmcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@
'conn_name': 'non_existent_nw_device',
'ifname': 'bond_non_existant',
'mode': 'active-backup',
'xmit_hash_policy': 'layer3+4',
'ip4': '10.10.10.10/24',
'gw4': '10.10.10.1',
'state': 'present',
Expand All @@ -522,7 +523,7 @@
ipv6.method: auto
ipv6.ignore-auto-dns: no
ipv6.ignore-auto-routes: no
bond.options: mode=active-backup,primary=non_existent_primary
bond.options: mode=active-backup,primary=non_existent_primary,xmit_hash_policy=layer3+4
"""

TESTCASE_BRIDGE = [
Expand Down Expand Up @@ -1896,7 +1897,8 @@ def test_bond_connection_create(mocked_generic_connection_create, capfd):

for param in ['ipv4.gateway', 'primary', 'connection.autoconnect',
'connection.interface-name', 'bond_non_existant',
'mode', 'active-backup', 'ipv4.addresses']:
'mode', 'active-backup', 'ipv4.addresses',
'+bond.options', 'xmit_hash_policy=layer3+4']:
assert param in args[0]

out, err = capfd.readouterr()
Expand Down

0 comments on commit e062a78

Please sign in to comment.