Merge lp:~bac/lpsetup/refactor-install into lp:lpsetup

Proposed by Brad Crittenden on 2012-07-06
Status: Merged
Approved by: Gary Poster on 2012-07-06
Approved revision: 44
Merged at revision: 44
Proposed branch: lp:~bac/lpsetup/refactor-install
Merge into: lp:lpsetup
Diff against target: 175 lines (+36/-28)
4 files modified
lpsetup/cli.py (+5/-5)
lpsetup/subcommands/finish_inithost.py (+6/-18)
lpsetup/subcommands/inithost.py (+20/-1)
lpsetup/tests/subcommands/test_finish_inithost.py (+5/-4)
To merge this branch: bzr merge lp:~bac/lpsetup/refactor-install
Reviewer Review Type Date Requested Status
Gary Poster (community) 2012-07-06 Approve on 2012-07-06
Review via email: mp+113753@code.launchpad.net

Commit Message

Move portions of the 'install' subcommand that do not depend on having a Launchpad tree elsewhere. Also rename 'install' to 'finish_inithost'. It is the intent for this command to eventually go away, though that may be some time from now.

Description of the Change

Move portions of the 'install' subcommand that do not depend on having
a Launchpad tree elsewhere. Also rename 'install' to
'finish_inithost'. It is the intent for this command to eventually go
away.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lpsetup/cli.py'
2--- lpsetup/cli.py 2012-07-05 18:38:51 +0000
3+++ lpsetup/cli.py 2012-07-06 15:01:30 +0000
4@@ -16,20 +16,20 @@
5 exceptions,
6 )
7 from lpsetup.subcommands import (
8+ finish_inithost,
9 inithost,
10 initlxc,
11 initrepo,
12- install,
13 lxcinstall,
14 version,
15 )
16
17
18 subcommands = [
19- ('install', install.SubCommand),
20- ('inithost', inithost.SubCommand),
21- ('initlxc', initlxc.SubCommand),
22- ('initrepo', initrepo.SubCommand),
23+ ('finish-init-host', finish_inithost.SubCommand),
24+ ('init-host', inithost.SubCommand),
25+ ('init-lxc', initlxc.SubCommand),
26+ ('init-repo', initrepo.SubCommand),
27 ('lxc-install', lxcinstall.SubCommand),
28 ('version', version.SubCommand),
29 ]
30
31=== renamed file 'lpsetup/subcommands/install.py' => 'lpsetup/subcommands/finish_inithost.py'
32--- lpsetup/subcommands/install.py 2012-07-05 18:38:51 +0000
33+++ lpsetup/subcommands/finish_inithost.py 2012-07-06 15:01:30 +0000
34@@ -17,9 +17,7 @@
35
36 from shelltoolbox import (
37 cd,
38- file_append,
39 get_su_command,
40- mkdirs,
41 su,
42 )
43
44@@ -31,10 +29,6 @@
45 from lpsetup.settings import (
46 CHECKOUT_DIR,
47 DEPENDENCIES_DIR,
48- HOSTS_CONTENT,
49- HOSTS_FILE,
50- LP_APACHE_MODULES,
51- LP_APACHE_ROOTS,
52 LP_BRANCH_NAME,
53 )
54 from lpsetup.utils import call
55@@ -75,26 +69,20 @@
56 pwd_database = pwd.getpwnam(user)
57 subprocess.call(['addgroup', '--gid', str(pwd_database.pw_gid), user])
58 # Set up Launchpad dependencies.
59+ # XXX: Eventually move to 'update'.
60 checkout_dir = os.path.join(repository, LP_BRANCH_NAME)
61 setup_external_sourcecode(
62 user, checkout_dir, dependencies_dir, valid_ssh_keys)
63- with su(user):
64- # Create Apache document roots, to avoid warnings.
65- mkdirs(*LP_APACHE_ROOTS)
66- # Set up Apache modules.
67- for module in LP_APACHE_MODULES.split():
68- call('a2enmod', module)
69- with cd(checkout_dir):
70- # Launchpad database setup.
71+
72+ # Launchpad database setup.
73+ with su(user), cd(checkout_dir):
74 call('utilities/launchpad-database-setup', user)
75+
76 # Make and install launchpad.
77 make_launchpad(user, checkout_dir, install=True)
78+
79 # Change owner of /srv/launchpad.dev/.
80 os.chown('/srv/launchpad.dev/', pwd_database.pw_uid, pwd_database.pw_gid)
81- # Set up container hosts file.
82- lines = ['{0}\t{1}\n'.format(ip, names) for ip, names in HOSTS_CONTENT]
83- for line in lines:
84- file_append(HOSTS_FILE, line)
85
86
87 def setup_bzr_locations_as_root(user, lpuser, repository):
88
89=== modified file 'lpsetup/subcommands/inithost.py'
90--- lpsetup/subcommands/inithost.py 2012-07-05 18:38:51 +0000
91+++ lpsetup/subcommands/inithost.py 2012-07-06 15:01:30 +0000
92@@ -17,6 +17,7 @@
93
94 from shelltoolbox import (
95 apt_get_install,
96+ file_append,
97 generate_ssh_keys,
98 mkdirs,
99 run,
100@@ -34,6 +35,10 @@
101 from lpsetup.settings import (
102 APT_REPOSITORIES,
103 BASE_PACKAGES,
104+ HOSTS_CONTENT,
105+ HOSTS_FILE,
106+ LP_APACHE_MODULES,
107+ LP_APACHE_ROOTS,
108 LP_PACKAGES,
109 SSH_KEY_NAME,
110 )
111@@ -71,7 +76,7 @@
112 ... '/tmp/foo', 'Hello, world', 'w') # doctest: +ELLIPSIS
113 >>> os.remove('/tmp/foo')
114
115- Passing a `mode` other than "a" or "w' will cause an Exception.
116+ Passing a `mode` other than "a" or "w" will cause an Exception.
117
118 >>> write_file_contents(
119 ... '/tmp/foo', 'Hello, world', 'w+') # doctest: +ELLIPSIS
120@@ -130,6 +135,20 @@
121 call('bzr', 'whoami', formataddr([full_name, email]))
122 if valid_ssh_keys:
123 subprocess.call(['bzr', 'lp-login', lpuser])
124+
125+ # Create Apache document roots, to avoid warnings.
126+ mkdirs(*LP_APACHE_ROOTS)
127+ # Set up Apache modules.
128+ for module in LP_APACHE_MODULES.split():
129+ call('a2enmod', module)
130+
131+ # Set up container hosts file.
132+ lines = [get_file_header()]
133+ lines.extend(['{0}\t{1}\n'.format(ip, names)
134+ for ip, names in HOSTS_CONTENT])
135+ for line in lines:
136+ file_append(HOSTS_FILE, line)
137+
138 # haveged is used to fill /dev/random, avoiding
139 # entropy exhaustion during automated parallel tests.
140 if feed_random:
141
142=== renamed file 'lpsetup/tests/subcommands/test_install.py' => 'lpsetup/tests/subcommands/test_finish_inithost.py'
143--- lpsetup/tests/subcommands/test_install.py 2012-07-05 18:38:51 +0000
144+++ lpsetup/tests/subcommands/test_finish_inithost.py 2012-07-06 15:01:30 +0000
145@@ -7,7 +7,7 @@
146 import unittest
147
148 from lpsetup import handlers
149-from lpsetup.subcommands import install
150+from lpsetup.subcommands import finish_inithost
151 from lpsetup.tests.subcommands import test_inithost
152 from lpsetup.tests.utils import (
153 get_random_string,
154@@ -16,9 +16,10 @@
155
156
157 setup_bzr_locations_step = (
158- install.setup_bzr_locations_as_root, ['user', 'lpuser', 'repository'])
159+ finish_inithost.setup_bzr_locations_as_root,
160+ ['user', 'lpuser', 'repository'])
161 setup_launchpad_step = (
162- install.setup_launchpad, ['user', 'dependencies_dir', 'repository',
163+ finish_inithost.setup_launchpad, ['user', 'dependencies_dir', 'repository',
164 'valid_ssh_keys'])
165
166
167@@ -31,7 +32,7 @@
168
169 class InstallTest(StepsBasedSubCommandTestMixin, unittest.TestCase):
170
171- sub_command_class = install.SubCommand
172+ sub_command_class = finish_inithost.SubCommand
173 expected_arguments = get_arguments()
174 expected_handlers = (
175 handlers.handle_user,

Subscribers

People subscribed via source and target branches