aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2015-08-17 10:57:15 -0400
committerDan Prince <dprince@redhat.com>2015-08-17 10:57:15 -0400
commit5e48946bcc863bb8a5f19f1c96f11355ba84e96c (patch)
treeb9bff747d7284b43daa5fe3ced03613dbc62677a
parent103b87aa82cfd298b664fe1314e987bd953ec20d (diff)
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
-rw-r--r--os_net_config/impl_ifcfg.py2
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py9
2 files changed, 10 insertions, 1 deletions
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)