diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-10-12 07:57:35 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-10-12 07:57:35 +0000 |
commit | cf68668803886fb68b0f0a4a33edf65cf17c6b7c (patch) | |
tree | 3415170b00d922626b110b57bde0f597076dc11b /os_net_config/tests/test_objects.py | |
parent | 95a8412bd9a80ce1e15363ae6c1a51db9432f9d7 (diff) | |
parent | 62bc734ad540cde0cf47b863db686b328d575d33 (diff) |
Merge "Add support for Linux Bonding to os-net-config ifcfg"
Diffstat (limited to 'os_net_config/tests/test_objects.py')
-rw-r--r-- | os_net_config/tests/test_objects.py | 58 |
1 files changed, 58 insertions, 0 deletions
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.. |