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
0
Merge Requests
0
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
Jérome Perrin
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
Show 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):
...
@@ -238,15 +238,15 @@ def updateInstanceParameter(config, software_type=None):
config: Slaprunner configuration.
config: Slaprunner configuration.
software_type: reconfigure Software Instance with software type.
software_type: reconfigure Software Instance with software type.
"""
"""
time
.
sleep
(
1
)
if
not
(
updateProxy
(
config
)
and
requestInstance
(
config
,
software_type
)):
if
not
(
updateProxy
(
config
)
and
requestInstance
(
config
,
software_type
)):
return
False
return
False
def
startProxy
(
config
):
def
startProxy
(
config
):
"""Start Slapproxy server"""
"""Start Slapproxy server"""
if
sup_process
.
isRunning
(
'slapproxy'
):
if
sup_process
.
isRunning
(
config
,
'slapproxy'
):
return
return
try
:
try
:
sup_process
.
runProcess
(
config
,
"slapproxy"
)
sup_process
.
runProcess
(
config
,
"slapproxy"
)
except
xmlrpclib
.
Fault
:
except
xmlrpclib
.
Fault
:
...
@@ -266,15 +266,11 @@ def removeProxyDb(config):
...
@@ -266,15 +266,11 @@ def removeProxyDb(config):
os
.
unlink
(
config
[
'database_uri'
])
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
Return True if slapos is still running and false if slapos if not
"""
"""
# XXX-Cedric Hardcoded pidfile
return
sup_process
.
isRunning
(
config
,
'slapgrid-sr'
)
if
config
:
slapgrid_pid
=
os
.
path
.
join
(
config
[
'run_dir'
],
'slapgrid-sr.pid'
)
return
isPidFileProcessRunning
(
slapgrid_pid
)
return
isRunning
(
'slapgrid-sr'
)
def
slapgridResultToFile
(
config
,
step
,
returncode
,
datetime
):
def
slapgridResultToFile
(
config
,
step
,
returncode
,
datetime
):
...
@@ -300,17 +296,14 @@ def waitProcess(config, process, step):
...
@@ -300,17 +296,14 @@ def waitProcess(config, process, step):
slapgridResultToFile
(
config
,
step
,
process
.
returncode
,
date
)
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
Use Slapgrid to compile current Software Release and wait until
compilation is done
compilation is done
"""
"""
if
isSoftwareRunning
(
):
if
sup_process
.
isRunning
(
config
,
'slapgrid-sr'
):
return
False
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'
]):
if
not
os
.
path
.
exists
(
config
[
'software_root'
]):
os
.
mkdir
(
config
[
'software_root'
])
os
.
mkdir
(
config
[
'software_root'
])
stopProxy
(
config
)
stopProxy
(
config
)
...
@@ -319,16 +312,16 @@ def runSoftwareWithLock(config, lock=True):
...
@@ -319,16 +312,16 @@ def runSoftwareWithLock(config, lock=True):
if
os
.
path
.
exists
(
config
[
'software_log'
]):
if
os
.
path
.
exists
(
config
[
'software_log'
]):
os
.
remove
(
config
[
'software_log'
])
os
.
remove
(
config
[
'software_log'
])
if
not
updateProxy
(
config
):
if
not
updateProxy
(
config
):
return
False
return
1
try
:
try
:
sup_process
.
runProcess
(
config
,
"slapgrid-sr"
)
sup_process
.
runProcess
(
config
,
"slapgrid-sr"
)
if
lock
:
if
lock
:
sup_process
.
waitForProcessEnd
(
config
,
"slapgrid-sr"
)
sup_process
.
waitForProcessEnd
(
config
,
"slapgrid-sr"
)
#Saves the current compile software for re-use
#Saves the current compile software for re-use
config_SR_folder
(
config
)
config_SR_folder
(
config
)
return
True
return
sup_process
.
returnCode
(
config
,
"slapgrid-sr"
)
except
xmlrpclib
.
Fault
:
except
xmlrpclib
.
Fault
:
return
False
return
1
def
config_SR_folder
(
config
):
def
config_SR_folder
(
config
):
...
@@ -392,39 +385,34 @@ def loadSoftwareRList(config):
...
@@ -392,39 +385,34 @@ def loadSoftwareRList(config):
return
list
return
list
def
isInstanceRunning
(
config
=
None
):
def
isInstanceRunning
(
config
):
"""
"""
Return True if slapos is still running and False otherwise
Return True if slapos is still running and False otherwise
"""
"""
# XXX-Cedric Hardcoded pidfile
return
sup_process
.
isRunning
(
config
,
'slapgrid-cp'
)
if
config
:
slapgrid_pid
=
os
.
path
.
join
(
config
[
'run_dir'
],
'slapgrid-cp.pid'
)
return
isPidFileProcessRunning
(
slapgrid_pid
)
return
isRunning
(
'slapgrid-cp'
)
def
runInstanceWithLock
(
config
,
lock
=
Tru
e
):
def
runInstanceWithLock
(
config
,
lock
=
Fals
e
):
"""
"""
Use Slapgrid to deploy current Software Release and wait until
Use Slapgrid to deploy current Software Release and wait until
deployment is done.
deployment is done.
"""
"""
if
isInstanceRunning
(
):
if
sup_process
.
isRunning
(
config
,
'slapgrid-cp'
):
return
False
return
1
slapgrid_pid
=
os
.
path
.
join
(
config
[
'run_dir'
],
'slapgrid-cp.pid'
)
startProxy
(
config
)
startProxy
(
config
)
# XXX Hackish and unreliable
# XXX Hackish and unreliable
if
os
.
path
.
exists
(
config
[
'instance_log'
]):
if
os
.
path
.
exists
(
config
[
'instance_log'
]):
os
.
remove
(
config
[
'instance_log'
])
os
.
remove
(
config
[
'instance_log'
])
if
not
(
updateProxy
(
config
)
and
requestInstance
(
config
)):
if
not
(
updateProxy
(
config
)
and
requestInstance
(
config
)):
return
False
return
1
try
:
try
:
sup_process
.
runProcess
(
config
,
"slapgrid-cp"
)
sup_process
.
runProcess
(
config
,
"slapgrid-cp"
)
if
lock
:
if
lock
:
sup_process
.
waitForProcessEnd
(
config
,
"slapgrid-cp"
)
sup_process
.
waitForProcessEnd
(
config
,
"slapgrid-cp"
)
return
True
return
sup_process
.
returnCode
(
config
,
"slapgrid-cp"
)
except
xmlrpclib
.
Fault
:
except
xmlrpclib
.
Fault
:
return
False
return
1
def
getProfilePath
(
projectDir
,
profile
):
def
getProfilePath
(
projectDir
,
profile
):
...
@@ -557,10 +545,8 @@ def configNewSR(config, projectpath):
...
@@ -557,10 +545,8 @@ def configNewSR(config, projectpath):
"""
"""
folder = realpath(config, projectpath)
folder = realpath(config, projectpath)
if folder:
if folder:
if isInstanceRunning():
sup_process.stopIfRunning(config, '
slapgrid
-
cp
')
killRunningProcess('
slapgrid
-
cp
')
sup_process.stopIfRunning(config, '
slapgrid
-
sr
')
if isSoftwareRunning():
killRunningProcess('
slapgrid
-
sr
')
stopProxy(config)
stopProxy(config)
removeProxyDb(config)
removeProxyDb(config)
startProxy(config)
startProxy(config)
...
@@ -652,7 +638,7 @@ def removeSoftwareByName(config, md5, folderName):
...
@@ -652,7 +638,7 @@ def removeSoftwareByName(config, md5, folderName):
config: slaprunner configuration
config: slaprunner configuration
foldername: the link name given to the software release
foldername: the link name given to the software release
md5: the md5 filename given by slapgrid to SR folder"""
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")
raise Exception("Software installation or instantiation in progress, cannot remove")
path = os.path.join(config['
software_root
'], md5)
path = os.path.join(config['
software_root
'], md5)
linkpath = os.path.join(config['
software_link
'], folderName)
linkpath = os.path.join(config['
software_link
'], folderName)
...
@@ -890,8 +876,9 @@ def runSlapgridUntilSuccess(config, step):
...
@@ -890,8 +876,9 @@ def runSlapgridUntilSuccess(config, step):
# XXX-Nico runSoftwareWithLock can return 0 or False (0==False)
# XXX-Nico runSoftwareWithLock can return 0 or False (0==False)
while counter > 0:
while counter > 0:
counter -= 1
counter -= 1
slapgrid = runSlapgridWithLock(config)
slapgrid = runSlapgridWithLock(config, lock=True)
if slapgrid:
# slapgrid == 0 because EXIT_SUCCESS == 0
if slapgrid == 0:
break
break
times_left = int(open(counter_file).read()) - 1
times_left = int(open(counter_file).read()) - 1
if times_left > 0 :
if times_left > 0 :
...
@@ -902,7 +889,7 @@ def runSlapgridUntilSuccess(config, step):
...
@@ -902,7 +889,7 @@ def runSlapgridUntilSuccess(config, step):
max_tries -= counter
max_tries -= counter
# run instance only if we are deploying the software release,
# run instance only if we are deploying the software release,
# if it is defined so, and sr is correctly deployed
# 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"))
return (max_tries, runSlapgridUntilSuccess(config, "instance"))
else:
else:
return max_tries
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