Commit 1b5131a2 authored by Peter V. Saveliev's avatar Peter V. Saveliev

rtnl: team config support

Bug-Url: https://github.com/svinota/pyroute2/issues/699
parent 01700545
......@@ -17,6 +17,7 @@ from pyroute2.netlink.rtnl.iw_event import iw_event
from pyroute2.netlink.rtnl.ifinfmsg.plugins import (bond,
gtp,
ipvlan,
team,
tuntap,
vlan,
vrf,
......@@ -214,6 +215,7 @@ data_plugins = {}
for module in (bond,
gtp,
ipvlan,
team,
tuntap,
vlan,
vrf,
......
from pyroute2.netlink import nla
class team(nla):
prefix = 'IFLA_'
nla_map = (('IFLA_TEAM_UNSPEC', 'none'),
('IFLA_TEAM_CONFIG', 'asciiz'))
......@@ -170,9 +170,17 @@ def manage_team(msg):
if msg['header']['type'] != RTM_NEWLINK:
raise ValueError('wrong command type')
config = {'device': msg.get_attr('IFLA_IFNAME'),
'runner': {'name': 'activebackup'},
'link_watch': {'name': 'ethtool'}}
try:
linkinfo = msg.get_attr('IFLA_LINKINFO')
infodata = linkinfo.get_attr('IFLA_INFO_DATA')
config = infodata.get_attr('IFLA_TEAM_CONFIG')
config = json.loads(config)
except AttributeError:
config = {'runner': {'name': 'activebackup'},
'link_watch': {'name': 'ethtool'}}
# fix device
config['device'] = msg.get_attr('IFLA_IFNAME')
with open(os.devnull, 'w') as fnull:
subprocess.check_call(['teamd', '-d', '-n', '-c', json.dumps(config)],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment