~racb/junk/pandakit

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
What this does:

 - Simple command line interface to control and automatically provision bare
   metal on demand. This is intended for developers and for automated testing,
   not for production or long-lived metal instances.

Still in progress (not complete):

 - USB boot support.

 - Right now, scripts assume that they are all in PATH and also that all files
   are in the correct directory. This speeded up development, but I intend to
   fix it eventually.

Prerequisites:

 - One or more Pandaboards. (Eventually I'd like this tool to support other
   forms of bare metal too, and become a generic push-based bare metal
   bootstrapping service).
 
 - A bootstrapping machine to manage the Pandaboards. This machine needs to
   have mechanism to read the Pandaboards' serial ports in real time.
 
 - Optional: if the bootstrapping machine can control the Pandaboards' power,
   this tool can use this facility.
 
 - Optional: if the bootstrapping machine is hooked up to the Pandaboards' USB
   gadget ports, this tool can boot them over USB (to prevent "bricking" until
   a human has swapped SD cards manually). This is work in progress. Note that
   at the moment USB booting is only capable of kicking off a pxelinux
   emulation boot, so a network boot is still required.

Notes:

 - This tool currently depends on cobbler. In the short term, it made sense
   just to wrap cobbler. In the long term, I'd like to get rid of this
   dependency, since I'm barely using any of cobbler's real functionality and I
   feel like I'm abusing it by using it in the obtuse manner needed to make it
   go in a push-based sense.

Installation:

 - For USB booting, if your machine is not ARM, add a line such as:

   deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports precise main universe

   to your /etc/apt/sources.list. This allows the installation of an ARM
   bootloader binary blob to your non-ARM machine for feeding to the
   Pandaboards over USB.
 
 - Install this package and its dependencies on your bootstrap server.

 - Name your Pandaboards. These will correspond to their default hostnames when
   they are in use.

 - Set up a DHCP server somewhere which provides "next-server" entries of your
   bootstrap server to your Pandaboards.

 - Set up a mechanism to read the Pandaboards' serial output in real time. I
   use the conserver-server together with "ttyusb-socat" in this package, and
   can provide examples.  Adding support for other mechanisms should be easy
   providing that you can provide a Unix program that will be called with the
   Pandaboard's name, produces the serial output on stdout in real time, and
   terminates on SIGINT/SIGTERM.
 
 - (Optional) Set up a mechanism to control the Pandaboards' power. I have only
   written support for my kmtronic relay system, but adding support for other
   mechanisms should be easy if you can provide a Unix program that can just
   turn on and off a Pandaboard by name on demand. If you do not have an
   automated power facility, you will just prompted to perform a manual power
   switch when needed.
 
 - Edit local_setup.yaml to define what Pandaboards you have, their IP and MAC
   addresses, what you're using for console access and power control, and
   parameters for console access and power control as required (eg. where each
   Pandaboard's USB serial console is on your USB bus in order to tell them
   apart, where your relay board is on the USB bus, which relay is connected to
   which Pandaboard, etc).
 
 - Edit ~/.ssh/config to allow shelling in to each Panda by name (this tool
   relies on these mappings existing).
 
Use:

 - pk is the tool I want to wrap everything into for the moment.

 - "pk install <hostname>" to install a Pandaboard with a precise armhf
   preseed, boot it, and sort out your ssh key. When this command returns with
   a zero exit status, the machine is available and you can ssh into it
   immediately.
 
 - "pk install <hostname> oneiric armel" for oneiric instead.

 - "pk install" also accepts overrides such as --preseed=..., --kernel=...,
   --initrd=... --kopts=...
 
 - "pk console <hostname>" to watch the real time serial console of a machine.

 - "pk power on|off|reset <hostname> [<hostname>...]" for direct power control.

 - "pk netboot <hostname>" to attempt to shell in and write a netboot
   configuration to your SD card. This is done automatically by "pk install" if
   you're not using USB boot. But this is not reliable - if your Pandaboard is
   not turned on or does not have ssh set up (or is otherwise bricked), then
   this tool will be unable to switch it back to netboot mode if you are not
   using USB boot.