From 6334379e93cdb00d632842769dbcb65584693f12 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 30 May 2017 16:15:27 +0200 Subject: [PATCH] add support for mtu property --- library/network_connections.py | 8 ++++++++ library/test_network_connections.py | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/library/network_connections.py b/library/network_connections.py index f7633f3..45964a0 100755 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -662,6 +662,7 @@ class ArgValidator_DictConnection(ArgValidatorDict): ArgValidatorStr ('master'), ArgValidatorStr ('interface_name'), ArgValidatorMac ('mac'), + ArgValidatorNum ('mtu', val_min = 0, val_max = 0xFFFFFFFF, default_value = None), ArgValidatorBool('check_iface_exists', default_value = True), ArgValidatorStr ('parent'), ArgValidatorNum ('vlan_id', val_min = 0, val_max = 4094, default_value = None), @@ -936,6 +937,9 @@ class IfcfgUtil: else: raise MyError('unsupported type %s' % (connection['type'])) + if connection['mtu']: + ifcfg['MTU'] = str(connection['mtu']) + if connection['slave_type'] is not None: m = cls._connection_find_master(connection['master'], connections, idx) if connection['slave_type'] == 'bridge': @@ -1230,6 +1234,10 @@ class NMUtil: else: raise MyError('unsupported type %s' % (connection['type'])) + if connection['mtu']: + s_wired = self.connection_ensure_setting(con, NM.SettingWired) + s_wired.set_property(NM.SETTING_WIRED_MTU, connection['mtu']) + if connection['slave_type'] is not None: s_con.set_property(NM.SETTING_CONNECTION_SLAVE_TYPE, connection['slave_type']) s_con.set_property(NM.SETTING_CONNECTION_MASTER, self._connection_find_master_uuid(connection['master'], connections, idx)) diff --git a/library/test_network_connections.py b/library/test_network_connections.py index 6c66d0b..b2eca25 100755 --- a/library/test_network_connections.py +++ b/library/test_network_connections.py @@ -153,6 +153,7 @@ class TestValidator(unittest.TestCase): 'dns_search': [], }, 'mac': None, + 'mtu': None, 'master': None, 'vlan_id': None, 'ignore_errors': None, @@ -196,6 +197,7 @@ class TestValidator(unittest.TestCase): 'dhcp4_send_hostname': None, }, 'mac': None, + 'mtu': None, 'master': None, 'vlan_id': None, 'ignore_errors': None, @@ -256,6 +258,7 @@ class TestValidator(unittest.TestCase): 'dns_search': [], }, 'mac': 'aa:bb:cc', + 'mtu': None, 'master': None, 'check_iface_exists': True, 'name': '5', @@ -298,6 +301,7 @@ class TestValidator(unittest.TestCase): 'dhcp4_send_hostname': None, }, 'mac': None, + 'mtu': None, 'master': None, 'vlan_id': None, 'ignore_errors': None, @@ -337,6 +341,7 @@ class TestValidator(unittest.TestCase): 'dhcp4_send_hostname': None, }, 'mac': None, + 'mtu': None, 'master': None, 'vlan_id': None, 'ignore_errors': None, @@ -378,6 +383,7 @@ class TestValidator(unittest.TestCase): 'dhcp4_send_hostname': None, }, 'mac': None, + 'mtu': None, 'master': None, 'vlan_id': None, 'ignore_errors': None,