3
from subprocess import check_output
4
from shlex import split
6
cache_output = check_output(['apt-cache', 'policy', 'maas']).decode('utf-8')
7
for line in cache_output.splitlines():
9
if ':' in line and line.split(':')[0] == 'Installed':
10
maas_version = line.split(':')[1].strip()
13
f = open('/etc/maas-cert-server/iperf.conf', 'r')
14
test_target_iperf = f.readline().rstrip()
17
test_target_iperf = "gateway"
22
{{for line in str(curtin_preseed).splitlines()}}
25
{{if third_party_drivers and driver}}
27
{{py: key_string = ''.join(['\\x%x' % x for x in map(ord, driver['key_binary'])])}}
28
driver_00_get_key: /bin/echo -en '{{key_string}}' > /tmp/maas-{{driver['package']}}.gpg
29
driver_01_add_key: ["apt-key", "add", "/tmp/maas-{{driver['package']}}.gpg"]
30
driver_02_add: ["add-apt-repository", "-y", "deb {{driver['repository']}} {{node.get_distro_series()}} main"]
31
driver_03_update_install: ["sh", "-c", "apt-get update --quiet && apt-get --assume-yes install {{driver['package']}}"]
32
driver_04_load: ["sh", "-c", "depmod && modprobe {{driver['module']}}"]
38
echo "Setting up sudoers...";
39
echo "ubuntu ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/maas ; chmod 0440 /etc/sudoers.d/maas;
44
echo "Installing certfication tools...";
45
echo " Add cert source list...";
47
if [ -z "`grep DISTRIB_DESCRIPTION /etc/lsb-release | grep development`" ] ; then
48
echo deb http://ppa.launchpad.net/hardware-certification/public/ubuntu $DISTRIB_CODENAME main >> /etc/apt/sources.list.d/certification.list;
50
echo deb http://ppa.launchpad.net/checkbox-dev/ppa/ubuntu $DISTRIB_CODENAME main >> /etc/apt/sources.list.d/certification.list;
52
echo deb http://ppa.launchpad.net/firmware-testing-team/ppa-fwts-stable/ubuntu $DISTRIB_CODENAME main >> /etc/apt/sources.list.d/certification.list;
53
echo " Getting GPG Keys...";
54
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 1FEADE10;
55
echo " Running apt-get update...";
57
echo " Installing checkbox certification...";
58
apt-get install -y --force-yes canonical-certification-server;
60
maas_ip=$(/sbin/ip route | awk '/default/ { print $3 }');
61
wget -nc -P /usr/bin http://$maas_ip/canonical-certification-precheck;
62
chmod a+x /usr/bin/canonical-certification-precheck;
67
echo "Setting up iperf...";
68
/bin/sed -i '/^#TEST_TARGET_FTP /s/^#//' /etc/xdg/canonical-certification.conf;
69
/bin/sed -i '/^#TEST_USER /s/^#//' /etc/xdg/canonical-certification.conf;
70
/bin/sed -i '/^#TEST_PASS /s/^#//' /etc/xdg/canonical-certification.conf;
71
/bin/sed -i '/^#TEST_TARGET_IPERF /s/^#//' /etc/xdg/canonical-certification.conf;
72
if [ "{{test_target_iperf}}" = "gateway" ] ; then
73
maas_ip=$(/sbin/ip route | awk '/default/ { print $3 }');
74
sed -i 's/ your-iperf-server.example.com/'"$maas_ip"'/g' /etc/xdg/canonical-certification.conf;
76
sed -i 's/ your-iperf-server.example.com/{{test_target_iperf}}/g' /etc/xdg/canonical-certification.conf;
80
- &networkinterfaces |
82
echo "Setting all network interfaces to auto...";
83
echo $(ls -l /etc/network/interfaces);
84
echo "# This file created by maas-cert-server curtin preseed script" > /etc/network/interfaces;
85
echo "auto lo" >> /etc/network/interfaces;
86
echo "iface lo inet loopback\n" >> /etc/network/interfaces;
87
for i in `ls /sys/class/net|sort |grep -v -E '(lo|wlan)'`; do
88
if [ `cat /sys/class/net/$i/operstate` != "up" ] ; then
91
if [ `cat /sys/class/net/$i/operstate` != "up" ] ; then
92
echo "# $i available but inoperative; check its cabling and DHCP server!" >> /etc/network/interfaces ;
93
echo -n "#" >> /etc/network/interfaces ;
97
echo "auto $i" >> /etc/network/interfaces ;
98
echo "iface $i inet dhcp\n" >> /etc/network/interfaces ;
104
echo "Setting ubuntu password..."
105
echo "#cloud-config\nsystem_info:\n default_user:\n lock_passwd: False\n plain_text_passwd: 'ubuntu'" > /etc/cloud/cloud.cfg.d/ubuntu-user-defaults.cfg
109
maas: [wget, '--no-proxy', '{{node_disable_pxe_url|escape.shell}}', '--post-data', '{{node_disable_pxe_data|escape.shell}}', '-O', '/dev/null']
110
{{if third_party_drivers and driver}}
111
driver_00_key_get: curtin in-target -- sh -c "/bin/echo -en '{{key_string}}' > /tmp/maas-{{driver['package']}}.gpg"
112
driver_02_key_add: ["curtin", "in-target", "--", "apt-key", "add", "/tmp/maas-{{driver['package']}}.gpg"]
113
driver_03_add: ["curtin", "in-target", "--", "add-apt-repository", "-y", "deb {{driver['repository']}} {{node.get_distro_series()}} main"]
114
driver_04_update_install: ["curtin", "in-target", "--", "apt-get", "update", "--quiet"]
115
driver_05_install: ["curtin", "in-target", "--", "apt-get", "-y", "install", "{{driver['package']}}"]
116
driver_06_depmod: ["curtin", "in-target", "--", "depmod"]
117
driver_07_update_initramfs: ["curtin", "in-target", "--", "update-initramfs", "-u"]
119
# inject maas version into /etc/installed-with-maas and install cert tools
120
set_maas_version: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo {{maas_version}} > /etc/installed-by-maas"]
121
# Install certification suite
122
zv_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *sudoers ]
123
zw_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *installcert ]
124
zx_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *iperf ]
125
zy_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *networkinterfaces]
126
zz_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *setubuntupass]
132
{{if node.split_arch()[0] in {'i386', 'amd64'} }}
134
ubuntu_archive: http://{{main_archive_hostname}}/{{main_archive_directory}}
135
ubuntu_security: http://{{main_archive_hostname}}/{{main_archive_directory}}
138
ubuntu_archive: http://{{ports_archive_hostname}}/{{ports_archive_directory}}
139
ubuntu_security: http://{{ports_archive_hostname}}/{{ports_archive_directory}}
143
apt_proxy: {{http_proxy}}
145
apt_proxy: http://{{server_host}}:8000/