libteam/0014-utils-team2bond-Add-qu...

82 lines
3.7 KiB
Diff

From dea184d3aa8a6038977494ddd4ae6c540317fb72 Mon Sep 17 00:00:00 2001
From: Hangbin Liu <haliu@redhat.com>
Date: Fri, 24 Mar 2023 14:00:11 +0800
Subject: [PATCH 14/15] utils/team2bond: Add queue_id support
Adding bond ports in the option check logic. There is no need to do it in
another loop, then we can remove the bond_ports variable.
Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
utils/team2bond | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/utils/team2bond b/utils/team2bond
index f337906..2f5d868 100755
--- a/utils/team2bond
+++ b/utils/team2bond
@@ -263,10 +263,11 @@ def setup_ports(bond_name, team_opts, exec_cmd):
if 'ports' in team_opts:
for iface in team_opts['ports']:
- bond_ports.append(iface)
+ port_options = ["ifname", iface, "master", bond_name]
+
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))
+ port_options.append("bond-port.queue-id")
+ port_options.append(str(team_opts['ports'][iface]['queue_id']))
if 'lacp_prio' in team_opts['ports'][iface]:
print("# Warn: Option lacp_prio: %d on interface %s is not supported by bonding" %
(team_opts['ports'][iface]['lacp_prio'], iface))
@@ -289,23 +290,21 @@ def setup_ports(bond_name, team_opts, exec_cmd):
primary['name'] = iface
primary['sticky'] = True
- for port in bond_ports:
- ret = subprocess.run(['nmcli', '-g', 'general.type', 'dev', 'show', port],
- stderr=subprocess.PIPE, stdout=subprocess.PIPE)
- if ret.returncode != 0:
- print("# Warn: Get dev %s type failed, will use type ethernet by default" % port)
- if_type = 'ethernet'
- elif ret.stdout.find(b'ethernet') != 0:
- print("# Warn: %s is not a ethernet device, please make sure the type is correct" % port)
- if_type = str(ret.stdout, 'utf-8').strip()
- else:
- if_type = str(ret.stdout, 'utf-8').strip()
+ ret = subprocess.run(['nmcli', '-g', 'general.type', 'dev', 'show', iface],
+ stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+ if ret.returncode != 0:
+ print("# Warn: Get dev %s type failed, will use type ethernet by default" % iface)
+ if_type = 'ethernet'
+ elif ret.stdout.find(b'ethernet') != 0:
+ print("# Warn: %s is not a ethernet device, please make sure the type is correct" % iface)
+ if_type = str(ret.stdout, 'utf-8').strip()
+ else:
+ if_type = str(ret.stdout, 'utf-8').strip()
- if exec_cmd:
- subprocess.run(['nmcli', 'con', 'add', 'type', if_type,
- 'ifname', port, 'master', bond_name])
- else:
- print('nmcli con add type %s ifname %s master %s' % (if_type, port, bond_name))
+ if exec_cmd:
+ subprocess.run(['nmcli', 'con', 'add', 'type', if_type] + port_options)
+ else:
+ print('nmcli con add type %s %s' % (if_type, " ".join(port_options)))
if lacp_key != 0:
if exec_cmd:
@@ -314,6 +313,7 @@ def setup_ports(bond_name, team_opts, exec_cmd):
else:
print('nmcli con mod bond-' + bond_name \
+ ' +bond.options "ad_user_port_key=' + str(lacp_key) + '"')
+
if primary['name']:
if exec_cmd:
subprocess.run(['nmcli', 'con', 'mod', 'bond-' + bond_name,
--
2.38.1