Wed, Apr 15, 2020 at 10:34:15AM CEST, jtluka(a)redhat.com wrote:
Tue, Apr 14, 2020 at 08:40:37PM CEST, pgagne(a)redhat.com wrote:
>From: Perry Gagne <pgagne(a)redhat.com>
>
>Signed-off-by: Perry Gagne <pgagne(a)redhat.com>
>---
> lnst/Devices/TeamDevice.py | 49 ++++++++++++++++-----------------
> lnst/Recipes/ENRT/TeamRecipe.py | 11 ++++----
> 2 files changed, 29 insertions(+), 31 deletions(-)
>
>diff --git a/lnst/Devices/TeamDevice.py b/lnst/Devices/TeamDevice.py
>index 4f6eee5..3a60125 100644
>--- a/lnst/Devices/TeamDevice.py
>+++ b/lnst/Devices/TeamDevice.py
>@@ -9,44 +9,43 @@ published by the Free Software Foundation; see COPYING for details.
> __author__ = """
> olichtne(a)redhat.com (Ondrej Lichtner)
> """
>-
>-import re
>+import json
> from lnst.Common.ExecCmd import exec_cmd
>-from lnst.Common.Utils import bool_it
>+from lnst.Common.DeviceError import DeviceError, DeviceConfigError
> from lnst.Devices.MasterDevice import MasterDevice
>
>-def prepare_json_str(json_str):
>- if not json_str:
>- return "{}"
>- json_str = json_str.replace('"', '\\"')
>- json_str = re.sub('\s+', ' ', json_str)
>- return json_str
>
>-#TODO rework with pyroute2? don't know how json and teamd works with that...
Please do not remove the TODO unless you resolved it or you're sure this
is not doable. Maybe you already discussed this with Ondrej, in that
case ignore my comment.
So I looked at the pyroute2 code and the team driver is supported.
The problem seems to be that IPRoute does not support passing the teamd
config yet and the active-backup runner is used as default. Might be
worth to check with pyroute maintainer.
<cut> <!-- netlink/rtnl/ifinfmsg/proxy.py -->
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'}}
with open(os.devnull, 'w') as fnull:
subprocess.check_call(['teamd', '-d', '-n', '-c',
json.dumps(config)],
stdout=fnull,
stderr=fnull)
</cut>