Skip to content

Commit

Permalink
vagrant: Sets the hostname to the experiment's
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Jan 26, 2015
1 parent 0221768 commit 9f3d814
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions reprounzip-vagrant/reprounzip/unpackers/vagrant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ def vagrant_run(args):

selected_runs = get_runs(runs, args.run, cmdline)

hostname = runs[selected_runs[0]].get('hostname', 'reprounzip')

cmds = []
for run_number in selected_runs:
run = runs[run_number]
Expand All @@ -453,6 +455,13 @@ def vagrant_run(args):
cmd = 'sudo -u \'#%d\' sh -c %s' % (uid, shell_escape(cmd))
cmds.append(cmd)
cmds = ' && '.join(cmds)
# Sets the hostname to the original experiment's machine's
# FIXME: not reentrant: this restores the Vagrant machine's hostname after
# the run, which might cause issues if several "reprounzip vagrant run" are
# running at once
cmds = ('OLD_HOSTNAME=$(/bin/hostname); /bin/hostname %s; ' % hostname +
cmds +
'; RES=$?; /bin/hostname "$OLD_HOSTNAME"; exit $RES')
cmds = '/usr/bin/sudo /bin/sh -c %s' % shell_escape(cmds)

# Gets vagrant SSH parameters
Expand Down

0 comments on commit 9f3d814

Please sign in to comment.