Here at Cloudbase, we use a lot of Intel Next Unit of Computing (NUC) for our internal testing and development work. The NUC is a small form factor computer, designed and manufactured by Intel, very compact and powerful, sporting a Haswell i5 processor, up to 16 GB of RAM and a mSATA SSD.
You can see our NUC tempest testing rig in action here.
What those NUCs are lacking (except for a single older model, as of today) is the ability to power them on and off remotely, like higher grade servers do with technologies like IPMI, AMT, iLO. Unfortunately, the NUCs don’t have any of those, so we invented our own to have some fun. 🙂
Lego to the rescue
Since we had a lot of Lego just lying around, we though, why not building a Lego Mindstorms robot to remotely push the NUC power button?
After a bunch of prototypes, we came out with this:
We call it reBot
Our first implementation of reBot was for Ubuntu Metal as a Service (MAAS). MAAS is the bare-metal deployment service for Ubuntu, which spins physical machines up just like virtual machines in OpenStack. I won’t go into the details of how MAAS & Juju work, but you can read more about our Windows implementation here.
Right now we also have a working proof-of-concept power adapter for OpenStack Ironic.
This is how a 4-node reBot MAAS setup is deploying a full OpenStack bare-metal cloud, all unattended:
Software
The Mindstorms EV3 brick runs a custom firmware, called leJos which provides some remote control abilities via Java RMI (ok, it ain’t Python, but we can live with it :-)). We connected it to the MAAS controller (the sitting on top of the switches in the picture) via an ethernet-over-USB connection.
Here are some of the motor actions that we wrote for pushing the lever up/down and reset the NUC. Here is an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import lejos.remote.ev3.*; import lejos.utility.Delay; class BarePlasticAction { public static void main(String[] args) { if(args.length != 4) { System.out.println("usage: BarePlasticAction <EV3 address> <A|B|C|D> <degrees> <pause>"); System.exit(1); } String host = args[0]; String port = args[1]; int degrees = Integer.parseInt(args[2]); int pause = Integer.parseInt(args[3]); RMIRegulatedMotor m = null; try { RemoteEV3 ev3 = new RemoteEV3(host); m = ev3.createRegulatedMotor(port, 'L'); m.setAcceleration(6000); float speed = m.getMaxSpeed(); m.setSpeed((int)speed); m.rotateTo(degrees); if (pause >= 0) { Delay.msDelay(pause); m.rotateTo(0); } } catch(Exception ex) { ex.printStackTrace(); } finally { if (m != null) { try { m.close(); } catch(Exception ex) { // ignore } } } } } |
All we needed to do at this point was to call it from MAAS, specifying the EV3 port, degrees of rotation and time to keep the power button pushed down (de facto simulating what you’d do with your finger when resetting a PC).
Power on:
1 |
java -cp ../ev3classes.jar:.. BarePlasticAction 10.0.1.1 B 1440 1500 |
Power off:
1 |
java -cp ../ev3classes.jar:.. BarePlasticAction 10.0.1.1 B 1440 5000 |
And this is how the MAAS configuration page looks like:
The code and Lego model are available as open source on GitHub, so go ahead and build your own, or even improve on the design:
https://github.com/cloudbase/reBot
here’s also a handy bill of materials with all the required Lego parts.
A quick question: are you using a single Gigabit Ethernet controller or do you add in a mini PCIe card to go dual NIC?
We are using USB 3.0 dual port gigabit adapters, just like this one http://www.startech.com/Networking-IO/Adapter-Cards/USB-3-to-Dual-Port-Gigabit-Ethernet-Adapter-NIC-with-USB-Port~USB32000SPT
Do the NUC units have a “boot on power restore” BIOS option so that you could use one of these for iLO?
http://www.amazon.com/IP-Power-9258T-Network-Controller/dp/B005D55HKU