launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #10981
[Merge] lp:~bac/lpsetup/host2target into lp:lpsetup
Brad Crittenden has proposed merging lp:~bac/lpsetup/host2target into lp:lpsetup.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~bac/lpsetup/host2target/+merge/119795
Change 'host' to 'target' everywhere to make it less confusing.
--
https://code.launchpad.net/~bac/lpsetup/host2target/+merge/119795
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~bac/lpsetup/host2target into lp:lpsetup.
=== modified file 'README.rst'
--- README.rst 2012-07-30 18:56:59 +0000
+++ README.rst 2012-08-15 21:09:20 +0000
@@ -88,7 +88,7 @@
long as you specify using the '-e' command line option. The tests
are in lpsetup/tests/integration.
-The first, *test_init_host.py*, only tests the *init-host* command but
+The first, *test_init_target.py*, only tests the *init-target* command but
goes no further. The second, *test_install_lxc.py*, tests
*install-lxc*. If this test is run against a local LXC environment,
some changes need are first required to the host machine where the
=== modified file 'commands.rst'
--- commands.rst 2012-07-19 17:48:40 +0000
+++ commands.rst 2012-08-15 21:09:20 +0000
@@ -6,7 +6,7 @@
usage: lp-setup [-h]
- {finish-init-host,init-host,init-lxc,init-repo,install-lxc,update,version,help}
+ {finish-init-target,init-target,init-lxc,init-repo,install-lxc,update,version,help}
...
Create and update Launchpad development and testing environments.
@@ -15,11 +15,11 @@
-h, --help show this help message and exit
subcommands:
- {finish-init-host,init-host,init-lxc,init-repo,install-lxc,update,version,help}
+ {finish-init-target,init-target,init-lxc,init-repo,install-lxc,update,version,help}
Each subcommand accepts --h or --help to describe it.
- finish-init-host Finish the initialization of a Launchpad development
- host.
- init-host Prepare a machine to run Launchpad. May be an LXC
+ finish-init-target Finish the initialization of a Launchpad development
+ target.
+ init-target Prepare a machine to run Launchpad. May be an LXC
container or not.
init-lxc Create an LXC container suitable for later installing
a Launchpad development environment.
@@ -69,14 +69,14 @@
Create an LXC container suitable for later installing a Launchpad
development environment. The `lpsetup` package is installed in the
-container and `init-host` is called. The LXC container is shutdown at
+container and `init-target` is called. The LXC container is shutdown at
the end of the command.
Run as root on the host machine.
-init-host
-~~~~~~~~~
+init-target
+~~~~~~~~~~~
Prepare a machine to run Launchpad. It may be a host machine or an
LXC container. It installs the base packages, creates the specified
@@ -108,8 +108,8 @@
Run as the user in the Launchpad target, either a host machine or LXC
container.
-finish-init-host
-~~~~~~~~~~~~~~~~
+finish-init-target
+~~~~~~~~~~~~~~~~~~
Finish the initialization of a Launchpad development host.
@@ -118,7 +118,7 @@
been retrieved and run as root.
Run as root in the Launchpad target, either a host machine or LXC
-container. Must be done after `init-host` and `init-repo` have
+container. Must be done after `init-target` and `init-repo` have
completed.
TODO: rename to finish-init-target
=== modified file 'lpsetup/cli.py'
--- lpsetup/cli.py 2012-08-13 08:42:08 +0000
+++ lpsetup/cli.py 2012-08-15 21:09:20 +0000
@@ -19,8 +19,8 @@
exceptions,
)
from lpsetup.subcommands import (
- finish_inithost,
- inithost,
+ finish_init_target,
+ init_target,
initlxc,
initrepo,
install_lxc,
@@ -31,8 +31,8 @@
SUBCOMMANDS = [
- ('finish-init-host', finish_inithost.SubCommand()),
- ('init-host', inithost.SubCommand()),
+ ('finish-init-target', finish_init_target.SubCommand()),
+ ('init-target', init_target.SubCommand()),
('init-lxc', initlxc.SubCommand()),
('init-repo', initrepo.SubCommand()),
('install-lxc', install_lxc.SubCommand()),
=== renamed file 'lpsetup/subcommands/finish_inithost.py' => 'lpsetup/subcommands/finish_init_target.py'
=== renamed file 'lpsetup/subcommands/inithost.py' => 'lpsetup/subcommands/init_target.py'
--- lpsetup/subcommands/inithost.py 2012-08-09 15:32:08 +0000
+++ lpsetup/subcommands/init_target.py 2012-08-15 21:09:20 +0000
@@ -2,7 +2,7 @@
# Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-"""inithost subcommand: prepare a host machine to run Launchpad."""
+"""init-target subcommand: prepare a target machine to run Launchpad."""
__metaclass__ = type
__all__ = [
@@ -133,7 +133,7 @@
def initialize_base(user):
- """Perform base initialization shared by inithost and initlxc."""
+ """Perform base initialization shared by init-target and init-lxc."""
# Install necessary deb packages. This requires Oneiric or later.
call('apt-get', 'update')
apt_get_install(*BASE_PACKAGES, caller=call)
@@ -148,7 +148,7 @@
def initialize(user):
- """Initialize host machine."""
+ """Initialize target machine."""
make_version_dir()
initialize_base(user)
with su(user):
@@ -159,7 +159,7 @@
for module in LP_APACHE_MODULES.split():
call('a2enmod', module)
- # The user must be added to sudoers if inithost is run in a container
+ # The user must be added to sudoers if init-target is run in a container
# and we are running the developer story.
# XXX 2012-07-18 frankban: add the developer/testing check.
if running_in_container():
@@ -188,11 +188,11 @@
This is a separate step for several reasons::
- - It is directly called by *initlxc* as one of its first steps.
- Note that *initlxc* needs the user's `.ssh` dir to be set up
+ - It is directly called by *init-lxc* as one of its first steps.
+ Note that *init-lxc* needs the user's `.ssh` dir to be set up
to be able to connect to the container.
- - *initlxc* should be able to skip this step when re-executing
- *inithost* from inside the container, to avoid setting up the
+ - *init-lxc* should be able to skip this step when re-executing
+ *init-target* from inside the container, to avoid setting up the
user home two times. Note: the user home is bind mounted by lxc.
"""
with su(user) as env:
=== modified file 'lpsetup/subcommands/initlxc.py'
--- lpsetup/subcommands/initlxc.py 2012-08-09 15:32:08 +0000
+++ lpsetup/subcommands/initlxc.py 2012-08-15 21:09:20 +0000
@@ -2,7 +2,7 @@
# Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-"""initlxc subcommand: prepare an LXC container to run Launchpad.
+"""init-lxc subcommand: prepare an LXC container to run Launchpad.
Run as root on the host machine to create an LXC container that can later be
used to install a Launchpad development environment.
@@ -11,7 +11,7 @@
__metaclass__ = type
__all__ = [
'create_lxc',
- 'inithost_in_lxc',
+ 'init_target_in_lxc',
'initialize',
'install_lpsetup_in_lxc',
'start_lxc',
@@ -45,7 +45,7 @@
LXC_PACKAGES,
PY26_PACKAGES,
)
-from lpsetup.subcommands import inithost
+from lpsetup.subcommands import init_target
from lpsetup.utils import (
call,
get_container_path,
@@ -60,13 +60,13 @@
def initialize(user, install_haveged):
"""Initialize the LXC host."""
- inithost.initialize_base(user)
+ init_target.initialize_base(user)
if install_haveged:
# haveged is used to fill /dev/random, avoiding
# entropy exhaustion during automated parallel tests.
apt_get_install('haveged', caller=call)
-initialize.description = inithost.initialize_base.description + """If \
+initialize.description = init_target.initialize_base.description + """If \
requested, install haveged in order to fill /dev/random, avoiding \
entropy exhaustion during automated parallel tests.
"""
@@ -207,16 +207,16 @@
install_lpsetup_in_lxc.description = None
-def inithost_in_lxc(lxc_name, ssh_key_path, user, email, full_name, lpuser,
+def init_target_in_lxc(lxc_name, ssh_key_path, user, email, full_name, lpuser,
ssh_key_name, home_dir):
"""Prepare the Launchpad environment inside an LXC."""
# Use ssh to call this script from inside the container.
- args = ['init-host', '--yes', '-u', user, '-E', email, '-f', full_name,
+ args = ['init-target', '--yes', '-u', user, '-E', email, '-f', full_name,
'-l', lpuser, '-S', ssh_key_name, '--skip-steps', 'setup_home']
cmd = this_command(home_dir, args)
ssh(lxc_name, cmd, key=ssh_key_path)
-inithost_in_lxc.description = 'Initialize the LXC instance $lxc_name.\n'
+init_target_in_lxc.description = 'Initialize the LXC instance $lxc_name.\n'
def stop_lxc(lxc_name, ssh_key_path):
@@ -228,7 +228,7 @@
stop_lxc.description = 'Stop the LXC instance $lxc_name.\n'
-class SubCommand(inithost.SubCommand):
+class SubCommand(init_target.SubCommand):
"""Create an LXC container suitable for later installing a Launchpad
development environment.
"""
@@ -242,8 +242,8 @@
install_lpsetup_in_lxc,
['lxc_name', 'ssh_key_path', 'lxc_os', 'user', 'home_dir',
'lpsetup_branch'])
- inithost_in_lxc_step = (
- inithost_in_lxc,
+ init_target_in_lxc_step = (
+ init_target_in_lxc,
['lxc_name', 'ssh_key_path', 'user', 'email', 'full_name', 'lpuser',
'ssh_key_name', 'home_dir'])
stop_lxc_step = (
@@ -252,12 +252,12 @@
base_steps = (
(initialize, ['user', 'install_haveged']),
- inithost.SubCommand.setup_home_step,
+ init_target.SubCommand.setup_home_step,
create_lxc_step,
start_lxc_step,
wait_for_lxc_step,
install_lpsetup_in_lxc_step,
- inithost_in_lxc_step,
+ init_target_in_lxc_step,
)
steps = base_steps + (stop_lxc_step,)
=== modified file 'lpsetup/subcommands/install_lxc.py'
--- lpsetup/subcommands/install_lxc.py 2012-08-09 15:32:08 +0000
+++ lpsetup/subcommands/install_lxc.py 2012-08-15 21:09:20 +0000
@@ -7,7 +7,7 @@
__metaclass__ = type
__all__ = [
'create_scripts',
- 'finish_inithost_in_lxc',
+ 'finish_init_target_in_lxc',
'init_repo_in_lxc',
'SubCommand',
'update_in_lxc',
@@ -117,12 +117,12 @@
update.update_tree.description)
-def finish_inithost_in_lxc(
+def finish_init_target_in_lxc(
lxc_name, ssh_key_path, home_dir, user, target_dir):
- args = ['finish-init-host', target_dir, '--user', user, '--yes']
+ args = ['finish-init-target', target_dir, '--user', user, '--yes']
cmd_in_lxc(lxc_name, ssh_key_path, home_dir, args)
-finish_inithost_in_lxc.description = """Set up the database, make and \
+finish_init_target_in_lxc.description = """Set up the database, make and \
install Launchpad inside the LXC instance $lxc_name.
"""
@@ -141,7 +141,7 @@
(update_in_lxc,
['lxc_name', 'ssh_key_path', 'home_dir', 'user', 'external_path',
'target_dir', 'lp_source_deps', 'use_http']),
- (finish_inithost_in_lxc,
+ (finish_init_target_in_lxc,
['lxc_name', 'ssh_key_path', 'home_dir', 'user', 'target_dir']),
# Run on host:
initlxc.SubCommand.stop_lxc_step,
=== renamed file 'lpsetup/tests/integration/test_init_host.py' => 'lpsetup/tests/integration/test_init_target.py'
--- lpsetup/tests/integration/test_init_host.py 2012-07-27 08:07:45 +0000
+++ lpsetup/tests/integration/test_init_target.py 2012-08-15 21:09:20 +0000
@@ -2,7 +2,7 @@
# Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-"""A simple, integration test of init-host.
+"""A simple, integration test of init-target.
Tests initialization of the host without init-lxc in order to demonstrate that
it can be run in isolation, as part of a non-LXC environment.
@@ -13,22 +13,22 @@
from common import IntegrationTestBase
-class InitHostTest(IntegrationTestBase):
+class InitTargetTest(IntegrationTestBase):
- test_type = 'init-host tests'
+ test_type = 'init-target tests'
default_juju_env = 'lpsetup-testing-ec2'
juju_target = 'ubuntu/0'
def do_test(self):
- """Run an integration test that only address host issues.
+ """Run an integration test that only address target issues.
- Can be run on EC2 or LXC as the host machine.
+ Can be run on EC2 or LXC as the target machine.
"""
# Since the most common scenario is to have bzr whoami setup, we do
# that instead of providing the arguments directly to lpsetup.
- super(InitHostTest, self).do_test()
- self.on_remote('cd lpsetup; ./lp-setup init-host --yes')
+ super(InitTargetTest, self).do_test()
+ self.on_remote('cd lpsetup; ./lp-setup init-target --yes')
if __name__ == '__main__':
- sys.exit(InitHostTest().run())
+ sys.exit(InitTargetTest().run())
=== renamed file 'lpsetup/tests/subcommands/test_inithost.py' => 'lpsetup/tests/subcommands/test_init_target.py'
--- lpsetup/tests/subcommands/test_inithost.py 2012-08-10 15:30:47 +0000
+++ lpsetup/tests/subcommands/test_init_target.py 2012-08-15 21:09:20 +0000
@@ -2,7 +2,7 @@
# Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-"""Tests for the inithost subcommand."""
+"""Tests for the init-target subcommand."""
import os
import shutil
@@ -10,12 +10,12 @@
import tempfile
import unittest
-from lpsetup.subcommands import inithost
+from lpsetup.subcommands import init_target
from lpsetup.tests.utils import get_random_string
class WriteFileContentsTestCase(unittest.TestCase):
- """Tests for inithost.write_file_contents()."""
+ """Tests for init_target.write_file_contents()."""
def setUp(self):
temp_file = tempfile.NamedTemporaryFile()
@@ -25,11 +25,12 @@
self.temp_filename = temp_file.name
def test_write_file_contents_writes_file_contents(self):
- # inithost.write_file_contents writes the supplied file contents
+ # init_target.write_file_contents writes the supplied file contents
# to a given file using the mode provided and chmods the file to
# 0644 for the current user.
self.addCleanup(os.remove, self.temp_filename)
- inithost.write_file_contents(self.temp_filename, 'Hello, world!', 'w')
+ init_target.write_file_contents(
+ self.temp_filename, 'Hello, world!', 'w')
with open(self.temp_filename, 'r') as the_file:
contents = the_file.read()
self.assertEqual('Hello, world!', contents)
@@ -47,29 +48,32 @@
# contents differ from `contents`, write_file_contents() raises an
# Exception.
self.addCleanup(os.remove, self.temp_filename)
- inithost.write_file_contents(self.temp_filename, 'Hello, world!', 'w')
+ init_target.write_file_contents(
+ self.temp_filename, 'Hello, world!', 'w')
self.assertRaises(
- Exception, inithost.write_file_contents, self.temp_filename,
+ Exception, init_target.write_file_contents, self.temp_filename,
'Hello again!', 'w')
def test_write_file_contents_returns_if_file_contents_dont_change(self):
# If the existing file's contents don't differ from `contents`,
# write_file_contents() will simply return.
self.addCleanup(os.remove, self.temp_filename)
- inithost.write_file_contents(self.temp_filename, 'Hello, world!', 'w')
+ init_target.write_file_contents(
+ self.temp_filename, 'Hello, world!', 'w')
# This second call shouldn't raise an exception.
- inithost.write_file_contents(self.temp_filename, 'Hello, world!', 'w')
+ init_target.write_file_contents(
+ self.temp_filename, 'Hello, world!', 'w')
def test_write_file_contents_accepts_modes_a_or_w(self):
# Passing a `mode` other than "a" or "w" to write_file_contents()
# will cause an Exception.
self.assertRaises(
- AssertionError, inithost.write_file_contents,
+ AssertionError, init_target.write_file_contents,
'/tmp/foo', 'Hello, world!', 'a+')
class SetupSSHTest(unittest.TestCase):
- """Tests for inithost.setup_ssh()."""
+ """Tests for init_target.setup_ssh()."""
def setUp(self):
temp_file = tempfile.NamedTemporaryFile()
@@ -82,14 +86,14 @@
def test_setup_ssh_generates_keys_if_not_present(self):
# If SSH keys do not exist, the function will generate some.
- inithost.setup_ssh(self.ssh_dir, False, self.temp_filename)
+ init_target.setup_ssh(self.ssh_dir, False, self.temp_filename)
self.assertTrue(os.path.exists(self.temp_filename))
self.assertTrue(os.path.exists(self.temp_filename + '.pub'))
def test_setup_ssh_generates_authorized_keys(self):
# setup_ssh() also generates an authorized_keys file containing
# the public key.
- inithost.setup_ssh(self.ssh_dir, False, self.temp_filename)
+ init_target.setup_ssh(self.ssh_dir, False, self.temp_filename)
authorized_keys = os.path.join(self.ssh_dir, 'authorized_keys')
self.assertTrue(os.path.exists(authorized_keys))
public_key = open(self.temp_filename + '.pub').read()
@@ -98,7 +102,7 @@
def test_setup_ssh_generates_known_hosts(self):
# setup_ssh() also generates a `known_host` file containing
# 'bazaar.launchpad.net'.
- inithost.setup_ssh(self.ssh_dir, False, self.temp_filename)
+ init_target.setup_ssh(self.ssh_dir, False, self.temp_filename)
known_hosts = os.path.join(self.ssh_dir, 'known_hosts')
self.assertTrue(os.path.exists(known_hosts))
self.assertIn('bazaar.launchpad.net', open(known_hosts).read())
@@ -107,7 +111,7 @@
# If the ssh_dir passed to setup_ssh() doesn't exist, it
# will be created.
shutil.rmtree(self.ssh_dir)
- inithost.setup_ssh(self.ssh_dir, False, self.temp_filename)
+ init_target.setup_ssh(self.ssh_dir, False, self.temp_filename)
self.assertTrue(os.path.exists(self.ssh_dir))
self.assertTrue(os.path.isdir(self.ssh_dir))
@@ -123,14 +127,14 @@
def test_version_dir_creation(self):
# If the version path does not exist, it is created.
- inithost.make_version_dir(mkdirs=self.mkdirs)
- self.assertIn(inithost.get_version_path(), self.directories_made)
+ init_target.make_version_dir(mkdirs=self.mkdirs)
+ self.assertIn(init_target.get_version_path(), self.directories_made)
def test_originals_dir_creation(self):
# If the version path contains an "originals" directory for backups of
# files that we modify.
- inithost.make_version_dir(mkdirs=self.mkdirs)
- self.assertIn(inithost.get_version_path(), self.directories_made)
+ init_target.make_version_dir(mkdirs=self.mkdirs)
+ self.assertIn(init_target.get_version_path(), self.directories_made)
def create(filename, contents=None):
@@ -156,7 +160,7 @@
destination_dir = lambda: self.tempdir
contents = get_random_string()
create(source, contents)
- inithost.make_backup(source, destination_dir)
+ init_target.make_backup(source, destination_dir)
get_backup_path = destination_dir() + os.path.sep + source
self.assertTrue(os.path.exists(get_backup_path))
self.assertEqual(file(get_backup_path).read(), contents)
=== modified file 'lpsetup/tests/subcommands/test_smoke.py'
--- lpsetup/tests/subcommands/test_smoke.py 2012-08-10 08:34:16 +0000
+++ lpsetup/tests/subcommands/test_smoke.py 2012-08-15 21:09:20 +0000
@@ -27,8 +27,8 @@
# and verify that a non-error exit code is returned.
required_args = ['-f', 'Example User', '-E', 'email@xxxxxxxxxxx']
name_args_map = {
- 'finish-init-host': [],
- 'init-host': required_args,
+ 'finish-init-target': [],
+ 'init-target': required_args,
'init-lxc': required_args,
'init-repo': [],
'install-lxc': required_args,