Resolves: rhbz#1986788

Signed-off-by: Hangbin Liu <haliu@redhat.com>
This commit is contained in:
Hangbin Liu 2021-07-28 20:20:47 +08:00
parent 25adb0abaf
commit ca94379df6
3 changed files with 194 additions and 2 deletions

View File

@ -0,0 +1,79 @@
From ad9cf008dfed4918e3d1e521647e5f44f46bfc91 Mon Sep 17 00:00:00 2001
From: Hangbin Liu <haliu@redhat.com>
Date: Wed, 21 Jul 2021 14:23:55 +0800
Subject: [PATCH 3/4] utils/team2bond: add cautions for the script
Split the exec-cmd to Dangerous groups and add cautions to let customer
know they need to remove old team device. Also fix a typo.
Add parameter "actual" when dump team config.
Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
utils/team2bond | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/utils/team2bond b/utils/team2bond
index 265bc79..118f38b 100755
--- a/utils/team2bond
+++ b/utils/team2bond
@@ -1,7 +1,7 @@
#!/bin/env python3
# vim: sts=4 ts=4 sw=4 expandtab :
-from optparse import OptionParser
+from optparse import OptionParser, OptionGroup
import subprocess
import json
import sys
@@ -11,7 +11,7 @@ def handle_cmd_line():
parser.add_option('--config', dest='config', default = '',
help = "convert the team JSON format configuration file " \
+ "to NetworkManager connection profile, please use " \
- + "'teamdctl TEAM config dump' to dump the config file." \
+ + "'teamdctl TEAM config dump [actual]' to dump the config file." \
+ " Note the script only convert config file. IP " \
+ "address configurations still need to be set manually.")
parser.add_option('--rename', dest='rename', default = '',
@@ -19,11 +19,17 @@ def handle_cmd_line():
+ " Careful: firewall rules, aliases interfaces, etc., " \
+ "will break after the renaming because the tool " \
+ "will only change the config file, nothing else.")
- parser.add_option('--exec-cmd', dest='exec_cmd', action='store_true', default = False,
+
+ group = OptionGroup(parser, 'Dangerous Options',
+ "Caution: You need to dump the team configuration " \
+ "file first and then delete old team device to avoid " \
+ "device name conflicts.")
+ group.add_option('--exec-cmd', dest='exec_cmd', action='store_true', default = False,
help = "exec nmcli and add the connections directly " \
+ "instead of printing the nmcli cmd to screen. " \
- + "This parameter is NOT recommend, it would be good " \
+ + "This parameter is NOT recommended, it would be good " \
+ "to double check the cmd before apply.")
+ parser.add_option_group(group)
(options, args) = parser.parse_args()
@@ -302,7 +308,8 @@ def main():
if not options.exec_cmd:
print("### These are the commands to configure a bond interface " +
- "similar to this team config:")
+ "similar to this team config (remember to remove the old team " +
+ "device before exec the following cmds):")
if options.rename:
bond_name = options.rename
@@ -313,7 +320,7 @@ def main():
setup_ports(bond_name, team_opts, options.exec_cmd)
if not options.exec_cmd:
- print("### After this, IP addresses, routes and so need to be reconfigured.")
+ print("### After this, IP addresses, routes, and so on, need to be configured.")
if __name__ == '__main__':
main()
--
2.31.1

View File

