Merge lp:~salgado/launchpad/ec-log-in-as-ubuntu into lp:launchpad/db-devel

Proposed by Guilherme Salgado
Status: Merged
Approved by: Jonathan Lange
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~salgado/launchpad/ec-log-in-as-ubuntu
Merge into: lp:launchpad/db-devel
Diff against target: 86 lines (+19/-15)
2 files modified
lib/devscripts/ec2test/instance.py (+18/-14)
lib/devscripts/ec2test/testrunner.py (+1/-1)
To merge this branch: bzr merge lp:~salgado/launchpad/ec-log-in-as-ubuntu
Reviewer Review Type Date Requested Status
Jonathan Lange (community) Approve
Review via email: mp+22620@code.launchpad.net

Description of the change

This branch changes our ec2 utilities so that we can use them to build a
Launchpad-ready AMI using the official Ubuntu AMIs. This will make it
trivial for us to generate a Lucid AMI when the time comes.

The branch is originally from Michael Hudson, but I was asked to build
an AMI (based on the official images) to be used by ect-test, so I'll
have to land his changes to make the new AMI usable.

--
Guilherme Salgado <email address hidden>

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

This looks fine to me. Please land.

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/instance.py'
2--- lib/devscripts/ec2test/instance.py 2010-03-21 15:19:26 +0000
3+++ lib/devscripts/ec2test/instance.py 2010-04-01 14:21:08 +0000
4@@ -128,7 +128,7 @@
5 aptitude update
6 aptitude -y full-upgrade
7
8-apt-get -y install launchpad-developer-dependencies apache2 apache2-mpm-worker
9+DEBIAN_FRONTEND=noninteractive apt-get -y install launchpad-developer-dependencies apache2 apache2-mpm-worker
10
11 # Create the ec2test user, give them passwordless sudo.
12 adduser --gecos "" --disabled-password ec2test
13@@ -357,16 +357,17 @@
14 """
15 if not self._ec2test_user_has_keys:
16 if connection is None:
17- connection = self._connect('root')
18+ connection = self._connect('ubuntu')
19 our_connection = True
20 else:
21 our_connection = False
22 self._upload_local_key(connection, 'local_key')
23 connection.perform(
24- 'cat /root/.ssh/authorized_keys local_key '
25- '> /home/ec2test/.ssh/authorized_keys && rm local_key')
26- connection.perform('chown -R ec2test:ec2test /home/ec2test/')
27- connection.perform('chmod 644 /home/ec2test/.ssh/*')
28+ 'cat /home/ubuntu/.ssh/authorized_keys local_key '
29+ '| sudo tee /home/ec2test/.ssh/authorized_keys > /dev/null'
30+ '&& rm local_key')
31+ connection.perform('sudo chown -R ec2test:ec2test /home/ec2test/')
32+ connection.perform('sudo chmod 644 /home/ec2test/.ssh/*')
33 if our_connection:
34 connection.close()
35 self.log(
36@@ -382,13 +383,13 @@
37 lot of set up.
38 """
39 if self._from_scratch:
40- root_connection = self._connect('root')
41- self._upload_local_key(root_connection, 'local_key')
42- root_connection.perform(
43+ ubuntu_connection = self._connect('ubuntu')
44+ self._upload_local_key(ubuntu_connection, 'local_key')
45+ ubuntu_connection.perform(
46 'cat local_key >> ~/.ssh/authorized_keys && rm local_key')
47- root_connection.run_script(from_scratch_root)
48- self._ensure_ec2test_user_has_keys(root_connection)
49- root_connection.close()
50+ ubuntu_connection.run_script(from_scratch_root, sudo=True)
51+ self._ensure_ec2test_user_has_keys(ubuntu_connection)
52+ ubuntu_connection.close()
53 conn = self._connect('ec2test')
54 conn.run_script(
55 from_scratch_ec2test
56@@ -644,12 +645,15 @@
57 raise RuntimeError('Command failed: %s' % (cmd,))
58 return res
59
60- def run_script(self, script_text):
61+ def run_script(self, script_text, sudo=False):
62 """Upload `script_text` to the instance and run it with bash."""
63 script = self.sftp.open('script.sh', 'w')
64 script.write(script_text)
65 script.close()
66- self.run_with_ssh_agent('/bin/bash script.sh')
67+ cmd = '/bin/bash script.sh'
68+ if sudo:
69+ cmd = 'sudo ' + cmd
70+ self.run_with_ssh_agent(cmd)
71 # At least for mwhudson, the paramiko connection often drops while the
72 # script is running. Reconnect just in case.
73 self.reconnect()
74
75=== modified file 'lib/devscripts/ec2test/testrunner.py'
76--- lib/devscripts/ec2test/testrunner.py 2010-03-18 21:48:57 +0000
77+++ lib/devscripts/ec2test/testrunner.py 2010-04-01 14:21:08 +0000
78@@ -321,7 +321,7 @@
79 as_user = user_connection.perform
80 # Set up bazaar.conf with smtp information if necessary
81 if self.email or self.message:
82- as_user('mkdir .bazaar')
83+ as_user('[ -d .bazaar ] || mkdir .bazaar')
84 bazaar_conf_file = user_connection.sftp.open(
85 ".bazaar/bazaar.conf", 'w')
86 bazaar_conf_file.write(

Subscribers

People subscribed via source and target branches

to status/vote changes: