From fa4966f4dba8aab9fe17ac5711071e9e56384079 Mon Sep 17 00:00:00 2001 From: Dan Sneddon Date: Mon, 27 Apr 2015 18:39:37 -0700 Subject: Add flag for DEFROUTE=no in ifcfg files to ignore DHCP gateway When multiple interfaces are configured with DHCP, and more than one interface receives a gateway from the DHCP server(s), the resulting default gateway on the system is unpredictable. This change adds the "defroute" boolean to the configuration syntax for os-net-config. Any interface type may be marked so that the gateway received from the DHCP server will not be eligible as a default gateway for the system. This only works for ifcfg files, /etc/network/interfaces lacks an equivalent option. Change-Id: Id775f3506b2ec60c9a2833efd49fb8319151c00d Closes-Bug: 1449288 --- os_net_config/tests/test_impl_ifcfg.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'os_net_config/tests/test_impl_ifcfg.py') diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index 34a9e40..5c733d8 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -260,6 +260,27 @@ BOOTPROTO=none self.assertEqual(_OVS_BOND_DHCP, self.get_interface_config('bond0')) + def test_interface_defroute(self): + interface1 = objects.Interface('em1') + interface2 = objects.Interface('em2', defroute=False) + self.provider.add_interface(interface1) + self.provider.add_interface(interface2) + em1_config = """# This file is autogenerated by os-net-config +DEVICE=em1 +ONBOOT=yes +HOTPLUG=no +BOOTPROTO=none +""" + em2_config = """# This file is autogenerated by os-net-config +DEVICE=em2 +ONBOOT=yes +HOTPLUG=no +BOOTPROTO=none +DEFROUTE=no +""" + self.assertEqual(em1_config, self.get_interface_config('em1')) + self.assertEqual(em2_config, self.get_interface_config('em2')) + class TestIfcfgNetConfigApply(base.TestCase): -- cgit 1.2.3-korg