Merge lp:~vila/uci-engine/britney-images into lp:uci-engine

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: 881
Merged at revision: 875
Proposed branch: lp:~vila/uci-engine/britney-images
Merge into: lp:uci-engine
Diff against target: 163 lines (+92/-40)
3 files modified
britney_proxy/README.images (+36/-38)
image-builder/create-nova-adt-image.sh (+55/-0)
tests/test_britney.py (+1/-2)
To merge this branch: bzr merge lp:~vila/uci-engine/britney-images
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+240419@code.launchpad.net

Commit message

Document how glance images have been created for uci-britney

Description of the change

This describes how the glance images for uci-britney have been created.

In the long term, this should become part of the image builder.

In the mean time, it documents how a nova instance can be snapshotted to produce a glance image which opens the doors to any setup we may want to do inside a running instance which is easier than using a chroot in a qemu mounted image.

To post a comment you must log in.
lp:~vila/uci-engine/britney-images updated
880. By Vincent Ladeuil

Chmod 755 the script

881. By Vincent Ladeuil

Cleanup

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:881
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/1663/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/1663/rebuild

review: Approve (continuous-integration)
Revision history for this message
Joe Talbott (joetalbott) wrote :

This looks okay to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'britney_proxy/README.images'
2--- britney_proxy/README.images 2014-10-08 07:35:31 +0000
3+++ britney_proxy/README.images 2014-11-03 13:13:03 +0000
4@@ -19,49 +19,47 @@
5
6 Create a directory to hold cloud images
7
8-ubuntu@juju-bootstack-machine-1:~$ mkdir images
9+ubuntu@juju-bootstack-machine-1:~$ mkdir -p images
10 ubuntu@juju-bootstack-machine-1:~$ cd images
11
12 Get some images
13
14-ubuntu@juju-bootstack-machine-1:~$ wget http://cloud-images.ubuntu.com/utopic/current/utopic-server-cloudimg-amd64-disk1.img --output-document utopic-amd64.img
15-
16-ubuntu@juju-bootstack-machine-1:~$ wget http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img --output-document trusty-amd64.img
17-
18-ubuntu@juju-bootstack-machine-1:~$ wget http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img --output-document precise-amd64.img
19-
20-ubuntu@juju-bootstack-machine-1:~$ wget http://cloud-images.ubuntu.com/utopic/current/utopic-server-cloudimg-i386-disk1.img --output-document utopic-i386.img
21-
22-ubuntu@juju-bootstack-machine-1:~$ wget http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-i386-disk1.img --output-document trusty-i386.img
23-
24-ubuntu@juju-bootstack-machine-1:~$ wget http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-i386-disk1.img --output-document precise-i386.img
25+for series in utopic trusty precise
26+do
27+ for arch in amd64 i386
28+ do
29+ wget http://cloud-images.ubuntu.com/${series}/current/${series}-server-cloudimg-${arch}-disk1.img --output-document ${series}-${arch}.img
30+ done
31+done
32
33
34 Create images used by tests
35
36-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/cloudimg/utopic-amd64.img --file utopic-amd64.img --disk-format qcow2 --container-format bare --is-public True
37-
38-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/cloudimg/trusty-amd64.img --file trusty-amd64.img --disk-format qcow2 --container-format bare --is-public True
39-
40-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/cloudimg/precise-amd64.img --file precise-amd64.img --disk-format qcow2 --container-format bare --is-public True
41-
42-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/cloudimg/utopic-i386.img --file utopic-i386.img --disk-format qcow2 --container-format bare --is-public True
43-
44-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/cloudimg/trusty-i386.img --file trusty-i386.img --disk-format qcow2 --container-format bare --is-public True
45-
46-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/cloudimg/precise-i386.img --file precise-i386.img --disk-format qcow2 --container-format bare --is-public True
47-
48-Create images used for britney (just the cloud image to start with, further
49-optimizations will happen later)
50-
51-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/britney/utopic-amd64.img --file utopic-amd64.img --disk-format qcow2 --container-format bare --is-public True
52-
53-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/britney/trusty-amd64.img --file trusty-amd64.img --disk-format qcow2 --container-format bare --is-public True
54-
55-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/britney/precise-amd64.img --file precise-amd64.img --disk-format qcow2 --container-format bare --is-public True
56-
57-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/britney/utopic-i386.img --file utopic-i386.img --disk-format qcow2 --container-format bare --is-public True
58-
59-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/britney/trusty-i386.img --file trusty-i386.img --disk-format qcow2 --container-format bare --is-public True
60-
61-ubuntu@juju-bootstack-machine-1:~$ glance image-create --name uci/britney/precise-i386.img --file precise-i386.img --disk-format qcow2 --container-format bare --is-public True
62+PREFIX="uci/cloudimg/"
63+for series in utopic trusty precise
64+do
65+ for arch in amd64 i386
66+ do
67+ BASE_NAME=${series}-${arch}.img
68+ IMG_NAME=${PREFIX}${BASE_NAME}
69+ glance image-delete ${IMG_NAME}
70+ glance image-create --name ${IMG_NAME} --file ${BASE_NAME} --disk-format qcow2 --container-format bare --is-public True
71+ done
72+done
73+
74+Create images used for britney, this should be run from your local host (not the image builder one) and requires a known keypair to be registered with nova.
75+
76+nova keypair-add --pub-key <path> <your key name>
77+
78+We care only about utopic and trusty for now (precise is not targeted, vivid doesn't yet provide a cloud image).
79+
80+for series in utopic trusty
81+do
82+ for arch in amd64 i386
83+ do
84+ BASE_NAME=${series}-${arch}.img
85+ glance image-delete "uci/britney/${BASE_NAME}"
86+ ./image-builder/create-nova-adt-image.sh "uci/cloudimg/${BASE_NAME}" vila-uci-vms
87+ glance image-update --is-public True "uci/britney/${BASE_NAME}"
88+ done
89+done
90
91=== added file 'image-builder/create-nova-adt-image.sh'
92--- image-builder/create-nova-adt-image.sh 1970-01-01 00:00:00 +0000
93+++ image-builder/create-nova-adt-image.sh 2014-11-03 13:13:03 +0000
94@@ -0,0 +1,55 @@
95+#!/bin/sh
96+# create an uci/britney/${release}-${arch}.img nova image based on a generic
97+# image and adt-setup-vm
98+# Author: Martin Pitt <martin.pitt@ubuntu.com>
99+set -eu
100+BASEIMG="${1:-}"
101+
102+if [ -z "$BASEIMG" ]; then
103+ echo "Usage: $0 <base image name> [key name]" >&2
104+ exit 1
105+fi
106+
107+opts=""
108+[ -z "${2:-}" ] || opts="$opts --key_name $2"
109+[ -z "${EPHEMERAL_CLOUD_NET_ID:-}" ] || opts="$opts --nic net-id=$EPHEMERAL_CLOUD_NET_ID"
110+
111+# unbreak my server option :-(
112+userdata=`mktemp`
113+trap "rm $userdata" EXIT TERM INT QUIT PIPE
114+/bin/echo -e "#cloud-config\nmanage_etc_hosts: True" > $userdata
115+
116+# create new instance
117+INSTNAME="$BASEIMG-adt-prepare"
118+nova boot --flavor m1.smaller --image $BASEIMG --user-data $userdata $opts --poll $INSTNAME
119+
120+# determine IP address
121+ipaddr=$(nova show --minimal $INSTNAME | awk 'BEGIN {FS="|"} /network/ {n=split($3,i,/,\s*/); gsub(" ", "", i[n]); print i[n]}')
122+SSH_CMD="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$ipaddr"
123+echo "Waiting for ssh (may cause some error messages)..."
124+timeout 5m sh -c "while ! $SSH_CMD true; do sleep 5; done"
125+
126+echo "Waiting until cloud-init is done..."
127+timeout 10m $SSH_CMD 'while [ ! -e /var/lib/cloud/instance/boot-finished ]; do sleep 1; done'
128+
129+# Hack to create a vivid image from an utopic one
130+
131+# $SSH_CMD 'sudo sed -i "s/utopic/vivid/g" /etc/apt/sources.list /etc/apt/sources.list.d/*.list || true'
132+# $SSH_CMD sudo apt-get update
133+# $SSH_CMD sudo apt-get -y dist-upgrade
134+
135+echo "Running adt setup script..."
136+$SSH_CMD sudo sh -x < /usr/share/autopkgtest/adt-setup-vm
137+release=$($SSH_CMD lsb_release -sc)
138+arch=$($SSH_CMD dpkg --print-architecture)
139+
140+echo "Powering off to get a clean file system..."
141+$SSH_CMD sudo poweroff
142+while ! nova show --minimal $INSTNAME | grep -q 'vm_state.*stopped'; do sleep 1; done
143+
144+# determine new image name and build it
145+IMAGE_NAME="uci/britney/${release}-${arch}.img"
146+nova image-create --show --poll $INSTNAME "$IMAGE_NAME"
147+nova delete $INSTNAME
148+echo
149+echo "Successfully built image $IMAGE_NAME"
150
151=== modified file 'tests/test_britney.py'
152--- tests/test_britney.py 2014-10-16 10:31:16 +0000
153+++ tests/test_britney.py 2014-11-03 13:13:03 +0000
154@@ -60,8 +60,7 @@
155
156 scenarios = scenarii.multiply_scenarios(
157 # series
158- ([('precise', dict(series='precise', result='FAILED')),
159- ('trusty', dict(series='trusty', result='PASSED')),
160+ ([('trusty', dict(series='trusty', result='PASSED')),
161 ('utopic', dict(series='utopic', result='PASSED'))]),
162 # architectures
163 ([('amd64', dict(arch='amd64')), ('i386', dict(arch='i386'))]))

Subscribers

People subscribed via source and target branches