aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests
diff options
context:
space:
mode:
authorDan Sneddon <dsneddon@redhat.com>2016-07-08 13:46:57 -0700
committerDan Sneddon <dsneddon@redhat.com>2016-07-25 21:33:39 +0000
commit311df0c3828fe7571079fad9763bca9e2414b51a (patch)
tree89495aec84485c89a29411515f6685c95e45b760 /os_net_config/tests
parentf17add2e8e3c40f79cf211b0cb82a359104ad675 (diff)
Add adapter teaming support using teamd for ifcfg-systems
This change adds support for Linux adapter teams using teamd to manage the bonds instead of the kernel bonding module. Adapter teams using teamd can act like bonds, but also support additional features and possibly more robust fault tolerance. This implementation is fairly straightforward, in order to maintain backward compatibility with templates made for Linux bonds. The only difference in the syntax between the two is type: team instead of type: linux_bond, and the bonding_options format is different. The configuration files for teams should contain the team options as a JSON string. The options that can be used are documented in the teamd.conf(5) man page. If an interface is marked as primary, the priority will be changed from default 0 to 100, making this interface the preferred one. In addition, the MAC address of the Team and all member interfaces will be set to that of the primary interface. At this time, there is no way to set the priority of link members individually, only the interface marked primary will have a non-default priority. This change has been tested on bare metal and worked for a team with two bonded interfaces using LACP. The team was part of an OVS bridge, and there was a VLAN interface on the team. Everything worked as expected. Unit tests are included and passing. Change-Id: If1d516ce8f9ada76375c3a52c5557d3f7348981a Implements: blueprint os-net-config-teaming
Diffstat (limited to 'os_net_config/tests')
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py40
-rw-r--r--os_net_config/tests/test_objects.py22
2 files changed, 62 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index f30eb89..b8a8402 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -244,11 +244,24 @@ BOOTPROTO=dhcp
"""
+_LINUX_TEAM_DHCP = """# This file is autogenerated by os-net-config
+DEVICE=team0
+ONBOOT=yes
+HOTPLUG=no
+NM_CONTROLLED=no
+BOOTPROTO=dhcp
+DEVICETYPE=Team
+"""
+
+
_LINUX_BOND_INTERFACE = _BASE_IFCFG + """MASTER=bond0
SLAVE=yes
BOOTPROTO=none
"""
+_LINUX_TEAM_INTERFACE = _BASE_IFCFG + """TEAM_MASTER=team0
+BOOTPROTO=none
+"""
_IVS_UPLINK = """# This file is autogenerated by os-net-config
DEVICE=em1
@@ -291,6 +304,17 @@ OVS_BRIDGE=br-ex
OVS_PATCH_PEER=br-ex-patch
"""
+_LINUX_TEAM_PRIMARY_IFACE = """# This file is autogenerated by os-net-config
+DEVICE=em1
+ONBOOT=yes
+HOTPLUG=no
+NM_CONTROLLED=no
+PEERDNS=no
+TEAM_MASTER=team1
+TEAM_PORT_CONFIG='{"prio": 100}'
+BOOTPROTO=none
+"""
+
class TestIfcfgNetConfig(base.TestCase):
@@ -311,6 +335,9 @@ class TestIfcfgNetConfig(base.TestCase):
def get_linux_bond_config(self, name='bond0'):
return self.provider.linuxbond_data[name]
+ def get_linux_team_config(self, name='team0'):
+ return self.provider.linuxteam_data[name]
+
def get_route_config(self, name='em1'):
return self.provider.route_data.get(name, '')
@@ -604,6 +631,19 @@ BOOTPROTO=none
self.assertEqual(_LINUX_BOND_INTERFACE,
self.get_interface_config('em1'))
+ def test_linux_team(self):
+ interface1 = objects.Interface('em1')
+ interface2 = objects.Interface('em2')
+ team = objects.LinuxTeam('team0', use_dhcp=True,
+ members=[interface1, interface2])
+ self.provider.add_linux_team(team)
+ self.provider.add_interface(interface1)
+ self.provider.add_interface(interface2)
+ self.assertEqual(_LINUX_TEAM_DHCP,
+ self.get_linux_team_config('team0'))
+ self.assertEqual(_LINUX_TEAM_INTERFACE,
+ self.get_interface_config('em1'))
+
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 51119ec..17b6927 100644
--- a/os_net_config/tests/test_objects.py
+++ b/os_net_config/tests/test_objects.py
@@ -456,6 +456,28 @@ class TestBond(base.TestCase):
self.assertEqual("em2", interface2.name)
+class TestLinuxTeam(base.TestCase):
+
+ def test_from_json_dhcp(self):
+ data = """{
+"type": "team",
+"name": "team1",
+"use_dhcp": true,
+"members": [
+ { "type": "interface", "name": "em1", "primary": true },
+ { "type": "interface", "name": "em2" }
+]
+}
+"""
+ team = objects.object_from_json(json.loads(data))
+ self.assertEqual("team1", team.name)
+ self.assertTrue(team.use_dhcp)
+ interface1 = team.members[0]
+ self.assertEqual("em1", interface1.name)
+ interface2 = team.members[1]
+ self.assertEqual("em2", interface2.name)
+
+
class TestLinuxBond(base.TestCase):
def test_from_json_dhcp(self):