Merge lp:~mwhudson/launchpad/no-more-devpad-ssh into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/no-more-devpad-ssh
Merge into: lp:launchpad
Diff against target: 213 lines
5 files modified
lib/devscripts/ec2test/builtins.py (+3/-5)
lib/devscripts/ec2test/instance.py (+0/-22)
lib/devscripts/ec2test/sshconfig.py (+0/-95)
lib/devscripts/ec2test/testrunner.py (+4/-6)
utilities/update-sourcecode (+4/-2)
To merge this branch: bzr merge lp:~mwhudson/launchpad/no-more-devpad-ssh
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+12200@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Hi Tim,

This branch uses the update-sourcecode script rather than rsync to update the sourcecode directory, which lets us remove some of the complication from the ssh setup on the instance.

The other small changes are allowing the update-sourcecode script to run before make build has run and updating the branch _before_ updating sourcecode, so that any changes to update-sourcecode in the branch being tested are applied before the script is executed.

Cheers,
mwh

Revision history for this message
Tim Penhey (thumper) wrote :

On Tue, 22 Sep 2009 11:40:26 Michael Hudson wrote:
> Michael Hudson has proposed merging
> lp:~mwhudson/launchpad/no-more-devpad-ssh into lp:launchpad/devel.
>
> Requested reviews:
> Tim Penhey (thumper)
>
> Hi Tim,
>
> This branch uses the update-sourcecode script rather than rsync to update
> the sourcecode directory, which lets us remove some of the complication
> from the ssh setup on the instance.
>
> The other small changes are allowing the update-sourcecode script to run
> before make build has run and updating the branch _before_ updating
> sourcecode, so that any changes to update-sourcecode in the branch being
> tested are applied before the script is executed.
>
> Cheers,
> mwh
>

Looks good to me.

  merge approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/devscripts/ec2test/builtins.py'
