Commit ee6d4378 authored by Simon Redman's avatar Simon Redman

Separate repository cloning and env setup

parent dc11000f
......@@ -35,13 +35,16 @@ DEFAULT_REPO_URL="https://gitlab.flux.utah.edu/safeedge/ospfv3_monitor.git"
def _generate_repo_clone_command(repo: str, branch: str, path: str) -> str:
return "git clone -b {branch} --single-branch -- {repo} {path}; " \
"pushd {path}; " \
return "git clone -b {branch} --single-branch -- {repo} {path};".format(repo=repo, branch=branch, path=path)
def _generate_environment_create_command(path:str) -> str:
return "pushd {path} && " \
"virtualenv -p /usr/bin/python2 env; " \
"source env/bin/activate; " \
"pip install -r requirements.txt; " \
"deactivate; " \
"popd; ".format(repo=repo, branch=branch, path=path)
"source env/bin/activate && " \
"pip install -r requirements.txt && " \
"deactivate && " \
"popd".format(path=path)
def _generate_repo_update_command(path: str) -> str:
......@@ -68,7 +71,7 @@ def _generate_start_command(path:str=DEFAULT_CLONE_PATH,
:param pidfile: File to which the PID will be written
:return:
"""
return "{path}/python-sudo.sh {path}/{executable} --controller={controller} --port={port} 1> {logfile} & echo $! > {pidfile} && disown".format(
return "pushd {path}; ./python-sudo.sh {executable} --controller={controller} --port={port} 1> {logfile} & echo $! > {pidfile} && disown; popd".format(
path=path,
executable=executable,
controller=controller,
......@@ -125,6 +128,10 @@ def clone_repo_on_network(graph: networkx.Graph,
# Update anything which needed updating
commands = [_generate_repo_update_command(path)] * len(sessions_needing_updating)
outputs = ssh_helper.run_commands_on_many_hosts(sessions_needing_updating, commands)
# Setup the virtual environment
commands = [_generate_environment_create_command(path)] * len(sessions)
outputs = ssh_helper.run_commands_on_many_hosts(sessions, commands)
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment