From 7ce531d3c099e310c81f94328b9bfa20de58699b Mon Sep 17 00:00:00 2001 From: Dan Sneddon Date: Mon, 8 Jun 2015 13:52:54 -0700 Subject: Set primary interface on OVS bonds This change sets one of the member interfaces of a bond as the primary interface, which results in that interface being the active slave. This change adds a step to the apply method in impl_ifcfg which runs 'ovs-appctl bond/set-active-slave ' after bringing up the bond interfaces. This step ensures that the bonds work correctly without LACP switch support. If a member interface on the bond is set as primary, that interface will be used. Co-Authored-By: Dan Prince Change-Id: I795bb3b8ef977f9276bfec062b197c473393942e --- os_net_config/tests/test_impl_ifcfg.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'os_net_config/tests') diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index a273b05..9480d47 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -328,6 +328,7 @@ class TestIfcfgNetConfigApply(base.TestCase): self.temp_bridge_file = tempfile.NamedTemporaryFile() self.temp_cleanup_file = tempfile.NamedTemporaryFile(delete=False) self.ifup_interface_names = [] + self.ovs_appctl_cmds = [] def test_ifcfg_path(name): return self.temp_ifcfg_file.name @@ -348,6 +349,8 @@ class TestIfcfgNetConfigApply(base.TestCase): def test_execute(*args, **kwargs): if args[0] == '/sbin/ifup': self.ifup_interface_names.append(args[1]) + elif args[0] == '/bin/ovs-appctl': + self.ovs_appctl_cmds.append(' '.join(args)) pass self.stubs.Set(processutils, 'execute', test_execute) @@ -400,6 +403,19 @@ class TestIfcfgNetConfigApply(base.TestCase): self.provider.apply(activate=False) self.assertEqual([], self.ifup_interface_names) + def test_bond_active_slave(self): + #setup and apply a bond + interface1 = objects.Interface('em1', primary=True) + interface2 = objects.Interface('em2') + bond = objects.OvsBond('bond1', use_dhcp=True, + members=[interface1, interface2]) + self.provider.add_interface(interface1) + self.provider.add_interface(interface2) + self.provider.add_bond(bond) + self.provider.apply() + ovs_appctl_cmds = '/bin/ovs-appctl bond/set-active-slave bond1 em1' + self.assertIn(ovs_appctl_cmds, self.ovs_appctl_cmds) + def test_restart_children_on_change(self): # setup and apply a bridge interface = objects.Interface('em1') -- cgit 1.2.3-korg