Merge lp:~frankban/launchpad/setuplxc-random-trick into lp:launchpad

Proposed by Francesco Banconi on 2012-03-23
Status: Merged
Approved by: Gary Poster on 2012-03-23
Approved revision: no longer in the source branch.
Merged at revision: 15003
Proposed branch: lp:~frankban/launchpad/setuplxc-random-trick
Merge into: lp:launchpad
Diff against target: 57 lines (+13/-3)
1 file modified
utilities/setuplxc.py (+13/-3)
To merge this branch: bzr merge lp:~frankban/launchpad/setuplxc-random-trick
Reviewer Review Type Date Requested Status
Gary Poster (community) 2012-03-23 Approve on 2012-03-23
Review via email: mp+99044@code.launchpad.net

Description of the Change

== Changes ==

Added the /dev/random hack to setuplxc: if the --use-urandom flag is passed, rng-tools is installed and used to feed /dev/random with data from /dev/urandom.

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 'utilities/setuplxc.py'
2--- utilities/setuplxc.py 2012-03-19 23:46:32 +0000
3+++ utilities/setuplxc.py 2012-03-23 15:36:24 +0000
4@@ -688,6 +688,9 @@
5 'The directory must reside under the home directory of the '
6 'given user (see -u argument).')
7 parser.add_argument(
8+ '-U', '--use-urandom', action='store_true',
9+ help='Use /dev/urandom to feed /dev/random and avoid entropy exhaustion.')
10+parser.add_argument(
11 'directory',
12 help='The directory of the Launchpad repository to be created. '
13 'The directory must reside under the home directory of the '
14@@ -702,7 +705,7 @@
15
16 def initialize_host(
17 user, fullname, email, lpuser, private_key, public_key, ssh_key_path,
18- dependencies_dir, directory):
19+ use_urandom, dependencies_dir, directory):
20 """Initialize host machine."""
21 # Install necessary deb packages. This requires Oneiric or later.
22 subprocess.call(['apt-get', 'update'])
23@@ -763,6 +766,12 @@
24 subprocess.call([
25 'bzr', 'co', '--lightweight',
26 LP_SOURCE_DEPS, 'download-cache'])
27+ # rng-tools is used to set /dev/urandom as random data source, avoiding
28+ # entropy exhaustion during automated parallel tests.
29+ if use_urandom:
30+ subprocess.call(['apt-get', '-y', 'install', 'rng-tools'])
31+ file_append('/etc/default/rng-tools', 'HRNGDEVICE=/dev/urandom')
32+ subprocess.call(['/etc/init.d/rng-tools', 'start'])
33
34
35 def create_scripts(user, lxcname, ssh_key_path):
36@@ -1002,11 +1011,11 @@
37
38 def main(
39 user, fullname, email, lpuser, private_key, public_key, actions,
40- lxc_name, ssh_key_path, dependencies_dir, directory):
41+ lxc_name, ssh_key_path, use_urandom, dependencies_dir, directory):
42 function_args_map = OrderedDict((
43 ('initialize_host', (
44 user, fullname, email, lpuser, private_key, public_key,
45- ssh_key_path, dependencies_dir, directory)),
46+ ssh_key_path, use_urandom, dependencies_dir, directory)),
47 ('create_scripts', (user, lxc_name, ssh_key_path)),
48 ('create_lxc', (user, lxc_name, ssh_key_path)),
49 ('initialize_lxc', (
50@@ -1036,6 +1045,7 @@
51 args.actions,
52 args.lxc_name,
53 args.ssh_key_path,
54+ args.use_urandom,
55 args.dependencies_dir,
56 args.directory,
57 )