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
Justin
slapos.toolbox
Commits
0fbb9119
Commit
0fbb9119
authored
Aug 11, 2016
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: factorizes the Software Releases removal code
It makes tests easiers and lighten the code in view.py
parent
086a9951
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
19 deletions
+36
-19
slapos/runner/utils.py
slapos/runner/utils.py
+33
-13
slapos/runner/views.py
slapos/runner/views.py
+3
-6
No files found.
slapos/runner/utils.py
View file @
0fbb9119
...
...
@@ -646,27 +646,47 @@ def getSoftwareReleaseName(config):
return software.replace('
', '
_
')
return "No_name"
def removeSoftwareByName(config, md5, folderName):
"""Remove all content
of the software release specified by md5
def removeSoftwareRootDirectory(config, md5, folder_name):
"""
Removes all content in the filesystem
of the software release specified by md5
Args:
config: slaprunner configuration
foldername: the link name given to the software release
md5: the md5 filename given by slapgrid to SR folder"""
if isSoftwareRunning(config) or isInstanceRunning(config):
raise Exception("Software installation or instantiation in progress, cannot remove")
folder_name: the link name given to the software release
md5: the md5 filename given by slapgrid to SR folder
"""
path = os.path.join(config['
software_root
'], md5)
linkpath = os.path.join(config['
software_link
'], folder
N
ame)
linkpath = os.path.join(config['
software_link
'], folder
_n
ame)
if not os.path.exists(path):
r
aise Exception(
"Cannot remove software Release: No such file or directory")
r
eturn (0,
"Cannot remove software Release: No such file or directory")
if not os.path.exists(linkpath):
raise Exception("Cannot remove software Release: No such file or directory %s" %
('
software_root
/
' + folderName))
svcStopAll(config)
return (0, "Cannot remove software Release: No such file or directory %s" %
('
software_root
/
' + folder_name))
os.unlink(linkpath)
shutil.rmtree(path)
return loadSoftwareRList(config)
return
def removeSoftwareByName(config, md5, folder_name):
"""
Removes a software release specified by its md5 and its name from the webrunner.
If the software release is the one of the current running instance, then
the instance should be stopped.
Args:
config: slaprunner configuration
folder_name: the link name given to the software release
md5: the md5 filename given by slapgrid to SR folder
"""
if isSoftwareRunning(config) or isInstanceRunning(config):
return (0, "Software installation or instantiation in progress, cannot remove")
if getSoftwareReleaseName(config) == folder_name:
removeCurrentInstance(config)
result = removeSoftwareRootDirectory(config, md5, folder_name)
if result is not None:
return result
return 1, loadSoftwareRList(config)
def tail(f, lines=20):
...
...
slapos/runner/views.py
View file @
0fbb9119
...
...
@@ -367,12 +367,9 @@ def removeFile():
def
removeSoftwareDir
():
try
:
data
=
removeSoftwareByName
(
app
.
config
,
request
.
form
[
'md5'
],
request
.
form
[
'title'
])
return
jsonify
(
code
=
1
,
result
=
data
)
except
Exception
as
e
:
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
status
,
message
=
removeSoftwareByName
(
app
.
config
,
request
.
form
[
'md5'
],
request
.
form
[
'title'
])
return
jsonify
(
code
=
status
,
result
=
message
)
#read file and return content to ajax
...
...
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