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): ...@@ -152,9 +152,9 @@ def serve(config):
os.mkdir(software_link) os.mkdir(software_link)
slapos.runner.process.setHandler() slapos.runner.process.setHandler()
config.logger.info('Running slapgrid...') config.logger.info('Running slapgrid...')
runInstanceWithLock(app.config) ##runInstanceWithLock(app.config)
cloneDefaultGit(app.config) ##cloneDefaultGit(app.config)
setupDefaultSR(app.config) ##setupDefaultSR(app.config)
config.logger.info('Done.') config.logger.info('Done.')
app.wsgi_app = ProxyFix(app.wsgi_app) app.wsgi_app = ProxyFix(app.wsgi_app)
app.run(host=config.runner_host, port=int(config.runner_port), app.run(host=config.runner_host, port=int(config.runner_port),
......
...@@ -807,6 +807,25 @@ def readParameters(path): ...@@ -807,6 +807,25 @@ def readParameters(path):
else: else:
return "No such file or directory: %s" % path 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): def cloneDefaultGit(config):
"""Test if the default git has been downloaded yet """Test if the default git has been downloaded yet
......
...@@ -24,7 +24,7 @@ from slapos.runner.utils import (checkSoftwareFolder, configNewSR, getFolder, ...@@ -24,7 +24,7 @@ from slapos.runner.utils import (checkSoftwareFolder, configNewSR, getFolder,
removeSoftwareByName, runInstanceWithLock, removeSoftwareByName, runInstanceWithLock,
runSoftwareWithLock, saveSession, runSoftwareWithLock, saveSession,
svcStartStopProcess, svcStopAll, tail, svcStartStopProcess, svcStopAll, tail,
updateInstanceParameter) updateInstanceParameter, isSoftwareReleaseReady)
from slapos.runner.fileBrowser import FileBrowser from slapos.runner.fileBrowser import FileBrowser
from slapos.runner.gittools import (cloneRepo, gitStatus, switchBranch, from slapos.runner.gittools import (cloneRepo, gitStatus, switchBranch,
...@@ -643,6 +643,9 @@ def editFile(): ...@@ -643,6 +643,9 @@ def editFile():
def shell(): def shell():
return render_template('shell.html') return render_template('shell.html')
def isSRReady():
return isSoftwareReleaseReady(app.config)
#Setup List of URLs #Setup List of URLs
app.add_url_rule('/', 'home', home) app.add_url_rule('/', 'home', home)
app.add_url_rule('/browseWorkspace', 'browseWorkspace', browseWorkspace) app.add_url_rule('/browseWorkspace', 'browseWorkspace', browseWorkspace)
...@@ -725,3 +728,4 @@ app.add_url_rule("/fileBrowser", 'fileBrowser', fileBrowser, ...@@ -725,3 +728,4 @@ app.add_url_rule("/fileBrowser", 'fileBrowser', fileBrowser,
methods=['GET', 'POST']) methods=['GET', 'POST'])
app.add_url_rule("/editFile", 'editFile', editFile, methods=['GET']) app.add_url_rule("/editFile", 'editFile', editFile, methods=['GET'])
app.add_url_rule('/shell', 'shell', shell) 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