diff options
author | Dan Sneddon <dsneddon@redhat.com> | 2015-08-28 00:22:27 -0700 |
---|---|---|
committer | Dan Sneddon <dsneddon@redhat.com> | 2015-10-05 15:40:12 -0700 |
commit | 62bc734ad540cde0cf47b863db686b328d575d33 (patch) | |
tree | 1c7ef8896c7b58c20cbdfc77d5ccd98d968630be /os_net_config/tests | |
parent | 2497f596be89f3f6cfb1431fba68a0a599879e40 (diff) |
Add support for Linux Bonding to os-net-config ifcfg
This change adds support for Linux Bonding to the impl_ifcfg
in os-net-config. This change adds support for configuring Linux
Bonds using the Bonding module rather than Open vSwitch. Most of
the options for Linux Bonds are the same as OVS, with the exception
of bonding_options instead of ovs_options.
Change-Id: If8c6de1554234277843de9fac58536dd5b0a941b
Diffstat (limited to 'os_net_config/tests')
-rw-r--r-- | os_net_config/tests/test_impl_ifcfg.py | 18 | ||||
-rw-r--r-- | os_net_config/tests/test_objects.py | 58 |
2 files changed, 76 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index f083ef8..efee254 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -137,6 +137,15 @@ BOND_IFACES="em1 em2" """ +_LINUX_BOND_DHCP = """# This file is autogenerated by os-net-config +DEVICE=bond0 +ONBOOT=yes +HOTPLUG=no +NM_CONTROLLED=no +BOOTPROTO=dhcp +""" + + class TestIfcfgNetConfig(base.TestCase): def setUp(self): @@ -295,6 +304,15 @@ BOOTPROTO=none self.assertEqual(_OVS_BOND_DHCP, self.get_interface_config('bond0')) + def test_linux_bond(self): + interface1 = objects.Interface('em1') + interface2 = objects.Interface('em2') + bond = objects.LinuxBond('bond0', use_dhcp=True, + members=[interface1, interface2]) + self.provider.add_linux_bond(bond) + self.assertEqual(_LINUX_BOND_DHCP, + self.get_interface_config('bond0')) + def test_interface_defroute(self): interface1 = objects.Interface('em1') interface2 = objects.Interface('em2', defroute=False) diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py index 8488370..3d95bd6 100644 --- a/os_net_config/tests/test_objects.py +++ b/os_net_config/tests/test_objects.py @@ -325,6 +325,64 @@ class TestBond(base.TestCase): self.assertEqual("em2", interface2.name) +class TestLinuxBond(base.TestCase): + + def test_from_json_dhcp(self): + data = """{ +"type": "linux_bond", +"name": "bond1", +"use_dhcp": true, +"members": [ + { + "type": "interface", + "name": "em1" + }, + { + "type": "interface", + "name": "em2" + } +] +} +""" + bridge = objects.object_from_json(json.loads(data)) + self.assertEqual("bond1", bridge.name) + self.assertEqual(True, bridge.use_dhcp) + interface1 = bridge.members[0] + self.assertEqual("em1", interface1.name) + interface2 = bridge.members[1] + self.assertEqual("em2", interface2.name) + + def test_from_json_dhcp_with_nic1_nic2(self): + + def dummy_numbered_nics(nic_mapping=None): + return {"nic1": "em1", "nic2": "em2"} + self.stubs.Set(objects, '_numbered_nics', dummy_numbered_nics) + + data = """{ +"type": "ovs_bond", +"name": "bond1", +"use_dhcp": true, +"members": [ + { + "type": "interface", + "name": "nic1" + }, + { + "type": "interface", + "name": "nic2" + } +] +} +""" + bridge = objects.object_from_json(json.loads(data)) + self.assertEqual("bond1", bridge.name) + self.assertEqual(True, bridge.use_dhcp) + interface1 = bridge.members[0] + self.assertEqual("em1", interface1.name) + interface2 = bridge.members[1] + self.assertEqual("em2", interface2.name) + + class TestNumberedNicsMapping(base.TestCase): # We want to test the function, not the dummy.. |