aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_impl_ifcfg.py
diff options
context:
space:
mode:
authorDan Sneddon <dsneddon@redhat.com>2016-03-10 12:37:49 -0800
committerDan Sneddon <dsneddon@redhat.com>2016-03-22 10:18:04 -0700
commitbfc72bd5ce838dad03e41e44cae661074552cb39 (patch)
tree4abcef14683176f41e04b7571523bac3b770ea28 /os_net_config/tests/test_impl_ifcfg.py
parentef02752ebf86e5d8edc681426dc246d2d98732ea (diff)
Fix order-of-operations bug in os-net-config restart_interfaces
The current order of operations of bringing up interfaces starts with the bridges, and restarts the members of the bridges. This works well when an OVS bond is part of an OVS bridge, but does not work well when Linux bonding is used with no bridges (such as in the case of the Nuage plugin, which creates the bridges outside of the ifcfg files). This change will ensure that Linux bonds are brought up first, then any bridges are brought up, interfaces are brought up next, and the VLAN interfacs are brought up last. This corrects a race condition where any VLAN which was brought up before the bond would not be active, and the VLAN would have to be brought up by hand. This change also fixes a logging issue where os-net-config would report that no changes were necessary when changes were made. Now, the logging messages indicating that "No changes were necessary" show up when no changes are required, instead of when changes are actually made. Change-Id: I1efee3dfd8e8cef01b054bb57a3085cc7eb60372
Diffstat (limited to 'os_net_config/tests/test_impl_ifcfg.py')
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index 3500e4c..fa85de7 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -179,11 +179,11 @@ BOOTPROTO=none
"""
_VLAN_LINUX_BRIDGE = _BASE_VLAN_OVS + """VLAN=yes
+PHYSDEV=em1
BRIDGE=br-ctlplane
BOOTPROTO=none
"""
-
_OVS_BOND_DHCP = """# This file is autogenerated by os-net-config
DEVICE=bond0
ONBOOT=yes
@@ -246,6 +246,12 @@ class TestIfcfgNetConfig(base.TestCase):
def get_interface_config(self, name='em1'):
return self.provider.interface_data[name]
+ def get_vlan_config(self, name='vlan1'):
+ return self.provider.vlan_data[name]
+
+ def get_linux_bond_config(self, name='bond0'):
+ return self.provider.linuxbond_data[name]
+
def get_route_config(self, name='em1'):
return self.provider.route_data.get(name, '')
@@ -430,19 +436,19 @@ class TestIfcfgNetConfig(base.TestCase):
def test_add_vlan(self):
vlan = objects.Vlan('em1', 5)
self.provider.add_vlan(vlan)
- self.assertEqual(_VLAN_NO_IP, self.get_interface_config('vlan5'))
+ self.assertEqual(_VLAN_NO_IP, self.get_vlan_config('vlan5'))
def test_add_vlan_ovs(self):
vlan = objects.Vlan('em1', 5)
vlan.ovs_port = True
self.provider.add_vlan(vlan)
- self.assertEqual(_VLAN_OVS, self.get_interface_config('vlan5'))
+ self.assertEqual(_VLAN_OVS, self.get_vlan_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'))
+ self.assertEqual(expected, self.get_vlan_config('vlan5'))
def test_add_ovs_bridge_with_vlan(self):
vlan = objects.Vlan('em1', 5)
@@ -450,16 +456,15 @@ class TestIfcfgNetConfig(base.TestCase):
members=[vlan])
self.provider.add_vlan(vlan)
self.provider.add_bridge(bridge)
- self.assertEqual(_VLAN_OVS_BRIDGE, self.get_interface_config('vlan5'))
+ self.assertEqual(_VLAN_OVS_BRIDGE, self.get_vlan_config('vlan5'))
def test_add_linux_bridge_with_vlan(self):
- vlan = objects.Vlan(None, 5)
+ vlan = objects.Vlan('em1', 5)
bridge = objects.LinuxBridge('br-ctlplane', use_dhcp=True,
members=[vlan])
self.provider.add_vlan(vlan)
self.provider.add_bridge(bridge)
- self.assertEqual(_VLAN_LINUX_BRIDGE,
- self.get_interface_config('vlan5'))
+ self.assertEqual(_VLAN_LINUX_BRIDGE, self.get_vlan_config('vlan5'))
def test_ovs_bond(self):
interface1 = objects.Interface('em1')
@@ -489,7 +494,7 @@ BOOTPROTO=none
members=[interface1, interface2])
self.provider.add_linux_bond(bond)
self.assertEqual(_LINUX_BOND_DHCP,
- self.get_interface_config('bond0'))
+ self.get_linux_bond_config('bond0'))
def test_interface_defroute(self):
interface1 = objects.Interface('em1')