~frankban/lpsetup/urandom-hack

« back to all changes in this revision

Viewing changes to lpsetup/subcommands/install.py

  • Committer: Francesco Banconi
  • Date: 2012-04-10 09:22:25 UTC
  • Revision ID: francesco.banconi@canonical.com-20120410092225-sr0arslg80477yu7
Added random/urandom hack.

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
 
115
115
def initialize(
116
116
    user, full_name, email, lpuser, private_key, public_key, valid_ssh_keys,
117
 
    ssh_key_path, dependencies_dir, directory):
 
117
    ssh_key_path, use_urandom, dependencies_dir, directory):
118
118
    """Initialize host machine."""
119
119
    # Install necessary deb packages.  This requires Oneiric or later.
120
120
    call('apt-get', 'update')
165
165
        for line in lines:
166
166
            location = line.format(checkout_dir=checkout_dir, lpuser=lpuser)
167
167
            file_append(bzr_locations, location)
 
168
    # rng-tools is used to set /dev/urandom as random data source, avoiding
 
169
    # entropy exhaustion during automated parallel tests.
 
170
    if use_urandom:
 
171
        apt_get_install('rng-tools', caller=call)
 
172
        file_append('/etc/default/rng-tools', 'HRNGDEVICE=/dev/urandom')
 
173
        call('/etc/init.d/rng-tools', 'start')
168
174
 
169
175
 
170
176
def setup_apt(no_repositories=True):
218
224
        (initialize,
219
225
         'user', 'full_name', 'email', 'lpuser',
220
226
         'private_key', 'public_key', 'valid_ssh_keys', 'ssh_key_path',
221
 
         'dependencies_dir', 'directory'),
 
227
         'use_urandom', 'dependencies_dir', 'directory'),
222
228
        (setup_apt,
223
229
         'no_repositories'),
224
230
        (setup_launchpad,
289
295
        parser.add_argument(
290
296
            '-N', '--no-repositories', action='store_true',
291
297
            help='Do not add APT repositories.')
 
298
        parser.add_argument(
 
299
            '-U', '--use-urandom', action='store_true',
 
300
            help='Use /dev/urandom to feed /dev/random and avoid '
 
301
                 'entropy exhaustion.')