From e503eb8241dda600ef16741c29cab83443ae0528 Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Tue, 1 Jun 2021 10:13:33 +0800 Subject: [PATCH 1/2] nm bond: Fixing `tlb_dynamic_lb` option NM only takes 1 or 0 for True/False, currently only "use_carrier" and "tlb_dynamic_lb" are boolean. Integration test case included. NM 1.31 is required for bug https://bugzilla.redhat.com/show_bug.cgi?id=1959934 Signed-off-by: Gris Ge --- libnmstate/nm/bond.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnmstate/nm/bond.py b/libnmstate/nm/bond.py index cebac4d..067d87f 100644 --- a/libnmstate/nm/bond.py +++ b/libnmstate/nm/bond.py @@ -92,7 +92,7 @@ def _nm_fix_bond_options(option_name, option_value): option_name, option_value ) ) - elif option_name == "use_carrier": + elif option_name in ("use_carrier", "tlb_dynamic_lb"): option_value = 1 if option_value else 0 return str(option_value) -- 2.31.1 From 1d6c7715dfbcb5021016bcd7b4f1f9fa357b2f20 Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Tue, 1 Jun 2021 10:41:57 +0800 Subject: [PATCH 2/2] nm bond: Fix preserving `all_slaves_active` option When `all_slaves_active` was previously set via nmstate or NM, follow up bond modification will fail with: NmstateNotImplementedError: Unsupported bond option: 'all_slaves_active'='0' This is because the option returned by `_get_bond_options_from_profiles()` is not canonicalized. Expand the check to cover `1` and `0`. Integration test case included. Signed-off-by: Gris Ge --- libnmstate/nm/bond.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libnmstate/nm/bond.py b/libnmstate/nm/bond.py index 067d87f..1642319 100644 --- a/libnmstate/nm/bond.py +++ b/libnmstate/nm/bond.py @@ -82,9 +82,9 @@ def create_setting(iface, wired_setting, base_con_profile): def _nm_fix_bond_options(option_name, option_value): if option_name == "all_slaves_active": - if option_value == "delivered": + if option_value in ("delivered", "1"): option_value = 1 - elif option_value == "dropped": + elif option_value in ("dropped", "0"): option_value = 0 else: raise NmstateNotImplementedError( -- 2.31.1