@ -0,0 +1,99 @@
From ff20b5982cf674e8a0a7267645963a79d2e46729 Mon Sep 17 00:00:00 2001
From: Hangbin Liu <haliu@redhat.com>
Date: Wed, 21 Jul 2021 17:31:59 +0800
Subject: [PATCH 4/4] man: add team2bond man doc
Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
man/Makefile.am | 2 +-
man/team2bond.1 | 69 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 1 deletion(-)
create mode 100644 man/team2bond.1
diff --git a/man/Makefile.am b/man/Makefile.am
index 4c63629..52f0fb9 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -1,3 +1,3 @@
dist_man8_MANS = teamd.8 teamdctl.8 teamnl.8
dist_man5_MANS = teamd.conf.5
-dist_man1_MANS = bond2team.1
+dist_man1_MANS = bond2team.1 team2bond.1
diff --git a/man/team2bond.1 b/man/team2bond.1
new file mode 100644
index 0000000..f47aba4
--- /dev/null
+++ b/man/team2bond.1
@@ -0,0 +1,69 @@
+.TH TEAM2BOND 1 "2021-07-20" "libteam" "Team to Bonding conversion tool"
+.SH NAME
+team2bond \(em Converts a team configuration to a NetworkManager bond configuration
+.SH SYNOPSIS
+.B team2bond
+.RB [options]
+.SH DESCRIPTION
+.PP
+team2bond is a tool to convert team options to bonding options. During the conversion, team2bond tries to create a bond configuration that has the same or similar functionality as the team.
+.PP
+This tool converts a team JSON format configuration file to NetworkManager nmcli commands that you can use to set up a network bonding device. After verifying the commands and deleting the corresponding team device, run the nmcli commands manually or with parameter
+.B \-\-exec
+to create the NetworkManager connection profile.
+.PP
+.B Important:
+Note that deleting the team device makes this connection unavailable until you recreated the bond.
+.SH OPTIONS
+.TP
+.B "\-\-config <team json config file>"
+Specifies the team JSON format configuration file to convert. Use the 'teamdctl <TEAMNAME> config dump [actual]' command to create the JSON file.
+.TP
+.B "\-\-rename <interface>"
+This is a convenient option to replace the original interface name with the specified name. For example, use \-\-rename bond0 to change the interface name to bond0. Note, firewall rules, alias interfaces, and so on, that are tied to the original interface name can break after the renaming an interface because the tool only changes the NetworkManager profile.
+.TP
+.B "\-\-help"
+Print a help text to console and exit.
+.SH DANGEROUS OPTION
+.TP
+.B "\-\-exec"
+Executes the generated nmcli commands and adds the connections directly instead of printing then to the screen. This parameter is NOT recommended. Double-check the generated commands before you apply them.
+.SH EXAMPLE STEPS
+.TP
+1. Save the current 'team0' ip addresses, firewall rules, alias, etc.
+.TP
+2. Dump the current 'team0' configuration to a JSON file. Using the 'actual' option, team2bond dumps the actual config instead of the initial config:
+.TP
+.RS 1
+# teamdctl team0 config dump actual > team0.json
+.RE
+.TP
+3. Run the team2bond utility in dry-run mode to display nmcli commands that set up a network bond with similar settings as the team device:
+.TP
+.RS 1
+# team2bond \%--config team0.json
+.RE
+.TP
+To convert the current 'team0' configuration to bonding connection profile and rename the interface name to 'bond0':
+.TP
+.RS 1
+# team2bond \%--config team0.json \%--rename bond0
+.RE
+.TP
+4. Examine these generated nmcli commands, and make sure all parameters are correct.
+.TP
+5. Delete the team0 device by using the teamd or nmcli utility to avoid a device conflict. Then execute the commands the team2bond utility displayed in the previous step manually or use the \-\-exec option:
+.TP
+.RS 1
+# team2bond \%--config team0.json \%--rename bond0 \%--exec
+.RE
+.SH CAVEATS
+.PP
+The tool will not convert any other configuration which might be tied to the current setup. For instance, IP addresses, firewall rules, alias interfaces, bridges, and so on.
+.SH AUTHOR
+.PP
+Hangbin Liu <haliu@redhat.com>
+.SH SEE ALSO
+.BR nmcli (1),
+.BR teamdctl (8),
+.BR teamd.conf (5).
--
2.31.1

View File

@ -1,6 +1,6 @@
Name: libteam
Version: 1.31
Release: 7%{?dist}
Release: 8%{?dist}
Summary: Library for controlling team network device
License: LGPLv2+
URL: http://www.libteam.org
@ -8,6 +8,8 @@ Source: http://www.libteam.org/files/libteam-%{version}.tar.gz
Patch1: 0001-team-add-a-tool-for-team-to-bonding-config-migration.patch
Patch2: 0002-team2bond-fix-min_ports-format-and-add-lacp_key.patch
Patch3: 0003-utils-team2bond-add-cautions-for-the-script.patch
Patch4: 0004-man-add-team2bond-man-doc.patch
BuildRequires: gcc
BuildRequires: jansson-devel
@ -18,6 +20,9 @@ BuildRequires: systemd
BuildRequires: swig
BuildRequires: doxygen
BuildRequires: make
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
%description
This package contains a library which is a user-space
@ -65,7 +70,8 @@ service.
service.
%prep
%setup -q
%autosetup -p1
autoreconf --force --install -I m4
# prepare example dir for -devel
mkdir -p _tmpdoc1/examples
@ -91,6 +97,7 @@ install -p -m 755 teamd/redhat/initscripts_systemd/network-scripts/ifdown-Team $
install -p -m 755 teamd/redhat/initscripts_systemd/network-scripts/ifup-TeamPort $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/network-scripts
install -p -m 755 teamd/redhat/initscripts_systemd/network-scripts/ifdown-TeamPort $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/network-scripts
install -p -m 755 utils/bond2team $RPM_BUILD_ROOT%{_bindir}/bond2team
install -p -m 755 utils/team2bond $RPM_BUILD_ROOT%{_bindir}/team2bond
%ldconfig_scriptlets
@ -117,10 +124,12 @@ install -p -m 755 utils/bond2team $RPM_BUILD_ROOT%{_bindir}/bond2team
%{_bindir}/teamd
%{_bindir}/teamdctl
%{_bindir}/bond2team
%{_bindir}/team2bond
%{_mandir}/man8/teamd.8*
%{_mandir}/man8/teamdctl.8*
%{_mandir}/man5/teamd.conf.5*
%{_mandir}/man1/bond2team.1*
%{_mandir}/man1/team2bond.1*
%files -n teamd-devel
%{_includedir}/teamdctl.h
@ -134,6 +143,11 @@ install -p -m 755 utils/bond2team $RPM_BUILD_ROOT%{_bindir}/bond2team
%{_sysconfdir}/sysconfig/network-scripts/ifdown-TeamPort
%changelog
* Wed Jul 28 2021 Hangbin Liu <haliu@redhat.com> - 1.31-8
- Build util team2bond in teamd rpm [1986788]
- Add some cautions to util team2bond [1986788]
- Add team2bond man doc [1986788]
* Thu Jun 17 2021 Xin Long <lxin@redhat.com> - 1.31-7
- gating: fix the wrong link of openvswitch for RHEL-9 [1970175]