Merge lp:~serge-hallyn/sandbox-upgrader/uvtool into lp:~mvo/sandbox-upgrader/main

Proposed by Serge Hallyn
Status: Needs review
Proposed branch: lp:~serge-hallyn/sandbox-upgrader/uvtool
Merge into: lp:~mvo/sandbox-upgrader/main
Diff against target: 282 lines (+89/-62)
6 files modified
debian/changelog (+6/-0)
debian/control (+1/-2)
gen-test-upgrade-vm (+6/-13)
helper/clone-helper.sh (+33/-12)
sandbox-clone-to-vm (+30/-15)
sandbox-test-upgrade (+13/-20)
To merge this branch: bzr merge lp:~serge-hallyn/sandbox-upgrader/uvtool
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+202182@code.launchpad.net

Description of the change

Switch from using vm-builder to using uvtool.

vmbuilder will be removed from the archive in trusty. Ideally this switch could be done before february so we can smoothly transition before FFE.

To post a comment you must log in.

Unmerged revisions

45. By Serge Hallyn

Convert from using vm-builder to using uvtool. (LP: #1261419)

44. By Serge Hallyn

Convert from using vm-builder to using uvtool.

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 2008-08-18 13:49:51 +0000
3+++ debian/changelog 2014-01-17 22:46:33 +0000
4@@ -1,3 +1,9 @@
5+sandbox-upgrader (0.1+bzr20080818-0ubuntu2) trusty; urgency=medium
6+
7+ * Convert from using vm-builder to using uvtool. (LP: #1261419)
8+
9+ -- Serge Hallyn <serge.hallyn@ubuntu.com> Fri, 17 Jan 2014 16:40:45 -0600
10+
11 sandbox-upgrader (0.1+bzr20080818-0ubuntu1) intrepid; urgency=low
12
13 * run ssh/rm with -v
14
15=== modified file 'debian/control'
16--- debian/control 2008-08-15 22:31:17 +0000
17+++ debian/control 2014-01-17 22:46:33 +0000
18@@ -8,8 +8,7 @@
19
20 Package: sandbox-upgrader
21 Architecture: all
22-Depends: ${shlibs:Depends}, ${misc:Depends}, ubuntu-vm-builder, kvm (>= 1:70)
23-Conflicts: ubuntu-vm-builder (= 0.4-0ubuntu3)
24+Depends: ${shlibs:Depends}, ${misc:Depends}, uvtool, qemu-kvm
25 Description: sandbox upgrade test creation tools
26 This package contains helper scripts that can perform a test upgrade
27 in a virtual machine to help testing upgrade procedure.
28
29=== modified file 'gen-test-upgrade-vm'
30--- gen-test-upgrade-vm 2008-08-06 11:09:23 +0000
31+++ gen-test-upgrade-vm 2014-01-17 22:46:33 +0000
32@@ -2,20 +2,13 @@
33 # helper that generates a minimal environment for testing the upgrade
34 # script functionatlity
35
36-VM=kvm
37-SUITE=hardy
38+HOST=vm-auto-upgrade-test
39+SUITE=precise
40 ARCH=$(dpkg --print-architecture)
41 SIZE=80000
42 MEM=384
43
44-# this builds a bootable vm that is big enough,
45-# the clone-helper.sh does all the heavy lifting
46-ubuntu-vm-builder $VM $SUITE \
47- --arch $ARCH \
48- --rootsize $SIZE \
49- --mem $MEM \
50- --addpkg update-manager-core \
51- -d vm-auto-upgrade-test \
52- --ssh-key /var/lib/sandbox-upgrader/ssh/sshkey.pub \
53- "$@"
54-
55+uvt-simplestreams-libvirt sync release=$SUITE arch=$ARCH
56+uvt-kvm create $HOST release=$SUITE arch=$ARCH --ssh-public-key-file /var/lib/sandbox-upgrader/ssh/sshkey.pub
57+uvt-kvm wait $HOST
58+virsh destroy $HOST
59
60=== modified file 'helper/clone-helper.sh'
61--- helper/clone-helper.sh 2008-07-24 12:23:39 +0000
62+++ helper/clone-helper.sh 2014-01-17 22:46:33 +0000
63@@ -2,15 +2,22 @@
64
65 set -e
66
67+# XXX I'm turning this script off as I don't quite understand what it
68+# was meant to do. vm-builder claims this script would be called with
69+# the vm mountpoint as $1. But this script seems to assume it is under
70+# "root/'.
71+#false
72+
73+MOUNTPOINT=$1
74 save() {
75- if [ -f root/$1 ]; then
76- cp -va root/$1 root/$1.clonesave
77+ if [ -f $MOUNTPOINT/$1 ]; then
78+ cp -va $MOUNTPOINT/$1 $MOUNTPOINT/$1.clonesave
79 fi
80 }
81
82 restore() {
83- if [ -f root/$1.clonesave ]; then
84- mv root/$1.clonesave root/$1
85+ if [ -f $MOUNTPOINT/$1.clonesave ]; then
86+ mv $MOUNTPOINT/$1.clonesave $MOUNTPOINT/$1
87 fi
88 }
89
90@@ -24,35 +31,49 @@
91 save /etc/fstab
92 save /etc/network/interfaces
93
94-cp -ra /etc root/
95+# uvt-kvm defaults to an ubuntu user. Preserve it if it does
96+# not exist on the host
97+mv $MOUNTPOINT/home/ubuntu/.ssh $MOUNTPOINT/.ssh.clonesave
98+grep ubuntu /home//etc/passwd > $MOUNTPOINT/.passwdclonesave
99+grep ubuntu /home//etc/shadow > $MOUNTPOINT/.shadowclonesave
100+grep ubuntu /home//etc/group > $MOUNTPOINT/.groupclonesave
101+
102+cp -ra /etc $MOUNTPOINT/
103
104 restore /etc/fstab
105 restore /etc/network/interfaces
106
107 # copy the FS
108+if false; then
109 for d in /bin /boot /initrd /lib /lib32 /lib64 /opt /root \
110 /sbin /srv /usr /var; do
111 if [ -d $d ]; then
112- echo "copying $d -> root/"
113- (cd root/ ; tar cf - $d | tar xf - )
114+ echo "copying $d -> $MOUNTPOINT/"
115+ (cd $MOUNTPOINT/ ; tar cf - $d | tar xf - )
116 fi
117 done
118+fi
119
120 # kill copied menu.lst and let the system generate a new one
121-rm root/boot/grub/menu.lst
122+rm $MOUNTPOINT/boot/grub/menu.lst
123
124 # copy custom xorg.conf - the orignial one
125 # will most likely not work
126 # FIXME: instead of overwritting, just remove/rewrite
127 # the device section?
128-if [ -e root/etc/X11/xorg.conf ]; then
129- cp -v $BASEPATH/xorg.conf root/etc/X11/
130+if [ -e $MOUNTPOINT/etc/X11/xorg.conf ]; then
131+ cp -v $BASEPATH/xorg.conf $MOUNTPOINT/etc/X11/
132 fi
133
134 # create homedirs of the users
135 # FIXME: copy dot-files
136 for d in $(find /home/ -maxdepth 1 -type d ); do
137- (cd root/ ; tar --no-recursion -c -f - $d | tar xvf -)
138+ (cd $MOUNTPOINT/ ; tar --no-recursion -c -f - $d | tar xvf -)
139 done
140
141-
142+mv $MOUNTPOINT/.ssh.clonesave $MOUNTPOINT/home/ubuntu/.ssh
143+if ! grep -q ubuntu $MOUNTPOINT/etc/passwd; then
144+ cat $MOUNTPOINT/.passwdclonesave >> $MOUNTPOINT/etc/passwd
145+ cat $MOUNTPOINT/.shadowclonesave >> $MOUNTPOINT/etc/shadow
146+ cat $MOUNTPOINT/.groupclonesave >> $MOUNTPOINT/etc/group
147+fi
148
149=== modified file 'sandbox-clone-to-vm'
150--- sandbox-clone-to-vm 2008-08-07 14:12:42 +0000
151+++ sandbox-clone-to-vm 2014-01-17 22:46:33 +0000
152@@ -21,22 +21,37 @@
153
154 BASEPATH=/usr/share/sandbox-upgrader/
155
156-VM=kvm
157+VARPATH=/var/lib/sandbox-upgrader/
158+
159+# configuration
160+SSHKEY=$VARPATH/ssh/sshkey
161+
162 SUITE=$(lsb_release -c -s)
163 ARCH=$(dpkg --print-architecture)
164 SCRIPT=$BASEPATH/clone-helper.sh
165 SIZE=80000
166-MEM=384
167-TMPDIR=$PWD
168-
169-# this builds a bootable vm that is big enough,
170-# the clone-helper.sh does all the heavy lifting
171-ubuntu-vm-builder $VM $SUITE \
172- --arch $ARCH \
173- --user $USER \
174- --rootsize $SIZE \
175- --mem $MEM \
176- --addpkg xserver-xorg-video-cirrus \
177- --tmp $TMPDIR \
178- --exec $SCRIPT \
179- "$@"
180+MEM=512
181+HOST=vm-auto-upgrade-test
182+
183+SSHOPTS="-l ubuntu $HOST -i $SSHKEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=$SSHHOSTS -o BatchMode=yes -tt -v"
184+
185+uvt-simplestreams-libvirt sync release=$SUITE arch=$ARCH || uvt-simplestreams-libvirt sync --source http://cloud-images.ubuntu.com/daily release=$SUITE arch=$ARCH
186+uvt-kvm create $HOST release=$SUITE arch=$ARCH --ssh-public-key-file /var/lib/sandbox-upgrader/ssh/sshkey.pub
187+uvt-kvm wait $HOST
188+ssh $SSHOPTS sudo apt-get -yqq install xserver-xorg-video-cirrus
189+virsh destroy $HOST
190+read -p "invistage now then hit enter when done" x
191+
192+#now mount the image and run $SCRIPT
193+use_script=1
194+if [ $use_script -eq 1 ]; then
195+ modprobe nbd
196+ # TODO grab filename from virsh dumpxml output
197+ qemu-nbd -c /dev/nbd0 /var/lib/uvtool/libvirt/images/${HOST}.qcow
198+ TMPDIR=`mktemp -d`
199+ mount /dev/nbd0p1 $TMPDIR
200+ $SCRIPT $TMPDIR
201+ umount $TMPDIR
202+ qemu-nbd -d /dev/nbd0
203+ rmdir $TMPDIR
204+fi
205
206=== modified file 'sandbox-test-upgrade'
207--- sandbox-test-upgrade 2008-08-18 13:49:51 +0000
208+++ sandbox-test-upgrade 2014-01-17 22:46:33 +0000
209@@ -26,29 +26,21 @@
210 # configuration
211 SSHKEY=$VARPATH/ssh/sshkey
212 SSHHOSTS=$VARPATH/ssh/known_hosts
213-SSHPORT=51234
214 RESULTDIR=$VARPATH/result
215-VNCPORT=localhost:0
216+
217+HOST=vm-auto-upgrade-test
218
219 # common option for the helpers
220-KVMOPTS="-no-reboot -m 384 -vnc $VNCPORT -redir tcp:$SSHPORT::22 -net nic,model=virtio -net user "
221-SSHOPTS="-l root -p $SSHPORT localhost -i $SSHKEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=$SSHHOSTS -o BatchMode=yes -tt -v"
222-SCPOPTS="-P $SSHPORT -i $SSHKEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=$SSHHOSTS"
223-
224+SSHOPTS="-l ubuntu -i $SSHKEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=$SSHHOSTS -o BatchMode=yes -tt -v"
225+SCPOPTS="-i $SSHKEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=$SSHHOSTS"
226
227 wait_for_kvm () {
228- while true; do
229- if ssh -q $SSHOPTS true; then
230- echo "kvm ready"
231- break;
232- fi
233- sleep 5
234- done
235+ uvt-kvm wait $HOST
236 }
237
238
239 # check if the system is kvm capable
240-if ! egrep -q '(vmx|svm)' /proc/cpuinfo; then
241+if ! kvm-ok; then
242 echo "Your hardware does not support the cpu extenstions required to run kvm"
243 echo "Checkout https://wiki.ubuntu.com/kvm for more information"
244 exit 1
245@@ -65,7 +57,7 @@
246
247 # clone the system and make it ssh accessable
248 echo "Cloning system"
249-if [ -d "vm-auto-upgrade-test" ]; then
250+if virsh domuuid vm-auto-upgrade-test 2>&1 > /dev/null; then
251 echo "Using the existing cloned system to perform a upgrade test"
252 echo "If that is not what you want, please press ctrl-c now to"
253 echo "abort the test."
254@@ -74,23 +66,24 @@
255 fi
256
257 # start it in the background
258-echo "Starting kvm (with vnc on $VNCPORT)"
259-kvm $KVMOPTS vm-auto-upgrade-test/root.qcow2 &
260+virsh start $HOST || true
261+echo "vnc is on $(virsh vncdisplay $HOST)"
262
263 # now ssh into it and run a release upgrade (the kvm reboot and therefore
264 # stops kvm after the upgrade)
265 wait_for_kvm
266+ip=`uvt-kvm ip $HOST`
267 echo "Running test upgrade in kvm"
268-if ! ssh $SSHOPTS -- do-release-upgrade -d -f DistUpgradeViewNonInteractive; then
269+if ! ssh $SSHOPTS ${ip} -- do-release-upgrade -d -f DistUpgradeViewNonInteractive; then
270 echo "do-release-upgrade failed with exit code $?"
271 else
272 echo "do-releae-upgrade success: $?"
273 fi
274
275 echo "now copying the results to $RESULTDIR"
276-scp $SCPOPTS root@localhost:/var/log/dist-upgrade/* $RESULTDIR
277+scp $SCPOPTS ubuntu@${ip}:/var/log/dist-upgrade/* $RESULTDIR
278 # and stop the virtual machine
279-ssh $SSHOPTS -- /sbin/halt
280+ssh $SSHOPTS ${ip} -- /sbin/halt
281
282 echo "You may want to view $RESULTDIR/main.log for a overview"
283

Subscribers

People subscribed via source and target branches

to all changes: