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
|
# this describes test on precise (cobbler)
# launch instance of precise image
# ubuntu-precise-12.04-amd64-server-20120822.manifest.xml
#
# ssh in like
# ssh 10.55.60.113 -L 10080:localhost:80
[ "$(dpkg --print-architecture)" = "amd64" ] &&
{ sudo dpkg --remove-architecture i386 || sudo rm -f /etc/dpkg/dpkg.cfg.d/multiarch; }
mkdir -p ~/bin
BRIDGE="maasbr0"
MAAS_GW="192.168.77.1"
MAAS_NM="255.255.255.0"
MAAS_BC="192.168.77.255"
MAAS_RANGE="192.168.77.5,192.168.77.200"
MAAS_DHCP_INT="$BRIDGE"
MAAS_NEXT_SERVER="$MAAS_GW"
sudo apt-get update -q
sudo apt-get install libvirt-bin --assume-yes </dev/null
sudo adduser $(id -u --name) libvirtd
## on 12.04, dnsmasq is our dns and dhcp server
cat > libvirt-$BRIDGE.xml <<EOF
<network>
<name>$BRIDGE</name>
<forward mode='nat'/>
<bridge name='$BRIDGE' stp='off' delay='0' />
<dns>
<host ip='$MAAS_GW'>
<hostname>maas-system</hostname>
</host>
</dns>
<ip address='$MAAS_GW' netmask='$MAAS_NM'>
<dhcp>
<range start='${MAAS_RANGE%,*}' end='${MAAS_RANGE#*,}' />
<bootp server="${MAAS_NEXT_SERVER}" file="pxelinux.0" />
</dhcp>
</ip>
</network>
EOF
sg libvirtd -c "virsh -c qemu:///system net-define libvirt-$BRIDGE.xml"
sg libvirtd -c "virsh -c qemu:///system net-autostart $BRIDGE"
sg libvirtd -c "virsh -c qemu:///system net-start $BRIDGE"
pkgs="qemu-kvm linux-image-extra-virtual uml-utilities maas lxc"
( sudo apt-get update &&
sudo apt-get --assume-yes dist-upgrade &&
sudo DEBIAN_FRONTEND=noninteractive \
apt-get --assume-yes install $pkgs ) </dev/null
sudo adduser $(id -u --name) kvm
# use /mnt as a place for kvm images, it likely has space.
sudo chown $(id -u):$(id -g) -R /mnt
mkdir -p ~/bin/
xkvm_url="http://smoser.brickies.net/git/?p=tildabin.git;a=blob_plain;f=xkvm;hb=HEAD"
wget "${xkvm_url}" -O ~/bin/xkvm && chmod 755 ~/bin/xkvm
# put kernel output to serial console
# we do this to avoid the install going into graphics mode
# so it can be seen on the serial console
echo 'KOPTS="priority=critical locale=en_US netcfg/choose_interface=auto nobootsplash nomodeswitch verbose console=ttyS0"' | sudo tee -a /etc/maas/import_isos
# use the 'daily' stream of ephemeral images (thats what we're testing)
echo "STREAM=daily" | sudo tee -a /etc/maas/import_ephemerals
sudo maas createadmin --username=ubuntu --password=ubuntu \
--email=ubuntu@example.com
sudo maas-import-isos
sudo reboot
# xkvm now should function to easily put instances on the network where maas is
# listening to dhcp and dns.
# to boot a node with MAC 52:54:00:12:34:01 (change '01' to '02' to differ).
# then run:
qemu-img create -f qcow2 system-01.img 8G
xkvm --netdev maasbr0,macaddr=:01 -- \
-drive file=system-01.img,if=virtio -curses
# that will enlist, then
# go to http://localhost:10080/MAAS/nodes/ (or valid url see 'ssh -L' above)
#
|