Merge lp:~rodsmith/maas-cert-server/autoconfig-virt-images into lp:~hardware-certification/maas-cert-server/trunk

Proposed by Rod Smith
Status: Merged
Approved by: Jeff Lane 
Approved revision: 72
Merged at revision: 72
Proposed branch: lp:~rodsmith/maas-cert-server/autoconfig-virt-images
Merge into: lp:~hardware-certification/maas-cert-server/trunk
Diff against target: 109 lines (+55/-8)
3 files modified
debian/changelog (+5/-2)
preseed/curtin_userdata_cert (+25/-3)
preseed/curtin_userdata_custom_cert (+25/-3)
To merge this branch: bzr merge lp:~rodsmith/maas-cert-server/autoconfig-virt-images
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+312894@code.launchpad.net

Description of the change

This merge adds automatic configuration of virtualization images to /etc/xdg/canonical-certification.conf via MAAS curtin userdata files. Specifically:

- The node uses wget to see what images are available in the gateway's
  (assumed to be MAAS server's, as in other curtin userdata functions)
  web server's /cloud directory.
- If one or more images with a filename of the form
  ".*$DISTRIB_CODENAME-server-cloudimg-$arch.*img" exists, the first of
  these is set in the conf file.
- If such an image does not exist, but image(s) of the form
  ".*server-cloudimg-$arch.*img" exists, the last of these is set in
  the conf file. (Presumably the last one will be the most recent
  Ubuntu version.)

To post a comment you must log in.
Revision history for this message
Jeff Lane  (bladernr) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-12-08 11:03:51 +0000
3+++ debian/changelog 2016-12-09 09:45:43 +0000
4@@ -1,8 +1,11 @@
5-maas-cert-server (0.2.28-0ppa1) UNRELEASED; urgency=medium
6+maas-cert-server (0.2.28-0ppa1) xenial; urgency=medium
7
8+ * Add feature to curtin preseed scripts to find KVM images on MAAS
9+ server and set /etc/xdg/canonical-certification.conf to refer to
10+ the best found image, if possible.
11 * Minor changes to maniacs-setup to improve prompt formatting.
12
13- -- Rod Smith <rod.smith@canonical.com> Thu, 08 Dec 2016 11:56:45 +0100
14+ -- Rod Smith <rod.smith@canonical.com> Fri, 09 Dec 2016 10:14:21 +0100
15
16 maas-cert-server (0.2.27-0ppa1) xenial; urgency=medium
17
18
19=== modified file 'preseed/curtin_userdata_cert'
20--- preseed/curtin_userdata_cert 2016-11-18 16:35:19 +0000
21+++ preseed/curtin_userdata_cert 2016-12-09 09:45:43 +0000
22@@ -66,6 +66,27 @@
23 sleep 60;
24 echo "Done.";
25
26+ - &kvm_image |
27+ #!/bin/sh
28+ echo "Setting up to use KVM image on MAAS server...";
29+ . /etc/lsb-release;
30+ arch=$(dpkg --print-architecture);
31+ maas_ip=$(/sbin/ip route | awk '/default/ { print $3 }');
32+ rm -rf /tmp/index.html;
33+ wget -P /tmp/ http://$maas_ip/cloud/;
34+ filename_line=$(egrep "$DISTRIB_CODENAME-server-cloudimg-$arch.*img" /tmp/index.html | head -n 1);
35+ if [ ! -z "$filename_line" ] ; then
36+ filename=$(echo $filename_line | grep -Po '(?<=href=")[^"]*(?=")');
37+ else
38+ filename_line=$(egrep "server-cloudimg-$arch.*img" /tmp/index.html | head -n 1);
39+ filename=$(echo $filename_line | grep -Po '(?<=href=")[^"]*(?=")');
40+ fi
41+ if [ ! -z "$filename" ] ; then
42+ sed -i "s/#KVM_TIMEOUT/KVM_TIMEOUT/g" /etc/xdg/canonical-certification.conf;
43+ sed -i "s/#KVM_IMAGE = \/path\/to\/cloudimage-filename.img/KVM_IMAGE = http:\/\/$maas_ip\/cloud\/$filename/g" /etc/xdg/canonical-certification.conf;
44+ fi;
45+ rm -f /tmp/index.html;
46+
47 - &iperf
48 #!/bin/sh
49 echo "Setting up iperf...";
50@@ -114,9 +135,10 @@
51 # inject maas version into /etc/installed-with-maas and install cert tools
52 set_maas_version: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo {{maas_version}} > /etc/installed-by-maas"]
53 # Install certification suite
54- zu_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *disableupdates ]
55- zv_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *sudoers ]
56- zw_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *installcert ]
57+ zt_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *disableupdates ]
58+ zu_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *sudoers ]
59+ zv_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *installcert ]
60+ zw_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *kvm_image ]
61 zx_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *iperf ]
62 zy_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *setubuntupass]
63 zz_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *secureid]
64
65=== modified file 'preseed/curtin_userdata_custom_cert'
66--- preseed/curtin_userdata_custom_cert 2016-11-18 16:35:19 +0000
67+++ preseed/curtin_userdata_custom_cert 2016-12-09 09:45:43 +0000
68@@ -66,6 +66,27 @@
69 sleep 60;
70 echo "Done.";
71
72+ - &kvm_image |
73+ #!/bin/sh
74+ echo "Setting up to use KVM image on MAAS server...";
75+ . /etc/lsb-release;
76+ arch=$(dpkg --print-architecture);
77+ maas_ip=$(/sbin/ip route | awk '/default/ { print $3 }');
78+ rm -rf /tmp/index.html;
79+ wget -P /tmp/ http://$maas_ip/cloud/;
80+ filename_line=$(egrep "$DISTRIB_CODENAME-server-cloudimg-$arch.*img" /tmp/index.html | head -n 1);
81+ if [ ! -z "$filename_line" ] ; then
82+ filename=$(echo $filename_line | grep -Po '(?<=href=")[^"]*(?=")');
83+ else
84+ filename_line=$(egrep "server-cloudimg-$arch.*img" /tmp/index.html | tail -n 1);
85+ filename=$(echo $filename_line | grep -Po '(?<=href=")[^"]*(?=")');
86+ fi
87+ if [ ! -z "$filename" ] ; then
88+ sed -i "s/#KVM_TIMEOUT/KVM_TIMEOUT/g" /etc/xdg/canonical-certification.conf;
89+ sed -i "s/#KVM_IMAGE = \/path\/to\/cloudimage-filename.img/KVM_IMAGE = http:\/\/$maas_ip\/cloud\/$filename/g" /etc/xdg/canonical-certification.conf;
90+ fi;
91+ rm -f /tmp/index.html;
92+
93 - &iperf
94 #!/bin/sh
95 echo "Setting up iperf...";
96@@ -136,9 +157,10 @@
97 # inject maas version into /etc/installed-with-maas and install cert tools
98 set_maas_version: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo {{maas_version}} > /etc/installed-by-maas"]
99 # Install certification suite
100- zt_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *disableupdates ]
101- zu_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *sudoers ]
102- zv_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *installcert ]
103+ zs_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *disableupdates ]
104+ zt_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *sudoers ]
105+ zu_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *installcert ]
106+ zv_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *kvm_image ]
107 zw_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *iperf ]
108 zx_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *networkinterfaces]
109 zy_cert_install: ['curtin', 'in-target', '--', 'sh', '-c', *secureid]

Subscribers

People subscribed via source and target branches

to status/vote changes: