After some debugging, I could make it work... I'm not a programmer, so it might be wrong, but it's working:
root@netplan:~# cat fix-bug-1770082.diff --- a/netplan/cli/commands/apply.py +++ b/netplan/cli/commands/apply.py @@ -170,15 +170,15 @@ link = netifaces.ifaddresses(interface)[netifaces.AF_LINK][0] macaddress = link.get('addr') if driver_name in matches['by-driver']: - new_name = matches['by-driver'][driver_name] - logging.debug(new_name) + current_name = matches['by-driver'][driver_name] + logging.debug(current_name) logging.debug(interface) - if new_name != interface: - changes.update({interface: {'name': new_name}}) + if current_name != interface: + changes.update({interface: {'name': newname}}) if macaddress in matches['by-mac']: - new_name = matches['by-mac'][macaddress] - if new_name != interface: - changes.update({interface: {'name': new_name}}) + current_name = matches['by-mac'][macaddress] + if current_name != interface: + changes.update({interface: {'name': newname}})
logging.debug(changes) return changes
After applying the patch, it's working both on reboot and on netplan apply, with the interface down, of course.
After some debugging, I could make it work... I'm not a programmer, so it might be wrong, but it's working:
root@netplan:~# cat fix-bug-1770082.diff cli/commands/ apply.py cli/commands/ apply.py ifaddresses( interface) [netifaces. AF_LINK] [0]
macaddres s = link.get('addr') 'by-driver' ]: 'by-driver' ][driver_ name] debug(new_ name) 'by-driver' ][driver_ name] debug(current_ name)
logging. debug(interface ) update( {interface: {'name': new_name}}) update( {interface: {'name': newname}}) 'by-mac' ][macaddress] update( {interface: {'name': new_name}}) 'by-mac' ][macaddress] update( {interface: {'name': newname}})
--- a/netplan/
+++ b/netplan/
@@ -170,15 +170,15 @@
link = netifaces.
if driver_name in matches[
- new_name = matches[
- logging.
+ current_name = matches[
+ logging.
- if new_name != interface:
- changes.
+ if current_name != interface:
+ changes.
if macaddress in matches['by-mac']:
- new_name = matches[
- if new_name != interface:
- changes.
+ current_name = matches[
+ if current_name != interface:
+ changes.
return changes
After applying the patch, it's working both on reboot and on netplan apply, with the interface down, of course.