Merge lp:~benji/launchpad/more-integration into lp:launchpad

Proposed by Benji York on 2012-03-06
Status: Merged
Approved by: Gary Poster on 2012-03-06
Approved revision: no longer in the source branch.
Merged at revision: 14922
Proposed branch: lp:~benji/launchpad/more-integration
Merge into: lp:launchpad
Prerequisite: lp:~frankban/launchpad/setuplxc-scripts-shh-keys
Diff against target: 70 lines (+17/-10)
1 file modified
utilities/setuplxc.py (+17/-10)
To merge this branch: bzr merge lp:~benji/launchpad/more-integration
Reviewer Review Type Date Requested Status
Gary Poster (community) 2012-03-06 Approve on 2012-03-06
Review via email: mp+96211@code.launchpad.net

Commit Message

[r=gary][no-qa] fixes a couple of small issues in the setuplxc.py utilities script

Description of the Change

This branch fixes a couple of small issues in the setuplxc.py utilities script.

To post a comment you must log in.
Gary Poster (gary) wrote :

Cool, thank you.

Indentation of second line of HOST_PACKAGES seems a bit odd to me, but I'll defer if this is your style.

review: Approve
Robert Collins (lifeless) wrote :

This is good stuff. I'd like to make a suggestion, which is that
setuplxc move to lp-dev-tools. This may be impractical, and if so
thats fine.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utilities/setuplxc.py'
2--- utilities/setuplxc.py 2012-03-07 15:27:20 +0000
3+++ utilities/setuplxc.py 2012-03-07 15:27:20 +0000
4@@ -35,11 +35,12 @@
5 import os
6 import platform
7 import pwd
8+import re
9 import shutil
10 import subprocess
11 import sys
12+import textwrap
13 import time
14-import textwrap
15
16 APT_REPOSITORIES = (
17 'deb http://archive.ubuntu.com/ubuntu {distro} multiverse',
18@@ -50,7 +51,8 @@
19 )
20 DEPENDENCIES_DIR = '~/dependencies'
21 DHCP_FILE = '/etc/dhcp/dhclient.conf'
22-HOST_PACKAGES = ['ssh', 'lxc', 'libvirt-bin', 'bzr', 'testrepository']
23+HOST_PACKAGES = ['ssh', 'lxc', 'libvirt-bin', 'bzr', 'testrepository',
24+ 'python-shell-toolbox']
25 HOSTS_FILE = '/etc/hosts'
26 LP_APACHE_MODULES = 'proxy proxy_http rewrite ssl deflate headers'
27 LP_APACHE_ROOTS = (
28@@ -771,14 +773,14 @@
29 # root (see below) but drops root once inside the LXC container.
30 build_script_file = '/usr/local/bin/launchpad-lxc-build'
31 with open(build_script_file, 'w') as script:
32- script.write(textwrap.dedent("""
33+ script.write(textwrap.dedent("""\
34 #!/bin/sh
35 set -uex
36 lxc-start -n {lxcname} -d
37 lxc-wait -n {lxcname} -s RUNNING
38 sleep 30 # aparently RUNNING isn't quite enough
39 su {user} -c "/usr/bin/ssh -o StrictHostKeyChecking=no \\
40- -i '{ssh_key_path}' {lxcname} make -C {checkout_dir} schema"
41+ -i '{ssh_key_path}' {lxcname} make -C $PWD schema"
42 lxc-stop -n {lxcname}
43 lxc-wait -n {lxcname} -s STOPPED
44 """.format(**mapping)))
45@@ -786,14 +788,19 @@
46 # We need a script to test launchpad using LXC ephemeral instances.
47 test_script_file = '/usr/local/bin/launchpad-lxc-test'
48 with open(test_script_file, 'w') as script:
49- script.write(textwrap.dedent("""
50+ # We intentionally generate a very long line for the
51+ # lxc-start-ephemeral command below because ssh does not propagate
52+ # quotes the way we want. E.g.,
53+ # touch a; touch b; ssh localhost -- ls "a b"
54+ # succeeds, when it should say that the file "a b" does not exist.
55+ script.write(textwrap.dedent(re.sub(' {2,}', ' ', """\
56 #!/bin/sh
57 set -uex
58- lxc-start-ephemeral -u {user} -S '{ssh_key_path}' -o {lxcname} \\
59- -b $PWD -- xvfb-run --error-file=/var/tmp/xvfb-errors.log \\
60- --server-args='-screen 0 1024x768x24' \\
61- -a $PWD/bin/test --subunit $@
62- """.format(**mapping)))
63+ lxc-start-ephemeral -u {user} -S '{ssh_key_path}' -o {lxcname} \
64+ -b $PWD -- "xvfb-run --error-file=/var/tmp/xvfb-errors.log \
65+ --server-args='-screen 0 1024x768x24' \
66+ -a $PWD/bin/test --subunit $@"
67+ """).format(**mapping)))
68 os.chmod(test_script_file, 0555)
69 # Add a file to sudoers.d that will let the buildbot user run the above.
70 sudoers_file = '/etc/sudoers.d/launchpad-' + user