From: Dermot Bradley Date: Thu, 15 Oct 2020 00:17 +0100 Subject: [PATCH] cloud-init: Make wakeonlan setting actually work The "wakeonlan" option in cloud-init Network Config v2 YAML files did not actually do anything on Linux systems using /etc/network/interfaces files (i.e. Alpine and Debian). This patch ensures that when "wakeonlan: true" is present in a Network Config v2 YAML file that the equivalent entry will be written to /e/n/i. This change has already been submitted upstream as PR #626, therefore this patch can be (hopefully) removed upon the next upstream release. --- diff -aur a/cloudinit/net/eni.py b/cloudinit/net/eni.py --- a/cloudinit/net/eni.py +++ b/cloudinit/net/eni.py @@ -401,6 +401,10 @@ sections = [] subnets = iface.get('subnets', {}) accept_ra = iface.pop('accept-ra', None) + ethernet_wol = iface.pop('wakeonlan', None) + if ethernet_wol is not None: + # Specify WOL setting 'g' for using "Magic Packet" + iface['ethernet-wol'] = 'g' if subnets: for index, subnet in enumerate(subnets): ipv4_subnet_mtu = None diff -aur a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py --- a/cloudinit/net/network_state.py +++ b/cloudinit/net/network_state.py @@ -369,6 +369,9 @@ accept_ra = command.get('accept-ra', None) if accept_ra is not None: accept_ra = util.is_true(accept_ra) + wakeonlan = command.get('wakeonlan', None) + if wakeonlan is not None: + wakeonlan = util.is_true(wakeonlan) iface.update({ 'name': command.get('name'), 'type': command.get('type'), @@ -379,7 +382,8 @@ 'address': None, 'gateway': None, 'subnets': subnets, - 'accept-ra': accept_ra + 'accept-ra': accept_ra, + 'wakeonlan': wakeonlan }) self._network_state['interfaces'].update({command.get('name'): iface}) self.dump_network_state()