Skip to content

Commit

Permalink
Merge branch 'restore-hostname' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Feb 3, 2015
2 parents 36fb299 + 94348f9 commit d99ec79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions reprounzip-docker/reprounzip/unpackers/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ def docker_run(args):
# Name of new container
container = make_unique_name(b'reprounzip_run_')

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

cmds = []
for run_number in selected_runs:
run = runs[run_number]
Expand All @@ -291,6 +293,7 @@ def docker_run(args):
# Run command in container
logging.info("Starting container %s", container.decode('ascii'))
retcode = subprocess.call(['docker', 'run', b'--name=' + container,
'-h', hostname,
'-i', '-t', image,
'/bin/busybox', 'sh', '-c', cmds])
sys.stderr.write("\n*** Command finished, status: %d\n" % retcode)
Expand Down
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 @@ -424,6 +424,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 @@ -450,6 +452,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 d99ec79

Please sign in to comment.