Merge lp:~rcj/vmbuilder/jenkins_jvm-maasv3 into lp:~ubuntu-on-ec2/vmbuilder/jenkins_kvm

Proposed by Robert C Jennings
Status: Merged
Merged at revision: 765
Proposed branch: lp:~rcj/vmbuilder/jenkins_jvm-maasv3
Merge into: lp:~ubuntu-on-ec2/vmbuilder/jenkins_kvm
Diff against target: 175 lines (+161/-0)
3 files modified
config/cloud-maasv3.cfg (+10/-0)
jenkins/MAASv3_Builder.sh (+66/-0)
templates/img-maasv3.tmpl (+85/-0)
To merge this branch: bzr merge lp:~rcj/vmbuilder/jenkins_jvm-maasv3
Reviewer Review Type Date Requested Status
Dan Watkins (community) Approve
Review via email: mp+307591@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Dan Watkins (oddbloke) :
review: Approve
Revision history for this message
Dan Watkins (oddbloke) wrote :

Merging now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'config/cloud-maasv3.cfg'
2--- config/cloud-maasv3.cfg 1970-01-01 00:00:00 +0000
3+++ config/cloud-maasv3.cfg 2016-10-04 15:31:01 +0000
4@@ -0,0 +1,10 @@
5+#cloud-config
6+#This is generic enough to build for both MAAS and general cloud images
7+package_upgrade: true
8+password: ubuntu
9+packages:
10+- bzr
11+- qemu-utils
12+- zerofree
13+- gdisk
14+- proot
15
16=== added file 'jenkins/MAASv3_Builder.sh'
17--- jenkins/MAASv3_Builder.sh 1970-01-01 00:00:00 +0000
18+++ jenkins/MAASv3_Builder.sh 2016-10-04 15:31:01 +0000
19@@ -0,0 +1,66 @@
20+#!/bin/bash -x
21+
22+fail() { [ $# -eq 0 ] || echo "$@"; exit 1; }
23+
24+[ -z "${SERIAL}" -a -z "${SUITE}" -a -e "build_properties" ] && {
25+ source build_properties ||
26+ fail "Failed to read build_properties.";
27+}
28+
29+# Read in the common functions
30+my_dir="$( cd "$( dirname "$0" )" && pwd )"
31+base_dir=$(dirname ${my_dir})
32+export PATH="${base_dir}:${my_dir}:${PATH}"
33+source "${base_dir}/functions/locker"
34+source "${base_dir}/functions/common"
35+source "${base_dir}/functions/retry"
36+source ${my_dir}/build_lib.sh
37+select_build_config
38+
39+case "${STREAM:?}" in
40+ daily) build_f="/srv/ec2-images/${SUITE}/${SERIAL}";
41+ base_name="${SUITE}-server-cloudimg"
42+ ;;
43+ *) fail "Unknown/unsupported stream ${STREAM}.";;
44+esac
45+
46+out_f="${WORKSPACE:?}/maas-${SUITE}-${STREAM}-config.sh"
47+raw_f="${WORKSPACE}/${SUITE}-output.raw"
48+
49+export maas_branch="${MAAS_BRANCH:?}"
50+
51+touch ${WORKSPACE}/maasv3
52+tar cvf ${query_t} ${WORKSPACE}/maasv3
53+
54+# Construct the right template
55+maas_config.sh \
56+ --distro "${SUITE}" \
57+ --stream "${STREAM}" \
58+ --template "${kvm_builder}/templates/img-maasv3.tmpl" \
59+ --base-name "${base_name}" \
60+ --local "${build_f}" \
61+ --serial "${SERIAL}" \
62+ --out "${out_f}" \
63+ --maas-branch "${maas_branch}" \
64+ --out_d "/tmp/maas_final" ||
65+ fail "Failed to configure KVM instance for building"
66+
67+ci_cfg="${kvm_builder}/config/cloud-maasv3.cfg"
68+[ "$(uname -m)" == "ppc64" ] && ci_cfg="${kvm_builder}/config/cloud-trusty-pp64el.cfg"
69+
70+# Launch KVM to do the work
71+launch_kvm.sh \
72+ --id ${BUILD_ID} \
73+ --user-data "${out_f}" \
74+ --cloud-config "${ci_cfg}" \
75+ --extra-disk "${query_t}" \
76+ --disk-gb 50 \
77+ --raw-disk "${raw_f}" \
78+ --raw-size 20 \
79+ --mem 1G \
80+ --img-url ${BUILDER_CLOUD_IMAGE} ||
81+ fail "KVM instance failed to build image."
82+
83+# Extract the result set
84+tar -xvvf "${raw_f}" ||
85+ fail "Failed to extract information from instance"
86
87=== added file 'templates/img-maasv3.tmpl'
88--- templates/img-maasv3.tmpl 1970-01-01 00:00:00 +0000
89+++ templates/img-maasv3.tmpl 2016-10-04 15:31:01 +0000
90@@ -0,0 +1,85 @@
91+#!/bin/bash
92+# vi: ts=4 noexpandtab syntax=sh
93+# Setup up the build environment.
94+exec > >(tee /tmp/build.log) 2>&1
95+echo "127.0.1.1 $HOSTNAME $HOSTNAME" >> /etc/hosts
96+error() { echo "$@" 1>&2; }
97+fail() {
98+ [ $# -eq 0 ] || error "$@";
99+ echo "Failed" > /tmp/failed;
100+ tar -C /tmp -cvf /dev/vdb failed build.log;
101+ shutdown -P now;
102+ exit 1;
103+}
104+
105+debug() { error "$(date -R):" "$@"; }
106+sysfail() { fail "General failure!"; }
107+
108+trap sysfail SIGINT SIGTERM
109+
110+# Variables from configuration step
111+PACK_D="%D"
112+BZR_MAAS="%M"
113+suite="%d"
114+stream="%S"
115+serial="%s"
116+
117+# Set up the stuff
118+export SRC_D="/tmp/maas"
119+export START_D="/tmp/logs"
120+export OUT_D="%O"
121+
122+# Make sure that the root disk is big enough
123+# Work around for https://bugs.launchpad.net/ubuntu/+source/cloud-utils/+bug/1285197
124+sudo cloud-init single --name growpart --frequency=always &&
125+ sudo cloud-init single --name=resizefs --frequency=always
126+df -h
127+
128+
129+# Set up the code paths
130+cd /tmp
131+bzr branch "${BZR_MAAS}" "${SRC_D}" ||
132+ fail "Failed to check out the BZR branch"
133+
134+bash -x "${SRC_D}/system-setup";
135+OUT_D="/tmp/maas_final"
136+mkdir -p "${OUT_D}"
137+
138+# Extract /dev/vdc (which has all the goodies including the image
139+# for conversion)
140+tar -C / -xvvf /dev/vdd
141+
142+# Make the dirs
143+mkdir /tmp/maas_images
144+mkdir "${START_D}"
145+
146+
147+# Do the work
148+ARCHES="%A"
149+ARCHES=${ARCHES:-i386 amd64 armhf}
150+
151+debug "building maas ephemerals v3 suite=$suite arches=[${ARCHES}]"
152+for arch in ${ARCHES}; do
153+ prefix="${suite}-${stream}-maas-${arch}"
154+ work_d="${OUT_D}/${arch}"
155+ mkdir -p "${work_d}" ||
156+ fail "Unable to create destination directory for ${arch}"
157+
158+ debug "beginning arch $arch"
159+ env PYTHONPATH=${SRC_D} \
160+ PATH=${SRC_D}/bin:$PATH \
161+ "${SRC_D}/bin/meph2-cloudimg-sync" \
162+ --config ${SRC_D}/conf/meph-v3.yaml \
163+ "-vvv" "${OUT_D}" \
164+ "arch=${arch}" "release=${suite}" || fail "Failed to create MAAS image"
165+
166+done
167+
168+# Finish the work
169+echo "Taring up artifacts to /dev/vdb!"
170+touch /tmp/success
171+tar -C /tmp -cvf /dev/vdb maas_images /var/log/* logs success build.log "${OUT_D}" >> /dev/null
172+sync
173+shutdown -P now
174+
175+# vi: ts=4 noexpandtab syntax=sh

Subscribers

People subscribed via source and target branches