summaryrefslogtreecommitdiffstats
path: root/os_net_config
diff options
context:
space:
mode:
Diffstat (limited to 'os_net_config')
-rw-r--r--os_net_config/impl_eni.py2
-rw-r--r--os_net_config/impl_ifcfg.py4
-rw-r--r--os_net_config/objects.py16
-rw-r--r--os_net_config/tests/test_impl_eni.py6
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py6
5 files changed, 23 insertions, 11 deletions
diff --git a/os_net_config/impl_eni.py b/os_net_config/impl_eni.py
index 68d91ef..ae60099 100644
--- a/os_net_config/impl_eni.py
+++ b/os_net_config/impl_eni.py
@@ -130,7 +130,7 @@ class ENINetConfig(os_net_config.NetConfig):
data += "auto %s\n" % interface.name
data += _iface
data += address_data
- if interface.mtu != 1500:
+ if interface.mtu:
data += " mtu %i\n" % interface.mtu
if interface.hwaddr:
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index 70f5065..2e99f98 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -164,11 +164,11 @@ class IfcfgNetConfig(os_net_config.NetConfig):
data += "BOOTPROTO=dhcp\n"
elif not base_opt.addresses:
data += "BOOTPROTO=none\n"
- if base_opt.mtu != 1500:
+ if base_opt.mtu:
data += "MTU=%i\n" % base_opt.mtu
if base_opt.use_dhcpv6 or base_opt.v6_addresses():
data += "IPV6INIT=yes\n"
- if base_opt.mtu != 1500:
+ if base_opt.mtu:
data += "IPV6_MTU=%i\n" % base_opt.mtu
if base_opt.use_dhcpv6:
data += "DHCPV6C=yes\n"
diff --git a/os_net_config/objects.py b/os_net_config/objects.py
index dd8489e..b08dc46 100644
--- a/os_net_config/objects.py
+++ b/os_net_config/objects.py
@@ -134,7 +134,7 @@ class _BaseOpts(object):
"""Base abstraction for logical port options."""
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
- routes=None, mtu=1500, primary=False, nic_mapping=None,
+ routes=None, mtu=None, primary=False, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
dns_servers=None):
addresses = addresses or []
@@ -192,7 +192,7 @@ class _BaseOpts(object):
False)))
defroute = strutils.bool_from_string(str(json.get('defroute',
True)))
- mtu = json.get('mtu', 1500)
+ mtu = json.get('mtu', None)
dhclient_args = json.get('dhclient_args')
dns_servers = json.get('dns_servers')
primary = strutils.bool_from_string(str(json.get('primary', False)))
@@ -236,7 +236,7 @@ class Interface(_BaseOpts):
"""Base class for network interfaces."""
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
- routes=None, mtu=1500, primary=False, nic_mapping=None,
+ routes=None, mtu=None, primary=False, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
dns_servers=None):
addresses = addresses or []
@@ -262,7 +262,7 @@ class Vlan(_BaseOpts):
"""
def __init__(self, device, vlan_id, use_dhcp=False, use_dhcpv6=False,
- addresses=None, routes=None, mtu=1500, primary=False,
+ addresses=None, routes=None, mtu=None, primary=False,
nic_mapping=None, persist_mapping=False, defroute=True,
dhclient_args=None, dns_servers=None):
addresses = addresses or []
@@ -294,7 +294,7 @@ class OvsBridge(_BaseOpts):
"""Base class for OVS bridges."""
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
- routes=None, mtu=1500, members=None, ovs_options=None,
+ routes=None, mtu=None, members=None, ovs_options=None,
ovs_extra=None, nic_mapping=None, persist_mapping=False,
defroute=True, dhclient_args=None, dns_servers=None):
addresses = addresses or []
@@ -354,7 +354,7 @@ class LinuxBridge(_BaseOpts):
"""Base class for Linux bridges."""
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
- routes=None, mtu=1500, members=None, nic_mapping=None,
+ routes=None, mtu=None, members=None, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
dns_servers=None):
addresses = addresses or []
@@ -409,7 +409,7 @@ class LinuxBond(_BaseOpts):
"""Base class for Linux bonds."""
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
- routes=None, mtu=1500, primary=False, members=None,
+ routes=None, mtu=None, primary=False, members=None,
bonding_options=None, nic_mapping=None, persist_mapping=False,
defroute=True, dhclient_args=None, dns_servers=None):
addresses = addresses or []
@@ -464,7 +464,7 @@ class OvsBond(_BaseOpts):
"""Base class for OVS bonds."""
def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
- routes=None, mtu=1500, primary=False, members=None,
+ routes=None, mtu=None, primary=False, members=None,
ovs_options=None, ovs_extra=None, nic_mapping=None,
persist_mapping=False, defroute=True, dhclient_args=None,
dns_servers=None):
diff --git a/os_net_config/tests/test_impl_eni.py b/os_net_config/tests/test_impl_eni.py
index e0e009d..7f909ff 100644
--- a/os_net_config/tests/test_impl_eni.py
+++ b/os_net_config/tests/test_impl_eni.py
@@ -221,6 +221,12 @@ class TestENINetConfig(base.TestCase):
self.provider.add_vlan(vlan)
self.assertEqual(_VLAN_NO_IP, self.get_interface_config('vlan5'))
+ def test_vlan_mtu_1500(self):
+ vlan = objects.Vlan('eth0', 5, mtu=1500)
+ self.provider.add_vlan(vlan)
+ expected = _VLAN_NO_IP + ' mtu 1500\n'
+ self.assertEqual(expected, self.get_interface_config('vlan5'))
+
def test_vlan_ovs_bridge_int_port(self):
vlan = objects.Vlan('eth0', 5)
bridge = objects.OvsBridge('br0', use_dhcp=True,
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index c914ea2..8a60a8d 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -359,6 +359,12 @@ class TestIfcfgNetConfig(base.TestCase):
self.provider.add_vlan(vlan)
self.assertEqual(_VLAN_OVS, self.get_interface_config('vlan5'))
+ def test_add_vlan_mtu_1500(self):
+ vlan = objects.Vlan('em1', 5, mtu=1500)
+ self.provider.add_vlan(vlan)
+ expected = _VLAN_NO_IP + 'MTU=1500\n'
+ self.assertEqual(expected, self.get_interface_config('vlan5'))
+
def test_add_ovs_bridge_with_vlan(self):
vlan = objects.Vlan('em1', 5)
bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True,