[PR #7612/5adb7ab9 backport][stable-8] interfaces_file: filter by address_familiy when updating method (#7616)

interfaces_file: filter by address_familiy when updating method (#7612)

* When updating method, check address_family if provided.

* Also test modifying 'method' without address_family filter.

(cherry picked from commit 5adb7ab948)

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2023-11-26 20:30:55 +01:00 committed by GitHub
parent b7e68f5b2d
commit e3eaeda81a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 0 deletions

View file

@ -340,6 +340,8 @@ def addOptionAfterLine(option, value, iface, lines, last_line_dict, iface_option
changed = False
for ln in lines:
if ln.get('line_type', '') == 'iface' and ln.get('iface', '') == iface and value != ln.get('params', {}).get('method', ''):
if address_family is not None and ln.get('address_family') != address_family:
continue
changed = True
ln['line'] = re.sub(ln.get('params', {}).get('method', '') + '$', value, ln.get('line'))
ln['params']['method'] = value