mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* fix #5290
* add changelog fragment
* remove unnecessary braces
* Update changelogs/fragments/5291-fix-nmcli-error-when-setting-unset-mac-address.yaml
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit ec9e10d6d1
)
Co-authored-by: Giorgio Gallo <giorgio.gallo@bitnic.it>
This commit is contained in:
parent
8beb5d70c5
commit
d25b6e7681
2 changed files with 8 additions and 3 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "nmcli - fix error when setting previously unset MAC address, ``gsm.apn`` or ``vpn.data``: current values were being normalized without checking if they might be ``None`` (https://github.com/ansible-collections/community.general/pull/5291)."
|
|
@ -2099,15 +2099,18 @@ class Nmcli(object):
|
||||||
# MAC addresses are case insensitive, nmcli always reports them in uppercase
|
# MAC addresses are case insensitive, nmcli always reports them in uppercase
|
||||||
value = value.upper()
|
value = value.upper()
|
||||||
# ensure current_value is also converted to uppercase in case nmcli changes behaviour
|
# ensure current_value is also converted to uppercase in case nmcli changes behaviour
|
||||||
current_value = current_value.upper()
|
if current_value:
|
||||||
|
current_value = current_value.upper()
|
||||||
if key == 'gsm.apn':
|
if key == 'gsm.apn':
|
||||||
# Depending on version nmcli adds double-qoutes to gsm.apn
|
# Depending on version nmcli adds double-qoutes to gsm.apn
|
||||||
# Need to strip them in order to compare both
|
# Need to strip them in order to compare both
|
||||||
current_value = current_value.strip('"')
|
if current_value:
|
||||||
|
current_value = current_value.strip('"')
|
||||||
if key == self.mtu_setting and self.mtu is None:
|
if key == self.mtu_setting and self.mtu is None:
|
||||||
self.mtu = 0
|
self.mtu = 0
|
||||||
if key == 'vpn.data':
|
if key == 'vpn.data':
|
||||||
current_value = sorted(re.sub(r'\s*=\s*', '=', part.strip(), count=1) for part in current_value.split(','))
|
if current_value:
|
||||||
|
current_value = sorted(re.sub(r'\s*=\s*', '=', part.strip(), count=1) for part in current_value.split(','))
|
||||||
value = sorted(part.strip() for part in value.split(','))
|
value = sorted(part.strip() for part in value.split(','))
|
||||||
else:
|
else:
|
||||||
# parameter does not exist
|
# parameter does not exist
|
||||||
|
|
Loading…
Reference in a new issue