aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/objects.py
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/objects.py
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/objects.py')
-rw-r--r--os_net_config/objects.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/os_net_config/objects.py b/os_net_config/objects.py
index 289a0da..5137263 100644
--- a/os_net_config/objects.py
+++ b/os_net_config/objects.py
@@ -42,6 +42,8 @@ def object_from_json(json):
return OvsBond.from_json(json)
elif obj_type == "linux_bond":
return LinuxBond.from_json(json)
+ elif obj_type == "team":
+ return LinuxTeam.from_json(json)
elif obj_type == "linux_bridge":
return LinuxBridge.from_json(json)
elif obj_type == "ivs_bridge":
@@ -180,6 +182,7 @@ class _BaseOpts(object):
self.linux_bridge_name = None # internal
self.ivs_bridge_name = None # internal
self.linux_bond_name = None # internal
+ self.linux_team_name = None # internal
self.ovs_port = False # internal
self.primary_interface_name = None # internal
@@ -507,6 +510,62 @@ class IvsBridge(_BaseOpts):
dns_servers=dns_servers)
+class LinuxTeam(_BaseOpts):
+ """Base class for Linux bonds using teamd."""
+
+ def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
+ routes=None, mtu=None, primary=False, members=None,
+ bonding_options=None, nic_mapping=None, persist_mapping=False,
+ defroute=True, dhclient_args=None, dns_servers=None):
+ addresses = addresses or []
+ routes = routes or []
+ members = members or []
+ dns_servers = dns_servers or []
+ super(LinuxTeam, self).__init__(name, use_dhcp, use_dhcpv6, addresses,
+ routes, mtu, primary, nic_mapping,
+ persist_mapping, defroute,
+ dhclient_args, dns_servers)
+ self.members = members
+ self.bonding_options = bonding_options
+ for member in self.members:
+ member.linux_team_name = name
+ if member.primary:
+ if self.primary_interface_name:
+ msg = 'Only one primary interface allowed per team.'
+ raise InvalidConfigException(msg)
+ if member.primary_interface_name:
+ self.primary_interface_name = member.primary_interface_name
+ else:
+ self.primary_interface_name = member.name
+
+ @staticmethod
+ def from_json(json):
+ name = _get_required_field(json, 'name', 'LinuxTeam')
+ (use_dhcp, use_dhcpv6, addresses, routes, mtu, nic_mapping,
+ persist_mapping, defroute, dhclient_args,
+ dns_servers) = _BaseOpts.base_opts_from_json(
+ json, include_primary=False)
+ bonding_options = json.get('bonding_options')
+ members = []
+
+ # members
+ members_json = json.get('members')
+ if members_json:
+ if isinstance(members_json, list):
+ for member in members_json:
+ members.append(object_from_json(member))
+ else:
+ msg = 'Members must be a list.'
+ raise InvalidConfigException(msg)
+
+ return LinuxTeam(name, use_dhcp=use_dhcp, use_dhcpv6=use_dhcpv6,
+ addresses=addresses, routes=routes, mtu=mtu,
+ members=members, bonding_options=bonding_options,
+ nic_mapping=nic_mapping,
+ persist_mapping=persist_mapping, defroute=defroute,
+ dhclient_args=dhclient_args, dns_servers=dns_servers)
+
+
class LinuxBond(_BaseOpts):
"""Base class for Linux bonds."""