From 37de34e1712e2f95dfd8050ba8b0c61fe0fc9ed2 Mon Sep 17 00:00:00 2001 From: mark-tomich Date: Wed, 15 Nov 2023 16:01:35 -0500 Subject: [PATCH] infiniband and bond interfaces can receive MTU settings too (#7499) * infiniband and bond interfaces can receive MTU settings too * adding test for default mtu setting * the mtu parameter for infiniband is different than for ethernet * adding changelog fragment * Update changelogs/fragments/7499-allow-mtu-setting-on-bond-and-infiniband-interfaces.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein (cherry picked from commit d0870a022e7e8b688fb44db403e0c65db214953a) --- ...allow-mtu-setting-on-bond-and-infiniband-interfaces.yml | 2 ++ plugins/modules/nmcli.py | 7 ++++++- tests/unit/plugins/modules/test_nmcli.py | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/7499-allow-mtu-setting-on-bond-and-infiniband-interfaces.yml diff --git a/changelogs/fragments/7499-allow-mtu-setting-on-bond-and-infiniband-interfaces.yml b/changelogs/fragments/7499-allow-mtu-setting-on-bond-and-infiniband-interfaces.yml new file mode 100644 index 00000000000..f12aa557608 --- /dev/null +++ b/changelogs/fragments/7499-allow-mtu-setting-on-bond-and-infiniband-interfaces.yml @@ -0,0 +1,2 @@ +minor_changes: + - nmcli - allow for the setting of ``MTU`` for ``infiniband`` and ``bond`` interface types (https://github.com/ansible-collections/community.general/pull/7499). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 3882f851793..d12a309bc66 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -1950,15 +1950,20 @@ def mac_setting(self): @property def mtu_conn_type(self): return self.type in ( + 'bond', 'dummy', 'ethernet', + 'infiniband', 'team-slave', 'vlan', ) @property def mtu_setting(self): - return '802-3-ethernet.mtu' + if self.type == 'infiniband': + return 'infiniband.mtu' + else: + return '802-3-ethernet.mtu' @staticmethod def mtu_to_string(mtu): diff --git a/tests/unit/plugins/modules/test_nmcli.py b/tests/unit/plugins/modules/test_nmcli.py index 893caa0db6a..3508f4d2045 100644 --- a/tests/unit/plugins/modules/test_nmcli.py +++ b/tests/unit/plugins/modules/test_nmcli.py @@ -1445,7 +1445,8 @@ ipv6.method: auto ipv6.ignore-auto-dns: no ipv6.ignore-auto-routes: no -infiniband.transport-mode datagram +infiniband.mtu: auto +infiniband.transport-mode: datagram """ TESTCASE_INFINIBAND_STATIC_MODIFY_TRANSPORT_MODE = [