Merge lp:~adeuring/vmbuilder/jenkins_kvm-optionally-use-juju-test-packages into lp:~ubuntu-on-ec2/vmbuilder/jenkins_kvm

Proposed by Abel Deuring
Status: Merged
Merge reported by: Abel Deuring
Merged at revision: not available
Proposed branch: lp:~adeuring/vmbuilder/jenkins_kvm-optionally-use-juju-test-packages
Merge into: lp:~ubuntu-on-ec2/vmbuilder/jenkins_kvm
Diff against target: 172 lines (+60/-8)
5 files modified
build-juju-local.sh (+16/-1)
handle-xdeb.py (+15/-0)
launch_kvm.sh (+9/-3)
standalone.sh (+4/-2)
templates/img-juju.tmpl (+16/-2)
To merge this branch: bzr merge lp:~adeuring/vmbuilder/jenkins_kvm-optionally-use-juju-test-packages
Reviewer Review Type Date Requested Status
Abel Deuring (community) Needs Resubmitting
Ben Howard (community) Disapprove
Review via email: mp+229606@code.launchpad.net

Description of the change

The Juju QA team wants to build and test Vagrant boxes with debian packages that are regularily built by the team's CI infrastructure.

This branch adds two new environment variables, JUJU_CORE_PKG and JUJU_LOCAL_PKG. If they are defined, launch_kvm.sh adds the package files specificied by the variables to the cloud-init data and img-juju.tmpl installs them.

To post a comment you must log in.
Revision history for this message
Ben Howard (darkmuggle-deactivatedaccount) wrote :

I'm okay with changing launch_kvm, however, changes must be generic and not specific. launch_kvm is used to buid a variety of images.

review: Disapprove
455. By Abel Deuring

Pass optional could-init files to launch_kvm.sh and standalone.sh via command a line parameter; add these parameter in build-juju-local.sh when then env variables JUJU_CORE_PKG or JUJU_LOCAL_PKG are set.

Revision history for this message
Abel Deuring (adeuring) wrote :

> I'm okay with changing launch_kvm, however, changes must be generic and not
> specific. launch_kvm is used to buid a variety of images.

I've changed launch_kvm.sh and standalone.sh to accept accept another parameter, --cloud-init-file. The value(s) of this parameter is(are) passed to write-mime-multipart.

review: Needs Resubmitting
456. By Abel Deuring

standalone.sh: Prevent processing of --fetch_new consuming the next parameter.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build-juju-local.sh'
2--- build-juju-local.sh 2014-07-25 21:29:07 +0000
3+++ build-juju-local.sh 2014-08-14 07:58:38 +0000
4@@ -37,7 +37,10 @@
5 test_cmd_exists sstream-query simplestreams
6
7 # This defines what gets built
8-build_for=${BUILD_FOR:-trusty:amd64 precise:amd64}
9+build_for=(${BUILD_FOR:-trusty:amd64 precise:amd64})
10+[ -n "${JUJU_CORE_PKG}" -o -n "${JUJU_LOCAL_PKG}" ] && \
11+ [ ${#build_for[@]} -ge 2 ] && \
12+ fail "JUJU_CORE_PKG and JUJU_LOCAL_PKG can be specified only for a single build target."
13
14 for build in ${build_for[@]};
15 do
16@@ -62,6 +65,18 @@
17 )
18
19 [ ! -e "${builder_img}" ] && cmd+=("--fetch_new")
20+ if [ -n "${JUJU_CORE_PKG}" -o -n "${JUJU_LOCAL_PKG}" ]; then
21+ cmd+=("--cloud-init-file ${mydir}/handle-xdeb.py:text/part-handler")
22+ if [ -n "${JUJU_CORE_PKG}" ]; then
23+ cmd+=("--cloud-init-file ${JUJU_CORE_PKG}:application/x-deb")
24+ echo "JUJU_CORE_PKG=$(basename $JUJU_CORE_PKG)" > ${tmp_dir}/juju-sources.sh
25+ fi
26+ if [ -n "${JUJU_LOCAL_PKG}" ]; then
27+ cmd+=("--cloud-init-file ${JUJU_LOCAL_PKG}:application/x-deb")
28+ echo "JUJU_LOCAL_PKG=$(basename $JUJU_LOCAL_PKG)" >> ${tmp_dir}/juju-sources.sh
29+ fi
30+ cmd+=("--cloud-init-file ${tmp_dir}/juju-sources.sh:application/x-shellscript")
31+ fi
32
33 [ -e "${results_d_arch}/${suite}-server-cloudimg-${arch}-juju-vagrant-disk1.img" ] ||
34 ( cd ${results_d_arch} && ${cmd[@]} )
35
36=== added file 'handle-xdeb.py'
37--- handle-xdeb.py 1970-01-01 00:00:00 +0000
38+++ handle-xdeb.py 2014-08-14 07:58:38 +0000
39@@ -0,0 +1,15 @@
40+handler_version = 2
41+
42+
43+def list_types():
44+ return(["application/x-deb", "application/x-shellscript"])
45+
46+
47+def handle_part(data, ctype, filename, payload, frequency):
48+ import os
49+ if ctype in ("__begin__", "__end__"):
50+ return
51+
52+ dest = os.path.join(data.get_ipath(), filename)
53+ with open(dest, 'w') as out:
54+ out.write(payload)
55
56=== modified file 'launch_kvm.sh'
57--- launch_kvm.sh 2014-06-24 19:40:10 +0000
58+++ launch_kvm.sh 2014-08-14 07:58:38 +0000
59@@ -17,12 +17,13 @@
60 --raw-disk <ARG> Name of RAW disk to create and attach.
61 --raw-size <ARG> Size of RAW disk in GB.
62 --extra-disk <ARG> Add an extra disk, starting with /dev/vdd
63+ --cloud-init-file <ARG> Additional file for the cloud-init data
64 EOF
65 exit 1
66 }
67
68 short_opts="h"
69-long_opts="id:,ssh_port,disk-gb:,mem:,bzr-automated-ec2-builds:,cloud-config:,user-data:,kernel-url:,img-url:,raw-disk:,raw-size:,smp:,extra-disk:,help"
70+long_opts="id:,ssh_port,disk-gb:,mem:,bzr-automated-ec2-builds:,cloud-config:,user-data:,kernel-url:,img-url:,raw-disk:,raw-size:,smp:,extra-disk:,cloud-init-file:,help"
71 getopt_out=$(getopt --name "${0##*/}" \
72 --options "${short_opts}" --long "${long_opts}" -- "$@") &&
73 eval set -- "${getopt_out}" ||
74@@ -52,6 +53,7 @@
75 --raw-size) raw_size="$2"; shift;;
76 --smp) smp_opts="$2"; shift;;
77 --extra-disk) [ -z "${extra_disk}" ] && extra_disk=$2 || extra_disk="${extra_disk} $2"; shift;;
78+ --cloud-init-file) [ -z "${cloud_init_files}" ] && cloud_init_files=$2 || cloud_init_files="${cloud_init_files} $2"; shift;;
79 -h|--help) usage; exit 0;;
80 --) shift; break;;
81 esac
82@@ -78,8 +80,12 @@
83 [ -z "${ccloud}" ] && fail "Must define cloud-config script via --cloud-config"
84
85 debug "Creating Cloud-Init configuration..."
86-write-mime-multipart -o "${work_d}/user-data.txt" "${ccloud}" "${ud}" ||
87- fail "Unable to create user-data"
88+write_mime_args=(
89+ -o "${work_d}/user-data.txt"
90+ "${ccloud}"
91+ "${ud}")
92+write_mime_args+=(${cloud_init_files[@]})
93+write-mime-multipart ${write_mime_args[@]} || fail "Unable to create user-data"
94
95 echo "instance-id: $(uuidgen)" > "${work_d}/meta-data"
96 echo "local-hostname: builder" >> "${work_d}/meta-data"
97
98=== modified file 'standalone.sh'
99--- standalone.sh 2014-07-10 21:50:47 +0000
100+++ standalone.sh 2014-08-14 07:58:38 +0000
101@@ -71,7 +71,7 @@
102 }
103
104 short_opts="h"
105-long_opts="suite:,use_img:,install,streams:,template:,addin:,arch:,resize:,config:,final_img:,cloud_cfg:,fetch_new,resize_final:"
106+long_opts="suite:,use_img:,install,streams:,template:,addin:,arch:,resize:,config:,final_img:,cloud_cfg:,fetch_new,resize_final:,cloud-init-file:"
107 getopt_out=$(getopt --name "${0##*/}" \
108 --options "${short_opts}" --long "${long_opts}" -- "$@") &&
109 eval set -- "${getopt_out}" ||
110@@ -105,8 +105,9 @@
111 --config) config="${2}"; shift;;
112 --cloud_cfg) cloud_cfg="${2}"; shift;;
113 --final_img) final_img="${2}"; shift;;
114- --fetch_new) fetch_new=1; shift;;
115+ --fetch_new) fetch_new=1;;
116 --resize_final) resize_final="${2}"; shift;;
117+ --cloud-init-file) [ -z "${cloud_init_files}" ] && cloud_init_files="--cloud-init-file ${2}" || cloud_init_files="${cloud_init_files} --cloud-init-file ${2}"; shift;;
118 -h|--help) usage; exit 0;;
119 --) shift; break;;
120 esac
121@@ -256,6 +257,7 @@
122 "--raw-disk $(readlink -f $raw_f)"
123 "--raw-size ${raw_size:-20}"
124 "--img-url $(readlink -f $mod_img)"
125+ "${cloud_init_files[@]}"
126 )
127
128 # Run the command
129
130=== modified file 'templates/img-juju.tmpl'
131--- templates/img-juju.tmpl 2014-08-08 07:48:18 +0000
132+++ templates/img-juju.tmpl 2014-08-14 07:58:38 +0000
133@@ -316,7 +316,6 @@
134 byobu
135 lxc
136 cgroup-lite
137- juju-core
138 bzr
139 git
140 mongodb-server
141@@ -324,9 +323,13 @@
142 python-pip
143 libnss-myhostname
144 rsyslog-gnutls
145- juju-local
146 )
147
148+instance_dir=$(dirname $(dirname $(readlink -f $0)))
149+[ -e ${instance_dir}/juju-sources.sh ] && source ${instance_dir}/juju-sources.sh
150+[ -z ${JUJU_CORE_PKG} ] && pkgs+=(juju-core)
151+[ -z ${JUJU_LOCAL_PKG} ] && pkgs+=(juju-local)
152+
153 if [ "${suite}" == "precise" ]; then
154 pkgs+=(linux-headers-generic-lts-raring
155 linux-generic-lts-raring)
156@@ -355,6 +358,17 @@
157 xchroot apt-get -y update
158 xchroot update-grub
159
160+if [ -n "${JUJU_CORE_PKG}" ] ; then
161+ cp ${instance_dir}/${JUJU_CORE_PKG} ${mp}/tmp/
162+ xchroot dpkg -i /tmp/${JUJU_CORE_PKG}
163+fi
164+
165+if [ -n "${JUJU_LOCAL_PKG}" ] ; then
166+ cp ${instance_dir}/${JUJU_LOCAL_PKG} ${mp}/tmp/
167+ xchroot apt-get install -y cpu-checker juju-mongodb
168+ xchroot dpkg -i /tmp/${JUJU_LOCAL_PKG}
169+fi
170+
171 # Gets rid of an annoying message for shell provisioner
172 xchroot sed -i "s|mesg n|tty -s \&\& mesg n|g" /root/.profile
173

Subscribers

People subscribed via source and target branches