aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/impl_ifcfg.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/impl_ifcfg.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/impl_ifcfg.py')
-rw-r--r--os_net_config/impl_ifcfg.py61
1 files changed, 60 insertions, 1 deletions
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index 22aef22..49ad317 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -65,6 +65,7 @@ class IfcfgNetConfig(os_net_config.NetConfig):
self.linuxbridge_data = {}
self.linuxbond_data = {}
self.ib_interface_data = {}
+ self.linuxteam_data = {}
self.member_names = {}
self.renamed_interfaces = {}
self.bond_primary_ifaces = {}
@@ -109,11 +110,16 @@ class IfcfgNetConfig(os_net_config.NetConfig):
if base_opt.linux_bond_name:
data += "MASTER=%s\n" % base_opt.linux_bond_name
data += "SLAVE=yes\n"
+ if base_opt.linux_team_name:
+ data += "TEAM_MASTER=%s\n" % base_opt.linux_team_name
+ if base_opt.primary:
+ data += "TEAM_PORT_CONFIG='{\"prio\": 100}'\n"
if base_opt.ivs_bridge_name:
data += "DEVICETYPE=ivs\n"
data += "IVS_BRIDGE=%s\n" % base_opt.ivs_bridge_name
if base_opt.ovs_port:
- data += "DEVICETYPE=ovs\n"
+ if not isinstance(base_opt, objects.LinuxTeam):
+ data += "DEVICETYPE=ovs\n"
if base_opt.bridge_name:
if isinstance(base_opt, objects.Vlan):
data += "TYPE=OVSIntPort\n"
@@ -180,6 +186,19 @@ class IfcfgNetConfig(os_net_config.NetConfig):
self.member_names[base_opt.name] = members
if base_opt.bonding_options:
data += "BONDING_OPTS=\"%s\"\n" % base_opt.bonding_options
+ elif isinstance(base_opt, objects.LinuxTeam):
+ if base_opt.primary_interface_name:
+ primary_name = base_opt.primary_interface_name
+ primary_mac = utils.interface_mac(primary_name)
+ data += "MACADDR=\"%s\"\n" % primary_mac
+ if base_opt.use_dhcp:
+ data += "BOOTPROTO=dhcp\n"
+ if base_opt.members:
+ members = [member.name for member in base_opt.members]
+ self.member_names[base_opt.name] = members
+ data += "DEVICETYPE=Team\n"
+ if base_opt.bonding_options:
+ data += "TEAM_CONFIG='%s'\n" % base_opt.bonding_options
elif isinstance(base_opt, objects.OvsTunnel):
ovs_extra.extend(base_opt.ovs_extra)
data += "DEVICETYPE=ovs\n"
@@ -374,6 +393,18 @@ class IfcfgNetConfig(os_net_config.NetConfig):
if bond.routes:
self._add_routes(bond.name, bond.routes)
+ def add_linux_team(self, team):
+ """Add a LinuxTeam object to the net config object.
+
+ :param team: The LinuxTeam object to add.
+ """
+ logger.info('adding linux team: %s' % team.name)
+ data = self._add_common(team)
+ logger.debug('team data: %s' % data)
+ self.linuxteam_data[team.name] = data
+ if team.routes:
+ self._add_routes(team.name, team.routes)
+
def add_ovs_tunnel(self, tunnel):
"""Add a OvsTunnel object to the net config object.
@@ -451,6 +482,7 @@ class IfcfgNetConfig(os_net_config.NetConfig):
restart_vlans = []
restart_bridges = []
restart_linux_bonds = []
+ restart_linux_teams = []
update_files = {}
all_file_names = []
ivs_uplinks = [] # ivs physical uplinks
@@ -561,6 +593,27 @@ class IfcfgNetConfig(os_net_config.NetConfig):
else:
logger.info('No changes required for bridge: %s' % bridge_name)
+ for team_name, team_data in self.linuxteam_data.iteritems():
+ route_data = self.route_data.get(team_name, '')
+ route6_data = self.route6_data.get(team_name, '')
+ team_path = self.root_dir + bridge_config_path(team_name)
+ team_route_path = self.root_dir + route_config_path(team_name)
+ team_route6_path = self.root_dir + route6_config_path(team_name)
+ all_file_names.append(team_path)
+ all_file_names.append(team_route_path)
+ all_file_names.append(team_route6_path)
+ if (utils.diff(team_path, team_data) or
+ utils.diff(team_route_path, route_data) or
+ utils.diff(team_route6_path, route6_data)):
+ restart_linux_teams.append(team_name)
+ restart_interfaces.extend(self.child_members(team_name))
+ update_files[team_path] = team_data
+ update_files[team_route_path] = route_data
+ update_files[team_route6_path] = route6_data
+ else:
+ logger.info('No changes required for linux team: %s' %
+ team_name)
+
for bond_name, bond_data in self.linuxbond_data.iteritems():
route_data = self.route_data.get(bond_name, '')
route6_data = self.route6_data.get(bond_name, '')
@@ -628,6 +681,9 @@ class IfcfgNetConfig(os_net_config.NetConfig):
for linux_bond in restart_linux_bonds:
self.ifdown(linux_bond)
+ for linux_team in restart_linux_teams:
+ self.ifdown(linux_team)
+
for bridge in restart_bridges:
self.ifdown(bridge, iftype='bridge')
@@ -646,6 +702,9 @@ class IfcfgNetConfig(os_net_config.NetConfig):
for linux_bond in restart_linux_bonds:
self.ifup(linux_bond)
+ for linux_team in restart_linux_teams:
+ self.ifup(linux_team)
+
for bridge in restart_bridges:
self.ifup(bridge, iftype='bridge')