From 54255e65e8734635374ee62eb3a8b118f79b568b Mon Sep 17 00:00:00 2001 From: Hangbin Liu Date: Fri, 24 Mar 2023 11:18:43 +0800 Subject: [PATCH 12/15] utils/team2bond: support link watch in ports Signed-off-by: Hangbin Liu --- utils/team2bond | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/utils/team2bond b/utils/team2bond index e6e4f0d..ef4210d 100755 --- a/utils/team2bond +++ b/utils/team2bond @@ -224,18 +224,20 @@ def convert_opts(bond_name, team_opts, exec_cmd): bond_opts += convert_link_watch(link_watch_opts, arp_target, bond_opts) elif isinstance(team_opts['link_watch'], dict): bond_opts += convert_link_watch(team_opts['link_watch'], arp_target, bond_opts) - # Check link watch in team ports if we don't have global link_watch - elif 'ports' in team_opts: + # Check link watch in team ports, we asume it's a dict only? + if 'ports' in team_opts: for iface in team_opts['ports']: - if 'link_watch' in team_opts['ports'][iface]: + if ('link_watch' in team_opts['ports'][iface] and + isinstance(team_opts['ports'][iface]['link_watch'], dict)): bond_opts += convert_link_watch(team_opts['ports'][iface]['link_watch'], arp_target, bond_opts) - else: - print("Warn: No link_watch in team config file, use miimon=100 by default") - bond_opts += ",miimon=100" if arp_target: bond_opts += ",arp_ip_target=" + " ".join(arp_target) + if bond_opts.find("miimon") == -1 and bond_opts.find("_target") == -1: + print("Warn: No link_watch in team config file, use miimon=100 by default") + bond_opts += ",miimon=100" + if exec_cmd: subprocess.run(['nmcli', 'con', 'add', 'type', 'bond', 'ifname', bond_name, 'bond.options', bond_opts]) @@ -252,9 +254,6 @@ def setup_ports(bond_name, team_opts, exec_cmd): if 'ports' in team_opts: for iface in team_opts['ports']: bond_ports.append(iface) - if 'link_watch' in team_opts['ports'][iface] and \ - 'link_watch' in team_opts: - print("# Warn: Option link_watch in interface %s will be ignored as we have global link_watch set!" % iface) if 'queue_id' in team_opts['ports'][iface]: print("# Warn: Option queue_id: %d on interface %s is not supported by NM yet, please see rhbz:1949127" % (team_opts['ports'][iface]['queue_id'], iface)) -- 2.38.1