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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.toolbox
Commits
9ef5d5b1
Commit
9ef5d5b1
authored
Aug 09, 2016
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: factorizes code from runSoftwareWithLock and runInstanceWithLock
parent
9f35bd78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
36 deletions
+37
-36
slapos/runner/utils.py
slapos/runner/utils.py
+37
-36
No files found.
slapos/runner/utils.py
View file @
9ef5d5b1
...
@@ -278,33 +278,57 @@ def waitProcess(config, process, step):
...
@@ -278,33 +278,57 @@ def waitProcess(config, process, step):
date
=
datetime
.
datetime
.
now
().
strftime
(
"%Y-%m-%d %H:%M:%S"
)
date
=
datetime
.
datetime
.
now
().
strftime
(
"%Y-%m-%d %H:%M:%S"
)
slapgridResultToFile
(
config
,
step
,
process
.
returncode
,
date
)
slapgridResultToFile
(
config
,
step
,
process
.
returncode
,
date
)
def
runSlapgridWithLock
(
config
,
step
,
process_name
,
lock
=
False
):
def
runSoftwareWithLock
(
config
,
lock
=
False
):
"""
"""
Use Slapgrid to compile current Software Release and wait until
* process_name is the name of the process given to supervisord, which will
compilation is done
run the software or the instance
* step is one of ('software', 'instance')
* lock allows to make this function asynchronous or not
"""
"""
if
sup_process
.
isRunning
(
config
,
'slapgrid-sr'
):
if
sup_process
.
isRunning
(
config
,
process_name
):
return
1
return
1
if
not
os
.
path
.
exists
(
config
[
'software_root'
]):
root_folder
=
config
[
"%s_root"
%
step
]
os
.
mkdir
(
config
[
'software_root'
])
log_file
=
config
[
"%s_log"
%
step
]
if
not
os
.
path
.
exists
(
root_folder
):
os
.
mkdir
(
root_folder
)
# XXX Hackish and unreliable
# XXX Hackish and unreliable
if
os
.
path
.
exists
(
config
[
'software_log'
]
):
if
os
.
path
.
exists
(
log_file
):
os
.
remove
(
config
[
'software_log'
]
)
os
.
remove
(
log_file
)
if
not
updateProxy
(
config
):
if
not
updateProxy
(
config
):
return
1
return
1
if
step
==
'instance'
and
not
requestInstance
(
config
):
return
1
try
:
try
:
sup_process
.
runProcess
(
config
,
"slapgrid-sr"
)
sup_process
.
runProcess
(
config
,
process_name
)
if
lock
:
if
lock
:
sup_process
.
waitForProcessEnd
(
config
,
"slapgrid-sr"
)
sup_process
.
waitForProcessEnd
(
config
,
process_name
)
#Saves the current compile software for re-use
#Saves the current compile software for re-use
config_SR_folder
(
config
)
if
step
==
'software'
:
return
sup_process
.
returnCode
(
config
,
"slapgrid-sr"
)
config_SR_folder
(
config
)
return
sup_process
.
returnCode
(
config
,
process_name
)
except
xmlrpclib
.
Fault
:
except
xmlrpclib
.
Fault
:
return
1
return
1
def
runSoftwareWithLock
(
config
,
lock
=
False
):
"""
Use Slapgrid to compile current Software Release and wait until
compilation is done
"""
return
runSlapgridWithLock
(
config
,
'software'
,
'slapgrid-sr'
,
lock
)
def
runInstanceWithLock
(
config
,
lock
=
False
):
"""
Use Slapgrid to deploy current Software Release and wait until
deployment is done.
"""
return
runSlapgridWithLock
(
config
,
'instance'
,
'slapgrid-cp'
,
lock
)
def
config_SR_folder
(
config
):
def
config_SR_folder
(
config
):
"""Create a symbolik link for each folder in software folder. That allows
"""Create a symbolik link for each folder in software folder. That allows
the user to customize software release folder"""
the user to customize software release folder"""
...
@@ -373,29 +397,6 @@ def isInstanceRunning(config):
...
@@ -373,29 +397,6 @@ def isInstanceRunning(config):
return
sup_process
.
isRunning
(
config
,
'slapgrid-cp'
)
return
sup_process
.
isRunning
(
config
,
'slapgrid-cp'
)
def
runInstanceWithLock
(
config
,
lock
=
False
):
"""
Use Slapgrid to deploy current Software Release and wait until
deployment is done.
"""
if
sup_process
.
isRunning
(
config
,
'slapgrid-cp'
):
return
1
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
1
try
:
sup_process
.
runProcess
(
config
,
"slapgrid-cp"
)
if
lock
:
sup_process
.
waitForProcessEnd
(
config
,
"slapgrid-cp"
)
return
sup_process
.
returnCode
(
config
,
"slapgrid-cp"
)
except
xmlrpclib
.
Fault
:
return
1
def
getProfilePath
(
projectDir
,
profile
):
def
getProfilePath
(
projectDir
,
profile
):
"""
"""
Return the path of the current Software Release `profile`
Return the path of the current Software Release `profile`
...
...
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