From 7a000108af0d3487531fafa4d1075ae411d13c32 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:04:10 +0100 Subject: [PATCH] [PR #9571/d6863eae backport][stable-10] feat(nmcli): support the fail_over_mac parameter (#9594) feat(nmcli): support the fail_over_mac parameter (#9571) * feat(nmcli): support the fail_over_mac parameter * add fail_over_mac to +bond.options * update unit tests * Update changelogs/fragments/9570-feat-nmcli-add-fail-over-mac-parameter.yml Co-authored-by: Felix Fontein * Update plugins/modules/nmcli.py Co-authored-by: Felix Fontein * change to type str and add choices according to documentation * Update plugins/modules/nmcli.py Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein (cherry picked from commit d6863eaec3470607e39aab9ac70b312243e9eed9) Co-authored-by: cnfrancis <37379852+cnfrancis@users.noreply.github.com> --- .../9570-feat-nmcli-add-fail-over-mac-parameter.yml | 2 ++ plugins/modules/nmcli.py | 12 ++++++++++++ tests/unit/plugins/modules/test_nmcli.py | 1 + 3 files changed, 15 insertions(+) create mode 100644 changelogs/fragments/9570-feat-nmcli-add-fail-over-mac-parameter.yml diff --git a/changelogs/fragments/9570-feat-nmcli-add-fail-over-mac-parameter.yml b/changelogs/fragments/9570-feat-nmcli-add-fail-over-mac-parameter.yml new file mode 100644 index 0000000000..c46526e2f6 --- /dev/null +++ b/changelogs/fragments/9570-feat-nmcli-add-fail-over-mac-parameter.yml @@ -0,0 +1,2 @@ +minor_changes: + - nmcli - add a option ``fail_over_mac`` (https://github.com/ansible-collections/community.general/issues/9570, https://github.com/ansible-collections/community.general/pull/9571). \ No newline at end of file diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 0daf667160..3aff17ea6e 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -379,6 +379,12 @@ options: - This is only used with bond - xmit_hash_policy type. type: str version_added: 5.6.0 + fail_over_mac: + description: + - This is only used with bond - fail_over_mac. + type: str + choices: [none, active, follow] + version_added: 10.3.0 arp_interval: description: - This is only used with bond - ARP interval. @@ -1691,6 +1697,7 @@ class Nmcli(object): self.downdelay = module.params['downdelay'] self.updelay = module.params['updelay'] self.xmit_hash_policy = module.params['xmit_hash_policy'] + self.fail_over_mac = module.params['fail_over_mac'] self.arp_interval = module.params['arp_interval'] self.arp_ip_target = module.params['arp_ip_target'] self.slavepriority = module.params['slavepriority'] @@ -1839,6 +1846,7 @@ class Nmcli(object): 'primary': self.primary, 'updelay': self.updelay, 'xmit_hash_policy': self.xmit_hash_policy, + 'fail_over_mac': self.fail_over_mac, }) elif self.type == 'bond-slave': if self.slave_type and self.slave_type != 'bond': @@ -2286,6 +2294,9 @@ class Nmcli(object): if key == 'xmit_hash_policy': cmd.extend(['+bond.options', 'xmit_hash_policy=%s' % value]) continue + if key == 'fail_over_mac': + cmd.extend(['+bond.options', 'fail_over_mac=%s' % value]) + continue cmd.extend([key, value]) return self.execute_command(cmd) @@ -2602,6 +2613,7 @@ def main(): downdelay=dict(type='int'), updelay=dict(type='int'), xmit_hash_policy=dict(type='str'), + fail_over_mac=dict(type='str', choices=['none', 'active', 'follow']), arp_interval=dict(type='int'), arp_ip_target=dict(type='str'), primary=dict(type='str'), diff --git a/tests/unit/plugins/modules/test_nmcli.py b/tests/unit/plugins/modules/test_nmcli.py index 89e8de6d64..f7b8278b4f 100644 --- a/tests/unit/plugins/modules/test_nmcli.py +++ b/tests/unit/plugins/modules/test_nmcli.py @@ -4397,6 +4397,7 @@ def test_bond_connection_unchanged(mocked_generic_connection_diff_check, capfd): downdelay=dict(type='int'), updelay=dict(type='int'), xmit_hash_policy=dict(type='str'), + fail_over_mac=dict(type='str', choices=['none', 'active', 'follow']), arp_interval=dict(type='int'), arp_ip_target=dict(type='str'), primary=dict(type='str'),