Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
504c884b
Commit
504c884b
authored
Aug 28, 2014
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: "run" and "proxy" functions adapted to supervisor
parent
84bba7b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
38 deletions
+25
-38
slapos/runner/utils.py
slapos/runner/utils.py
+25
-38
No files found.
slapos/runner/utils.py
View file @
504c884b
...
...
@@ -238,15 +238,15 @@ def updateInstanceParameter(config, software_type=None):
config: Slaprunner configuration.
software_type: reconfigure Software Instance with software type.
"""
time
.
sleep
(
1
)
if
not
(
updateProxy
(
config
)
and
requestInstance
(
config
,
software_type
)):
return
False
def
startProxy
(
config
):
"""Start Slapproxy server"""
if
sup_process
.
isRunning
(
'slapproxy'
):
if
sup_process
.
isRunning
(
config
,
'slapproxy'
):
return
try
:
sup_process
.
runProcess
(
config
,
"slapproxy"
)
except
xmlrpclib
.
Fault
:
...
...
@@ -266,15 +266,11 @@ def removeProxyDb(config):
os
.
unlink
(
config
[
'database_uri'
])
def
isSoftwareRunning
(
config
=
None
):
def
isSoftwareRunning
(
config
):
"""
Return True if slapos is still running and false if slapos if not
"""
# XXX-Cedric Hardcoded pidfile
if
config
:
slapgrid_pid
=
os
.
path
.
join
(
config
[
'run_dir'
],
'slapgrid-sr.pid'
)
return
isPidFileProcessRunning
(
slapgrid_pid
)
return
isRunning
(
'slapgrid-sr'
)
return
sup_process
.
isRunning
(
config
,
'slapgrid-sr'
)
def
slapgridResultToFile
(
config
,
step
,
returncode
,
datetime
):
...
...
@@ -300,17 +296,14 @@ def waitProcess(config, process, step):
slapgridResultToFile
(
config
,
step
,
process
.
returncode
,
date
)
def
runSoftwareWithLock
(
config
,
lock
=
Tru
e
):
def
runSoftwareWithLock
(
config
,
lock
=
Fals
e
):
"""
Use Slapgrid to compile current Software Release and wait until
compilation is done
"""
if
isSoftwareRunning
(
):
return
False
if
sup_process
.
isRunning
(
config
,
'slapgrid-sr'
):
return
1
slapgrid_pid
=
os
.
path
.
join
(
config
[
'run_dir'
],
'slapgrid-sr.pid'
)
if
isPidFileProcessRunning
(
slapgrid_pid
):
return
False
if
not
os
.
path
.
exists
(
config
[
'software_root'
]):
os
.
mkdir
(
config
[
'software_root'
])
stopProxy
(
config
)
...
...
@@ -319,16 +312,16 @@ def runSoftwareWithLock(config, lock=True):
if
os
.
path
.
exists
(
config
[
'software_log'
]):
os
.
remove
(
config
[
'software_log'
])
if
not
updateProxy
(
config
):
return
False
return
1
try
:
sup_process
.
runProcess
(
config
,
"slapgrid-sr"
)
if
lock
:
sup_process
.
waitForProcessEnd
(
config
,
"slapgrid-sr"
)
#Saves the current compile software for re-use
config_SR_folder
(
config
)
return
True
return
sup_process
.
returnCode
(
config
,
"slapgrid-sr"
)
except
xmlrpclib
.
Fault
:
return
False
return
1
def
config_SR_folder
(
config
):
...
...
@@ -392,39 +385,34 @@ def loadSoftwareRList(config):
return
list
def
isInstanceRunning
(
config
=
None
):
def
isInstanceRunning
(
config
):
"""
Return True if slapos is still running and False otherwise
"""
# XXX-Cedric Hardcoded pidfile
if
config
:
slapgrid_pid
=
os
.
path
.
join
(
config
[
'run_dir'
],
'slapgrid-cp.pid'
)
return
isPidFileProcessRunning
(
slapgrid_pid
)
return
isRunning
(
'slapgrid-cp'
)
return
sup_process
.
isRunning
(
config
,
'slapgrid-cp'
)
def
runInstanceWithLock
(
config
,
lock
=
Tru
e
):
def
runInstanceWithLock
(
config
,
lock
=
Fals
e
):
"""
Use Slapgrid to deploy current Software Release and wait until
deployment is done.
"""
if
isInstanceRunning
(
):
return
False
if
sup_process
.
isRunning
(
config
,
'slapgrid-cp'
):
return
1
slapgrid_pid
=
os
.
path
.
join
(
config
[
'run_dir'
],
'slapgrid-cp.pid'
)
startProxy
(
config
)
# XXX Hackish and unreliable
if
os
.
path
.
exists
(
config
[
'instance_log'
]):
os
.
remove
(
config
[
'instance_log'
])
if
not
(
updateProxy
(
config
)
and
requestInstance
(
config
)):
return
False
return
1
try
:
sup_process
.
runProcess
(
config
,
"slapgrid-cp"
)
if
lock
:
sup_process
.
waitForProcessEnd
(
config
,
"slapgrid-cp"
)
return
True
return
sup_process
.
returnCode
(
config
,
"slapgrid-cp"
)
except
xmlrpclib
.
Fault
:
return
False
return
1
def
getProfilePath
(
projectDir
,
profile
):
...
...
@@ -557,10 +545,8 @@ def configNewSR(config, projectpath):
"""
folder = realpath(config, projectpath)
if folder:
if isInstanceRunning():
killRunningProcess('
slapgrid
-
cp
')
if isSoftwareRunning():
killRunningProcess('
slapgrid
-
sr
')
sup_process.stopIfRunning(config, '
slapgrid
-
cp
')
sup_process.stopIfRunning(config, '
slapgrid
-
sr
')
stopProxy(config)
removeProxyDb(config)
startProxy(config)
...
...
@@ -652,7 +638,7 @@ def removeSoftwareByName(config, md5, folderName):
config: slaprunner configuration
foldername: the link name given to the software release
md5: the md5 filename given by slapgrid to SR folder"""
if isSoftwareRunning(
) or isInstanceRunning(
):
if isSoftwareRunning(
config) or isInstanceRunning(config
):
raise Exception("Software installation or instantiation in progress, cannot remove")
path = os.path.join(config['
software_root
'], md5)
linkpath = os.path.join(config['
software_link
'], folderName)
...
...
@@ -890,8 +876,9 @@ def runSlapgridUntilSuccess(config, step):
# XXX-Nico runSoftwareWithLock can return 0 or False (0==False)
while counter > 0:
counter -= 1
slapgrid = runSlapgridWithLock(config)
if slapgrid:
slapgrid = runSlapgridWithLock(config, lock=True)
# slapgrid == 0 because EXIT_SUCCESS == 0
if slapgrid == 0:
break
times_left = int(open(counter_file).read()) - 1
if times_left > 0 :
...
...
@@ -902,7 +889,7 @@ def runSlapgridUntilSuccess(config, step):
max_tries -= counter
# run instance only if we are deploying the software release,
# if it is defined so, and sr is correctly deployed
if step == "software" and params['
run_instance
'] and slapgrid:
if step == "software" and params['
run_instance
'] and slapgrid
== 0
:
return (max_tries, runSlapgridUntilSuccess(config, "instance"))
else:
return max_tries
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment