aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_impl_ifcfg.py
diff options
context:
space:
mode:
authorBob Fournier <bfournie@redhat.com>2016-11-10 19:17:57 -0500
committerBob Fournier <bfournie@redhat.com>2016-11-15 17:44:33 -0500
commitfceeece7676c900e5295603f318c4218ac516bcb (patch)
tree2325294e9df0e7f80509c58aefffa6d3b91e3595 /os_net_config/tests/test_impl_ifcfg.py
parent191a3b042cf303d70df5badefe9defe81ae4bd6d (diff)
Stop dhclient in os-net-config if interface not set for DHCP
As described in https://bugs.launchpad.net/tripleo/+bug/1640598, there are situations in which the dhclient instance started by dhcp-all-interfaces runs even after the interface is no longer configured for DHCP. This change will terminate the instance using the '-r' argument if 'BOOTPROTO' is not set to 'dhcp' in the ifcfg file for the interface. The dhclient will only be stopped if a dhclient pid file exists, the pid file will be removed after stopping dhclient. Co-Authored-By: Dan Sneddon <dsneddon@redhat.com> Change-Id: I8a52ef5fb8052f185c01dcc27a1ecd70f5d630c8 Closes-Bug: 1640598
Diffstat (limited to 'os_net_config/tests/test_impl_ifcfg.py')
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index 8586daa..228004b 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -843,6 +843,7 @@ class TestIfcfgNetConfigApply(base.TestCase):
self.temp_cleanup_file = tempfile.NamedTemporaryFile(delete=False)
self.ifup_interface_names = []
self.ovs_appctl_cmds = []
+ self.stop_dhclient_interfaces = []
def test_ifcfg_path(name):
return self.temp_ifcfg_file.name
@@ -864,6 +865,11 @@ class TestIfcfgNetConfigApply(base.TestCase):
return self.temp_cleanup_file.name
self.stubs.Set(impl_ifcfg, 'cleanup_pattern', test_cleanup_pattern)
+ def test_stop_dhclient_process(interface):
+ self.stop_dhclient_interfaces.append(interface)
+ self.stubs.Set(impl_ifcfg, 'stop_dhclient_process',
+ test_stop_dhclient_process)
+
def test_execute(*args, **kwargs):
if args[0] == '/sbin/ifup':
self.ifup_interface_names.append(args[1])
@@ -913,6 +919,21 @@ class TestIfcfgNetConfigApply(base.TestCase):
route_data = utils.get_file_data(self.temp_route_file.name)
self.assertEqual("", route_data)
+ def test_dhclient_stop_on_iface_activate(self):
+ self.stop_dhclient_interfaces = []
+ v4_addr = objects.Address('192.168.1.2/24')
+ interface = objects.Interface('em1', addresses=[v4_addr])
+ interface2 = objects.Interface('em2', use_dhcp=True)
+ interface3 = objects.Interface('em3', use_dhcp=False)
+ self.provider.add_interface(interface)
+ self.provider.add_interface(interface2)
+ self.provider.add_interface(interface3)
+ self.provider.apply()
+ # stop dhclient on em1 due to static IP and em3 due to no IP
+ self.assertIn('em1', self.stop_dhclient_interfaces)
+ self.assertIn('em3', self.stop_dhclient_interfaces)
+ self.assertNotIn('em2', self.stop_dhclient_interfaces)
+
def test_apply_noactivate(self):
interface = objects.Interface('em1')
bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True,