...
 
Commits (2)
......@@ -35,11 +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};" \
"virtualenv -p /usr/bin/python2 env && env/bin/activate;" \
"pip install -r requirements.txt;" \
"popd;".format(repo=repo, branch=branch, path=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(path=path)
def _generate_repo_update_command(path: str) -> str:
......@@ -66,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,
......@@ -123,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
......