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
=== modified file 'lib/devscripts/ec2test/instance.py'
--- lib/devscripts/ec2test/instance.py 2010-03-21 15:19:26 +0000
+++ lib/devscripts/ec2test/instance.py 2010-04-01 14:21:08 +0000
@@ -128,7 +128,7 @@
128aptitude update128aptitude update
129aptitude -y full-upgrade129aptitude -y full-upgrade
130130
131apt-get -y install launchpad-developer-dependencies apache2 apache2-mpm-worker131DEBIAN_FRONTEND=noninteractive apt-get -y install launchpad-developer-dependencies apache2 apache2-mpm-worker
132132
133# Create the ec2test user, give them passwordless sudo.133# Create the ec2test user, give them passwordless sudo.
134adduser --gecos "" --disabled-password ec2test134adduser --gecos "" --disabled-password ec2test
@@ -357,16 +357,17 @@
357 """357 """
358 if not self._ec2test_user_has_keys:358 if not self._ec2test_user_has_keys:
359 if connection is None:359 if connection is None:
360 connection = self._connect('root')360 connection = self._connect('ubuntu')
361 our_connection = True361 our_connection = True
362 else:362 else:
363 our_connection = False363 our_connection = False
364 self._upload_local_key(connection, 'local_key')364 self._upload_local_key(connection, 'local_key')
365 connection.perform(365 connection.perform(
366 'cat /root/.ssh/authorized_keys local_key '366 'cat /home/ubuntu/.ssh/authorized_keys local_key '
367 '> /home/ec2test/.ssh/authorized_keys && rm local_key')367 '| sudo tee /home/ec2test/.ssh/authorized_keys > /dev/null'
368 connection.perform('chown -R ec2test:ec2test /home/ec2test/')368 '&& rm local_key')
369 connection.perform('chmod 644 /home/ec2test/.ssh/*')369 connection.perform('sudo chown -R ec2test:ec2test /home/ec2test/')
370 connection.perform('sudo chmod 644 /home/ec2test/.ssh/*')
370 if our_connection:371 if our_connection:
371 connection.close()372 connection.close()
372 self.log(373 self.log(
@@ -382,13 +383,13 @@
382 lot of set up.383 lot of set up.
383 """384 """
384 if self._from_scratch:385 if self._from_scratch:
385 root_connection = self._connect('root')386 ubuntu_connection = self._connect('ubuntu')
386 self._upload_local_key(root_connection, 'local_key')387 self._upload_local_key(ubuntu_connection, 'local_key')
387 root_connection.perform(388 ubuntu_connection.perform(
388 'cat local_key >> ~/.ssh/authorized_keys && rm local_key')389 'cat local_key >> ~/.ssh/authorized_keys && rm local_key')
389 root_connection.run_script(from_scratch_root)390 ubuntu_connection.run_script(from_scratch_root, sudo=True)
390 self._ensure_ec2test_user_has_keys(root_connection)391 self._ensure_ec2test_user_has_keys(ubuntu_connection)
391 root_connection.close()392 ubuntu_connection.close()
392 conn = self._connect('ec2test')393 conn = self._connect('ec2test')
393 conn.run_script(394 conn.run_script(
394 from_scratch_ec2test395 from_scratch_ec2test
@@ -644,12 +645,15 @@
644 raise RuntimeError('Command failed: %s' % (cmd,))645 raise RuntimeError('Command failed: %s' % (cmd,))
645 return res646 return res
646647
647 def run_script(self, script_text):648 def run_script(self, script_text, sudo=False):
648 """Upload `script_text` to the instance and run it with bash."""649 """Upload `script_text` to the instance and run it with bash."""
649 script = self.sftp.open('script.sh', 'w')650 script = self.sftp.open('script.sh', 'w')
650 script.write(script_text)651 script.write(script_text)
651 script.close()652 script.close()
652 self.run_with_ssh_agent('/bin/bash script.sh')653 cmd = '/bin/bash script.sh'
654 if sudo:
655 cmd = 'sudo ' + cmd
656 self.run_with_ssh_agent(cmd)
653 # At least for mwhudson, the paramiko connection often drops while the657 # At least for mwhudson, the paramiko connection often drops while the
654 # script is running. Reconnect just in case.658 # script is running. Reconnect just in case.
655 self.reconnect()659 self.reconnect()
656660
=== modified file 'lib/devscripts/ec2test/testrunner.py'
--- lib/devscripts/ec2test/testrunner.py 2010-03-18 21:48:57 +0000
+++ lib/devscripts/ec2test/testrunner.py 2010-04-01 14:21:08 +0000
@@ -321,7 +321,7 @@
321 as_user = user_connection.perform321 as_user = user_connection.perform
322 # Set up bazaar.conf with smtp information if necessary322 # Set up bazaar.conf with smtp information if necessary
323 if self.email or self.message:323 if self.email or self.message:
324 as_user('mkdir .bazaar')324 as_user('[ -d .bazaar ] || mkdir .bazaar')
325 bazaar_conf_file = user_connection.sftp.open(325 bazaar_conf_file = user_connection.sftp.open(
326 ".bazaar/bazaar.conf", 'w')326 ".bazaar/bazaar.conf", 'w')
327 bazaar_conf_file.write(327 bazaar_conf_file.write(

Subscribers

People subscribed via source and target branches

to status/vote changes: