Using Wake on LAN with MAAS 2.x


I maintain a number of development systems that are used as throw away machines to reproduce LXC and LXD bugs by the upstream developers. I use MAAS to track who’s using what and to have the machines deployed with whatever version of Ubuntu or Centos is needed to reproduce a given bug.

A number of those systems are proper servers with hardware BMCs on a management network that MAAS can drive using IPMI. Another set of systems are virtual machines that MAAS drives through libvirt.

But I’ve long had another system I wanted to get in there. That machine is a desktop computer but with a server grade SAS controller and internal and external arrays. That machine also has a Fiber Channel HBA and Infiniband card for even less common setups.

The trouble is that this being a desktop computer, it’s lacking any kind of remote management that MAAS supports. That machine does however have a good PCIe network card which provides reliable wake-on-lan.

Back in the days (MAAS 1.x), there was a wake-on-lan power type that would have covered my use case. This feature was however removed from MAAS 2.x (see LP: #1589140) and the development team suggests that users who want the old wake-on-lan feature, instead install Ubuntu 14.04 and the old MAAS 1.x branch.

Implementing Wake on LAN in MAAS 2.x

I am, however not particularly willing to install an old Ubuntu release and an old version of MAAS just for that one trivial feature, so I instead spent a bit of time to just implement the bits I needed and keep a patch around to be re-applied whenever MAAS changes.

MAAS doesn’t provide a plugin system for power types, so I unfortunately couldn’t just write a plugin and distribute that as an unofficial power type for those who need WOL. I instead had to resort to modifying MAAS directly to add the extra power type.

The code change needed to re-implement a wake-on-lan power type is pretty simple and only took me a few minutes to sort out. The patch can be found here:

To apply it to your MAAS, do:

sudo apt install wakeonlan
sudo patch -p1 -d /usr/lib/python3/dist-packages/provisioningserver/ < maas-wakeonlan.diff
sudo systemctl restart maas-rackd.service maas-regiond.service

Once done, you’ll now see this in the web UI:

After selecting the new “Wake on LAN” power type, enter the MAC address of the network interface that you have WOL enabled on and save the change.

MAAS will then be able to turn the system on, allowing for the normal commissioning and deployment stages. For everything else, this power type behaves like the “Manual” type, asking the user to manually go shutdown or reboot the system as you can’t do that through Wake on LAN.

Note that you’ll have to re-apply part of the patch whenever MAAS is updated. The patch modifies two files and adds a new one. The new file won’t be removed during an upgrade, but the two modified files will get reverted and need patching again.


This is certainly a hack and if your system supports anything better than Wake on LAN, or you’re willing to buy a supported PDU just for that one system, then you should do that instead.

But if the inability to turn a system on is all that stands in your way from adding it to your MAAS, as was the case for me, then that patch may help you.

I hope that in time MAAS will either get that feature back in some way or get a plugin system that I can use to ship that extra power type in its own separate package without needing to alter any of MAAS’ own files.

This entry was posted in Canonical voices, Planet Ubuntu and tagged . Bookmark the permalink.

8 Responses to Using Wake on LAN with MAAS 2.x

  1. Lee Lo says:

    Never thought about this! Never needed but I will keep an eye on it!

  2. kazuki says:

    This is just what I’m looking for!
    but this link is broken…

  3. Keith says:

    Thanks for this post and the others. I have found a lot of useful information that has helped me solve some of the issues I’ve ran into with Juju, MAAS, and Openstack. Wake on LAN was a feature missing in 16.04 that led to many frustrating situations with testing and development. Not any more!

  4. tx4 says:

    Thanks a lot! I’m trying to make it work at 2.2.1, but i dont found a file, any idea where can i touch to put on it?

  5. Deepa says:

    $ sudo patch -p1 -d /usr/lib/python3/dist-packages/provisioningserver/ < maas-wakeonlan.diff

    patching file drivers/power/
    Hunk #1 FAILED at 353.
    Hunk #2 FAILED at 371.
    2 out of 2 hunks FAILED — saving rejects to file drivers/power/
    patching file drivers/power/
    can't find file to patch at input line 85
    Perhaps you used the wrong -p or –strip option?
    The text leading up to this was:
    |diff -Nrup /usr/lib/python3/dist-packages/provisioningserver/power/ provisioningserver/power/
    |— /usr/lib/python3/dist-packages/provisioningserver/power/ 2016-12-21 12:56:19.000000000 +0000
    |+++ provisioningserver/power/ 2017-04-02 19:01:59.001823063 +0000
    File to patch: <<<<<<<<<<<< Which file should we give here
    Skip this patch? [y]
    Skipping patch.
    1 out of 1 hunk ignored

  6. yosefrow says:

    This did not work for me, however i was able to create a solution based on Kairen’s patch

  7. Elvis says:

    Mr Graber,
    I had a similar problem using several zotac computers, the intel servers came with IPMI which is great but the cheap computers only support WOL. After MAAS 2.x I lost the WOL and had to figure out something else, what I did was installing wakeonlan package on ubuntu to start them form bash while connected to the lxd container running mass but I encountered another problem when the nodes froze (the os crashed), there was no way for me to turn them off remotely then on. What I did to resolve the problem was to update the bios and set a parameter to start the computer on power loss/restore, then spent 9 bucks on relays on amazon

    And finally purchase a pi zero

    To open the circuit when the computers froze with a small python script that I can run form the pi which is exposed on the local network that I can reach over the VPN.

    I was also thinking about playing around to let mass control the pi to do everything from the maas interface.

Leave a Reply

Your email address will not be published. Required fields are marked *