aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_objects.py
diff options
context:
space:
mode:
authorxinwu <xin.wu@bigswitch.com>2016-01-31 18:35:28 -0800
committerxinwu <xin.wu@bigswitch.com>2016-03-07 18:59:02 -0800
commit63659fe4a60dfb18bbc8cc835d6d1c4fe7317a60 (patch)
tree5e9365a8a9e3a15552ad1fdba1fb83f3b0ad5390 /os_net_config/tests/test_objects.py
parentc545e46f8fe2362df81e86c187aa6e50be185ad6 (diff)
Enable os_net_config to configure IVS
This change generates /etc/sysconf/network-scripts/ifcfg-* for ivs. It also generates /etc/sysconf/ivs configuration file for ivs. It supports only RedHat at this point. Indigo Virtual Switch (IVS, https://github.com/floodlight/ivs) is a virtual switch for Linux. It is compatible with the KVM hypervisor and leveraging the Open vSwitch kernel module for packet forwarding. There are three major differences between IVS and OVS: 1. Each node can have at most one ivs, name is not required. 2. Bond is not allowed to attach to an ivs. It is the SDN controller's job to dynamically form bonds on ivs. 3. IP address can only be statically assigned. Change-Id: I276d736794d123405de793c2a4eb2c1ee55a0fad
Diffstat (limited to 'os_net_config/tests/test_objects.py')
-rw-r--r--os_net_config/tests/test_objects.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py
index a2e021b..83f9221 100644
--- a/os_net_config/tests/test_objects.py
+++ b/os_net_config/tests/test_objects.py
@@ -343,6 +343,61 @@ class TestLinuxBridge(base.TestCase):
self.assertEqual("br-foo", interface2.linux_bridge_name)
+class TestIvsBridge(base.TestCase):
+
+ def test_interface_from_json(self):
+ data = """{
+"type": "ivs_bridge",
+"members": [{
+ "type": "interface",
+ "name": "nic2"
+}]
+}
+"""
+ bridge = objects.object_from_json(json.loads(data))
+ self.assertEqual("ivs", bridge.name)
+ interface1 = bridge.members[0]
+ self.assertEqual("nic2", interface1.name)
+ self.assertEqual(False, interface1.ovs_port)
+ self.assertEqual("ivs", interface1.ivs_bridge_name)
+
+ def test_ivs_interface_from_json(self):
+ data = """{
+"type": "ivs_bridge",
+"members": [{
+ "type": "ivs_interface",
+ "name": "storage",
+ "vlan_id": 202
+}]
+}
+"""
+ bridge = objects.object_from_json(json.loads(data))
+ self.assertEqual("ivs", bridge.name)
+ interface1 = bridge.members[0]
+ self.assertEqual("storage202", interface1.name)
+ self.assertEqual(False, interface1.ovs_port)
+ self.assertEqual("ivs", interface1.ivs_bridge_name)
+
+ def test_bond_interface_from_json(self):
+ data = """{
+"type": "ivs_bridge",
+"members": [{
+ "type": "linux_bond",
+ "name": "bond1",
+ "members": [
+ {"type": "interface", "name": "nic2"},
+ {"type": "interface", "name": "nic3"}
+ ]
+}]
+}
+"""
+ err = self.assertRaises(objects.InvalidConfigException,
+ objects.IvsBridge.from_json,
+ json.loads(data))
+ expected = 'IVS does not support bond interfaces.'
+ self.assertIn(expected, err)
+
+
class TestBond(base.TestCase):
def test_from_json_dhcp(self):