2--- lib/devscripts/ec2test/builtins.py 2009-09-18 05:57:43 +0000
3+++ lib/devscripts/ec2test/builtins.py 2009-09-26 22:37:14 +0000
4@@ -393,14 +393,12 @@
5 for cmd in extra_update_image_command:
6 user_connection.run_with_ssh_agent(cmd)
7 user_connection.run_with_ssh_agent(
8- "rsync -avp --partial --delete "
9- "--filter='P *.o' --filter='P *.pyc' --filter='P *.so' "
10- "devpad.canonical.com:/code/rocketfuel-built/launchpad/sourcecode/* "
11- "/var/launchpad/sourcecode/")
12- user_connection.run_with_ssh_agent(
13 'bzr pull -d /var/launchpad/test ' + TRUNK_BRANCH)
14 user_connection.run_with_ssh_agent(
15 'bzr pull -d /var/launchpad/download-cache lp:lp-source-dependencies')
16+ user_connection.run_with_ssh_agent(
17+ "/var/launchpad/test/utilities/update-sourcecode "
18+ "/var/launchpad/sourcecode")
19 user_connection.close()
20 root_connection = instance.connect_as_root()
21 root_connection.perform(
22
23=== modified file 'lib/devscripts/ec2test/instance.py'
24--- lib/devscripts/ec2test/instance.py 2009-09-18 05:26:54 +0000
25+++ lib/devscripts/ec2test/instance.py 2009-09-26 22:37:14 +0000
26@@ -23,7 +23,6 @@
27
28 import paramiko
29
30-from devscripts.ec2test.sshconfig import SSHConfig
31 from devscripts.ec2test.credentials import EC2Credentials
32
33
34@@ -223,26 +222,6 @@
35 as_root('sudo -u %(USER)s mkdir /home/%(USER)s/.ssh')
36 root_sftp = root_connection.ssh.open_sftp()
37 remote_ssh_dir = '/home/%(USER)s/.ssh' % self._vals
38- # Create config file
39- self.log('Creating %s/config\n' % (remote_ssh_dir,))
40- ssh_config_file_name = os.path.join(
41- self._vals['HOME'], '.ssh', 'config')
42- ssh_config_source = open(ssh_config_file_name)
43- config = SSHConfig()
44- config.parse(ssh_config_source)
45- ssh_config_source.close()
46- ssh_config_dest = root_sftp.open("%s/config" % remote_ssh_dir, 'w')
47- ssh_config_dest.write('CheckHostIP no\n')
48- ssh_config_dest.write('StrictHostKeyChecking no\n')
49- for hostname in ('devpad.canonical.com', 'chinstrap.canonical.com'):
50- ssh_config_dest.write('Host %s\n' % (hostname,))
51- data = config.lookup(hostname)
52- for key in ('hostname', 'gssapiauthentication', 'proxycommand',
53- 'user', 'forwardagent'):
54- value = data.get(key)
55- if value is not None:
56- ssh_config_dest.write(' %s %s\n' % (key, value))
57- ssh_config_dest.close()
58 # create authorized_keys
59 self.log('Setting up %s/authorized_keys\n' % remote_ssh_dir)
60 authorized_keys_file = root_sftp.open(
61@@ -309,7 +288,6 @@
62 finally:
63 if shutdown:
64 self.shutdown()
65-
66
67 def _copy_single_file(self, sftp, local_path, remote_dir):
68 """Copy `local_path` to `remote_dir` on this instance.
69
70=== removed file 'lib/devscripts/ec2test/sshconfig.py'
71--- lib/devscripts/ec2test/sshconfig.py 2009-09-11 03:26:40 +0000
72+++ lib/devscripts/ec2test/sshconfig.py 1970-01-01 00:00:00 +0000
73@@ -1,95 +0,0 @@
74-#############################################################################
75-# Modified from paramiko.config. The change should be pushed upstream.
76-# Our fork supports Host lines with more than one host.
77-
78-import fnmatch
79-
80-class SSHConfig (object):
81- """
82- Representation of config information as stored in the format used by
83- OpenSSH. Queries can be made via L{lookup}. The format is described in
84- OpenSSH's C{ssh_config} man page. This class is provided primarily as a
85- convenience to posix users (since the OpenSSH format is a de-facto
86- standard on posix) but should work fine on Windows too.
87-
88- @since: 1.6
89- """
90-
91- def __init__(self):
92- """
93- Create a new OpenSSH config object.
94- """
95- self._config = [ { 'host': '*' } ]
96-
97- def parse(self, file_obj):
98- """
99- Read an OpenSSH config from the given file object.
100-
101- @param file_obj: a file-like object to read the config file from
102- @type file_obj: file
103- """
104- configs = [self._config[0]]
105- for line in file_obj:
106- line = line.rstrip('\n').lstrip()
107- if (line == '') or (line[0] == '#'):
108- continue
109- if '=' in line:
110- key, value = line.split('=', 1)
111- key = key.strip().lower()
112- else:
113- # find first whitespace, and split there
114- i = 0
115- while (i < len(line)) and not line[i].isspace():
116- i += 1
117- if i == len(line):
118- raise Exception('Unparsable line: %r' % line)
119- key = line[:i].lower()
120- value = line[i:].lstrip()
121-
122- if key == 'host':
123- del configs[:]
124- # the value may be multiple hosts, space-delimited
125- for host in value.split():
126- # do we have a pre-existing host config to append to?
127- matches = [c for c in self._config if c['host'] == host]
128- if len(matches) > 0:
129- configs.append(matches[0])
130- else:
131- config = { 'host': host }
132- self._config.append(config)
133- configs.append(config)
134- else:
135- for config in configs:
136- config[key] = value
137-
138- def lookup(self, hostname):
139- """
140- Return a dict of config options for a given hostname.
141-
142- The host-matching rules of OpenSSH's C{ssh_config} man page are used,
143- which means that all configuration options from matching host
144- specifications are merged, with more specific hostmasks taking
145- precedence. In other words, if C{"Port"} is set under C{"Host *"}
146- and also C{"Host *.example.com"}, and the lookup is for
147- C{"ssh.example.com"}, then the port entry for C{"Host *.example.com"}
148- will win out.
149-
150- The keys in the returned dict are all normalized to lowercase (look for
151- C{"port"}, not C{"Port"}. No other processing is done to the keys or
152- values.
153-
154- @param hostname: the hostname to lookup
155- @type hostname: str
156- """
157- matches = [
158- x for x in self._config if fnmatch.fnmatch(hostname, x['host'])]
159- # sort in order of shortest match (usually '*') to longest
160- matches.sort(lambda x,y: cmp(len(x['host']), len(y['host'])))
161- ret = {}
162- for m in matches:
163- ret.update(m)
164- del ret['host']
165- return ret
166-
167-# END paramiko config fork
168-#############################################################################
169
170=== modified file 'lib/devscripts/ec2test/testrunner.py'
171--- lib/devscripts/ec2test/testrunner.py 2009-09-18 02:23:13 +0000
172+++ lib/devscripts/ec2test/testrunner.py 2009-09-26 22:37:14 +0000
173@@ -400,12 +400,6 @@
174 user_connection = self._instance.connect_as_user()
175 # Clean up the test branch left in the instance image.
176 user_connection.perform('rm -rf /var/launchpad/test')
177- # get newest sources
178- user_connection.run_with_ssh_agent(
179- "rsync -avp --partial --delete "
180- "--filter='P *.o' --filter='P *.pyc' --filter='P *.so' "
181- "devpad.canonical.com:/code/rocketfuel-built/launchpad/sourcecode/* "
182- "/var/launchpad/sourcecode/")
183 # Get trunk.
184 user_connection.run_with_ssh_agent(
185 'bzr branch %(trunk_branch)s /var/launchpad/test')
186@@ -415,6 +409,10 @@
187 'cd /var/launchpad/test; bzr merge %(branch)s')
188 else:
189 self.log('(Testing trunk, so no branch merge.)')
190+ # get newest sources
191+ user_connection.run_with_ssh_agent(
192+ "/var/launchpad/test/utilities/update-sourcecode "
193+ "/var/launchpad/sourcecode")
194 # Get any new sourcecode branches as requested
195 for dest, src in self.branches:
196 fulldest = os.path.join('/var/launchpad/test/sourcecode', dest)
197
198=== modified file 'utilities/update-sourcecode'
199--- utilities/update-sourcecode 2009-09-10 04:31:12 +0000
200+++ utilities/update-sourcecode 2009-09-26 22:37:14 +0000
201@@ -5,10 +5,12 @@
202
203 """Update the sourcecode managed in sourcecode/."""
204
205-import _pythonpath
206-
207+import os
208 import sys
209
210+sys.path.append(
211+ os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib'))
212+
213 from devscripts import sourcecode
214
215