Commit 4e2f9bc1 authored by Nicolas Wavrant's avatar Nicolas Wavrant

slaprunner: new function isSoftwareReleaseReady

describes current state of deployment of the SR,
and starts it if required
parent d29efb23
......@@ -152,9 +152,9 @@ def serve(config):
os.mkdir(software_link)
slapos.runner.process.setHandler()
config.logger.info('Running slapgrid...')
runInstanceWithLock(app.config)
cloneDefaultGit(app.config)
setupDefaultSR(app.config)
##runInstanceWithLock(app.config)
##cloneDefaultGit(app.config)
##setupDefaultSR(app.config)
config.logger.info('Done.')
app.wsgi_app = ProxyFix(app.wsgi_app)
app.run(host=config.runner_host, port=int(config.runner_port),
......
......@@ -807,6 +807,25 @@ def readParameters(path):
else:
return "No such file or directory: %s" % path
def isSoftwareReleaseReady(config):
"""Return 1 if the Software Release has
correctly been deployed, 0 if not,
and 2 if it is currently deploying"""
project = os.path.join(config['etc_dir'], '.project')
if not os.path.exists(project):
return "0";
software_name = open(project, 'r').readline().split('/')[-2]
if os.path.exists(os.path.join(config['runner_workdir'],
'softwareLink', software_name, '.completed')):
return "1"
else:
if isSoftwareRunning(config):
return "2"
elif config['auto_deploy'] in (1, '1', True, 'true'):
runSoftwareWithLock(config)
return "2"
else:
return "0"
def cloneDefaultGit(config):
"""Test if the default git has been downloaded yet
......
......@@ -24,7 +24,7 @@ from slapos.runner.utils import (checkSoftwareFolder, configNewSR, getFolder,
removeSoftwareByName, runInstanceWithLock,
runSoftwareWithLock, saveSession,
svcStartStopProcess, svcStopAll, tail,
updateInstanceParameter)
updateInstanceParameter, isSoftwareReleaseReady)
from slapos.runner.fileBrowser import FileBrowser
from slapos.runner.gittools import (cloneRepo, gitStatus, switchBranch,
......@@ -643,6 +643,9 @@ def editFile():
def shell():
return render_template('shell.html')
def isSRReady():
return isSoftwareReleaseReady(app.config)
#Setup List of URLs
app.add_url_rule('/', 'home', home)
app.add_url_rule('/browseWorkspace', 'browseWorkspace', browseWorkspace)
......@@ -725,3 +728,4 @@ app.add_url_rule("/fileBrowser", 'fileBrowser', fileBrowser,
methods=['GET', 'POST'])
app.add_url_rule("/editFile", 'editFile', editFile, methods=['GET'])
app.add_url_rule('/shell', 'shell', shell)
app.add_url_rule('/isSRReady', 'isSRReady', isSRReady)
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