[PR #6769/9d8bec14 backport][stable-7] nmcli: fix empty list to replace / remove values (#6869)

nmcli: fix empty list to replace / remove values (#6769)

(cherry picked from commit 9d8bec14c0)

Co-authored-by: genofire <geno+dev@fireorbit.de>
This commit is contained in:
patchback[bot] 2023-07-06 21:39:07 +02:00 committed by GitHub
parent f8fc18412c
commit 330b0304ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 2 deletions

View file

@ -2183,7 +2183,10 @@ class Nmcli(object):
if key and len(pair) > 1:
raw_value = pair[1].lstrip()
if raw_value == '--':
conn_info[key] = None
if key_type == list:
conn_info[key] = []
else:
conn_info[key] = None
elif key == 'bond.options':
# Aliases such as 'miimon', 'downdelay' are equivalent to the +bond.options 'option=value' syntax.
opts = raw_value.split(',')
@ -2270,7 +2273,7 @@ class Nmcli(object):
# We can't just do `if not value` because then if there's a value
# of 0 specified as an integer it'll be interpreted as empty when
# it actually isn't.
if value != 0 and not value:
if value not in (0, []) and not value:
continue
if key in conn_info: