From 5e48946bcc863bb8a5f19f1c96f11355ba84e96c Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 17 Aug 2015 10:57:15 -0400 Subject: os-net-config: ensure ifup is called just once This patch fixes an issue in the ifcfg provider implementation that caused interfaces to be started twice. This can cause failures if the interface uses DHCP and dhclient was already running. The child_members function was incorrectly adding the interface name to the child members set on key error. This patch removes that logic and simply ignores key errors. Change-Id: Ibe0e32bc09979bc68b92a722b2bfa383e77502a9 Closes-bug: #1485634 --- os_net_config/impl_ifcfg.py | 2 +- os_net_config/tests/test_impl_ifcfg.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 99273bc..4cacbf8 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -62,7 +62,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): children.add(member) children.update(self.child_members(member)) except KeyError: - children.add(name) + pass return children def _add_common(self, base_opt): diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index e32aff2..3a77ee9 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -489,6 +489,15 @@ class TestIfcfgNetConfigApply(base.TestCase): self.assertIn('em1', self.ifup_interface_names) self.assertIn('em2', self.ifup_interface_names) + def test_restart_interface_counts(self): + interface = objects.Interface('em1') + self.provider.add_interface(interface) + interface2 = objects.Interface('em2') + self.provider.add_interface(interface2) + self.provider.apply() + self.assertEqual(1, self.ifup_interface_names.count("em1")) + self.assertEqual(1, self.ifup_interface_names.count("em2")) + def test_vlan_apply(self): vlan = objects.Vlan('em1', 5) self.provider.add_vlan(vlan) -- cgit 1.2.3-korg