summaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_objects.py
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2014-08-12 11:06:46 -0400
committerDan Prince <dprince@redhat.com>2014-08-12 11:51:31 -0400
commitf0ae3282450c2bb1bb35f22414858768f08d2653 (patch)
treeedcf2d322f4b222bd0b11034ce4e09689caf10ef /os_net_config/tests/test_objects.py
parentf57b67880d5c70bbc287ab56395895bb88a1b011 (diff)
Set the MAC to the primary interface
Adds support for a new 'primary' interface option exposed via the object model and JSON parsers which can be used to force the MAC address on a bridge. Only one interface on a given bridge (or bond) may be set as the primary interface. Also, update the ifcfg and eni providers so that they use OVS_EXTRA (or ovs_extra) to pin the mac accordingly.
Diffstat (limited to 'os_net_config/tests/test_objects.py')
-rw-r--r--os_net_config/tests/test_objects.py31
1 files changed, 31 insertions, 0 deletions
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):