diff options
Diffstat (limited to 'os_net_config/tests')
-rw-r--r-- | os_net_config/tests/test_impl_eni.py | 18 | ||||
-rw-r--r-- | os_net_config/tests/test_impl_ifcfg.py | 17 | ||||
-rw-r--r-- | os_net_config/tests/test_objects.py | 31 |
3 files changed, 66 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_eni.py b/os_net_config/tests/test_impl_eni.py index c05b7c6..55502b3 100644 --- a/os_net_config/tests/test_impl_eni.py +++ b/os_net_config/tests/test_impl_eni.py @@ -53,6 +53,9 @@ iface br0 inet dhcp pre-up ip addr flush dev eth0 """ +_OVS_BRIDGE_DHCP_PRIMARY_INTERFACE = _OVS_BRIDGE_DHCP + \ + " ovs_extra set bridge br0 other-config:hwaddr=a1:b2:c3:d4:e5\n" + _VLAN_NO_IP = """auto vlan5 iface vlan5 inet manual vlan-raw-device eth0 @@ -146,6 +149,21 @@ class TestENINetConfig(base.TestCase): self.assertEqual(_OVS_PORT_IFACE, self.get_interface_config()) self.assertEqual(_OVS_BRIDGE_DHCP, self.provider.bridges['br0']) + def test_network_ovs_bridge_with_dhcp_and_primary_interface(self): + + def test_interface_mac(name): + return "a1:b2:c3:d4:e5" + self.stubs.Set(utils, 'interface_mac', test_interface_mac) + + interface = objects.Interface(self.if_name, primary=True) + bridge = objects.OvsBridge('br0', use_dhcp=True, + members=[interface]) + self.provider.addBridge(bridge) + self.provider.addInterface(interface) + self.assertEqual(_OVS_PORT_IFACE, self.get_interface_config()) + self.assertEqual(_OVS_BRIDGE_DHCP_PRIMARY_INTERFACE, + self.provider.bridges['br0']) + def test_vlan(self): vlan = objects.Vlan('eth0', 5) self.provider.addVlan(vlan) diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index 629f1cf..2157cd0 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -65,6 +65,9 @@ OVSBOOTPROTO=dhcp OVSDHCPINTERFACES="em1" """ +_OVS_BRIDGE_DHCP_PRIMARY_INTERFACE = _OVS_BRIDGE_DHCP + \ + "OVS_EXTRA=\"set bridge br-ctlplane other-config:hwaddr=a1:b2:c3:d4:e5\"\n" + _BASE_VLAN = """DEVICE=vlan5 ONBOOT=yes HOTPLUG=no @@ -157,6 +160,20 @@ class TestIfcfgNetConfig(base.TestCase): self.assertEqual(_OVS_BRIDGE_DHCP, self.provider.bridges['br-ctlplane']) + def test_network_ovs_bridge_with_dhcp_primary_interface(self): + def test_interface_mac(name): + return "a1:b2:c3:d4:e5" + self.stubs.Set(utils, 'interface_mac', test_interface_mac) + + interface = objects.Interface('em1', primary=True) + bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True, + members=[interface]) + self.provider.addInterface(interface) + self.provider.addBridge(bridge) + self.assertEqual(_OVS_INTERFACE, self.get_interface_config()) + self.assertEqual(_OVS_BRIDGE_DHCP_PRIMARY_INTERFACE, + self.provider.bridges['br-ctlplane']) + def test_add_vlan(self): vlan = objects.Vlan('em1', 5) self.provider.addVlan(vlan) diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py index ecf8d7d..830a809 100644 --- a/os_net_config/tests/test_objects.py +++ b/os_net_config/tests/test_objects.py @@ -152,6 +152,37 @@ class TestBridge(base.TestCase): self.assertEqual(True, interface1.ovs_port) self.assertEqual("br-foo", interface1.bridge_name) + def test_from_json_primary_interface(self): + data = """{ +"type": "ovs_bridge", +"name": "br-foo", +"use_dhcp": true, +"members": [ + { + "type": "interface", + "name": "em1", + "primary": "true" + }, + { + "type": "interface", + "name": "em2" + }] +} +""" + bridge = objects.object_from_json(json.loads(data)) + self.assertEqual("br-foo", bridge.name) + self.assertEqual(True, bridge.use_dhcp) + self.assertEqual("em1", bridge.primary_interface_name) + interface1 = bridge.members[0] + self.assertEqual("em1", interface1.name) + self.assertEqual(True, interface1.ovs_port) + self.assertEqual(True, interface1.primary) + self.assertEqual("br-foo", interface1.bridge_name) + interface2 = bridge.members[1] + self.assertEqual("em2", interface2.name) + self.assertEqual(True, interface2.ovs_port) + self.assertEqual("br-foo", interface2.bridge_name) + class TestBond(base.TestCase): |