From dfb61b283d3c4c7fae6d717ed2638393337232ee Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 21 May 2023 17:23:56 +0200 Subject: [PATCH] [PR #6527/cb1e6376 backport][stable-6] nmcli: Fix bond option xmit_hash_policy (#6555) nmcli: Fix bond option xmit_hash_policy (#6527) * 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 * unit tests extend --------- Co-authored-by: Felix Fontein (cherry picked from commit cb1e6376db322f68a44f3681f6c3c3cdcc78019a) Co-authored-by: Sergey Putko --- .../fragments/6527-nmcli-bond-fix-xmit_hash_policy.yml | 2 ++ plugins/modules/nmcli.py | 3 +++ tests/unit/plugins/modules/test_nmcli.py | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/6527-nmcli-bond-fix-xmit_hash_policy.yml diff --git a/changelogs/fragments/6527-nmcli-bond-fix-xmit_hash_policy.yml b/changelogs/fragments/6527-nmcli-bond-fix-xmit_hash_policy.yml new file mode 100644 index 0000000000..5133920b73 --- /dev/null +++ b/changelogs/fragments/6527-nmcli-bond-fix-xmit_hash_policy.yml @@ -0,0 +1,2 @@ +bugfixes: + - nmcli - fix bond option ``xmit_hash_policy`` (https://github.com/ansible-collections/community.general/pull/6527). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 9672c1d159..08680bf6e3 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -2046,6 +2046,9 @@ class Nmcli(object): 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) diff --git a/tests/unit/plugins/modules/test_nmcli.py b/tests/unit/plugins/modules/test_nmcli.py index 7c207ca1f4..efd8284a33 100644 --- a/tests/unit/plugins/modules/test_nmcli.py +++ b/tests/unit/plugins/modules/test_nmcli.py @@ -500,6 +500,7 @@ TESTCASE_BOND = [ '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', @@ -522,7 +523,7 @@ ipv4.may-fail: yes 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 = [ @@ -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()