From 5dd4cc5148c6ef4ab10255a0fb966cb2eaf792e3 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 22:51:01 +0200 Subject: [PATCH] [PR #9962/a7ab7e92 backport][stable-10] Feat: Add infiniband mac address support in nmcli module (#9998) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Feat: Add infiniband mac address support in nmcli module (#9962) * Feat: Add infiniband mac address support in nmcli module * Add changelog fragment * Tentative to fix the error * Update changelogs/fragments/9962-nmcli-add-infiniband-mac-support.yml Co-authored-by: Felix Fontein * Update plugins/modules/nmcli.py Co-authored-by: Felix Fontein * Fix: fix test_bond_connection_unchanged module check * Update plugins/modules/nmcli.py Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Update changelogs/fragments/9962-nmcli-add-infiniband-mac-support.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> (cherry picked from commit a7ab7e924776593570ccbe2232609f5920fc8f83) Co-authored-by: BenoƮt Leveugle --- .../9962-nmcli-add-infiniband-mac-support.yml | 2 ++ plugins/modules/nmcli.py | 13 ++++++++++++- tests/unit/plugins/modules/test_nmcli.py | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/9962-nmcli-add-infiniband-mac-support.yml diff --git a/changelogs/fragments/9962-nmcli-add-infiniband-mac-support.yml b/changelogs/fragments/9962-nmcli-add-infiniband-mac-support.yml new file mode 100644 index 0000000000..0942788868 --- /dev/null +++ b/changelogs/fragments/9962-nmcli-add-infiniband-mac-support.yml @@ -0,0 +1,2 @@ +minor_changes: + - nmcli - add support for Infiniband MAC setting when ``type`` is ``infiniband`` (https://github.com/ansible-collections/community.general/pull/9962). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 3c895e76ec..43cf041ddb 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -99,6 +99,11 @@ options: type: str choices: [datagram, connected] version_added: 5.8.0 + infiniband_mac: + description: + - MAC address of the Infiniband IPoIB devices. + type: str + version_added: 10.6.0 slave_type: description: - Type of the device of this slave's master connection (for example V(bond)). @@ -1764,6 +1769,7 @@ class Nmcli(object): self.wireguard = module.params['wireguard'] self.vpn = module.params['vpn'] self.transport_mode = module.params['transport_mode'] + self.infiniband_mac = module.params['infiniband_mac'] self.sriov = module.params['sriov'] if self.method4: @@ -2034,6 +2040,8 @@ class Nmcli(object): options.update({ 'infiniband.transport-mode': self.transport_mode, }) + if self.infiniband_mac: + options['infiniband.mac-address'] = self.infiniband_mac elif self.type == 'vrf': options.update({ 'table': self.table, @@ -2708,9 +2716,12 @@ def main(): tap=dict(type='bool'))), wireguard=dict(type='dict'), vpn=dict(type='dict'), - transport_mode=dict(type='str', choices=['datagram', 'connected']), sriov=dict(type='dict'), table=dict(type='int'), + # infiniband specific vars + transport_mode=dict(type='str', choices=['datagram', 'connected']), + infiniband_mac=dict(type='str'), + ), mutually_exclusive=[['never_default4', 'gw4'], ['routes4_extended', 'routes4'], diff --git a/tests/unit/plugins/modules/test_nmcli.py b/tests/unit/plugins/modules/test_nmcli.py index 45875cb15b..614c58a842 100644 --- a/tests/unit/plugins/modules/test_nmcli.py +++ b/tests/unit/plugins/modules/test_nmcli.py @@ -4485,8 +4485,10 @@ def test_bond_connection_unchanged(mocked_generic_connection_diff_check, capfd): macvlan=dict(type='dict'), wireguard=dict(type='dict'), vpn=dict(type='dict'), - transport_mode=dict(type='str', choices=['datagram', 'connected']), sriov=dict(type='dict'), + # infiniband specific vars + transport_mode=dict(type='str', choices=['datagram', 'connected']), + infiniband_mac=dict(type='str'), ), mutually_exclusive=[['never_default4', 'gw4'], ['routes4_extended', 'routes4'],