Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
d7be8bbd
Commit
d7be8bbd
authored
Feb 22, 2022
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_slap_tool: Revert convertToStatus
It wasn't working properly, let's reintroduce once it better tested.
parent
806e6ed3
Pipeline
#19885
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
26 deletions
+44
-26
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
...onentTemplateItem/portal_components/tool.erp5.SlapTool.py
+44
-26
No files found.
master/bt5/slapos_slap_tool/ToolComponentTemplateItem/portal_components/tool.erp5.SlapTool.py
View file @
d7be8bbd
...
...
@@ -118,24 +118,6 @@ def convertToREST(function):
wrapper
.
__doc__
=
function
.
__doc__
return
wrapper
def
convertToStatus
(
function
):
def
wrapper
(
self
,
*
args
,
**
kwd
):
data_dict
=
function
(
self
,
*
args
,
**
kwd
)
last_modified
=
rfc1123_date
(
DateTime
())
# Keep in cache server for 7 days
self
.
REQUEST
.
response
.
setStatus
(
200
)
self
.
REQUEST
.
response
.
setHeader
(
'Cache-Control'
,
'public, max-age=60, stale-if-error=604800'
)
self
.
REQUEST
.
response
.
setHeader
(
'Vary'
,
'REMOTE_USER'
)
self
.
REQUEST
.
response
.
setHeader
(
'Last-Modified'
,
last_modified
)
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml; charset=utf-8'
)
self
.
REQUEST
.
response
.
setBody
(
dumps
(
data_dict
))
return
self
.
REQUEST
.
response
return
wrapper
def
_assertACI
(
document
):
sm
=
getSecurityManager
()
...
...
@@ -448,7 +430,6 @@ class SlapTool(BaseTool):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getComputerPartitionStatus'
)
@
convertToStatus
def
getComputerPartitionStatus
(
self
,
computer_id
,
computer_partition_id
):
"""
Get the connection status of the partition
...
...
@@ -458,13 +439,25 @@ class SlapTool(BaseTool):
computer_id
,
computer_partition_id
)
except
NotFound
:
return
self
.
_getAccessStatus
(
None
)
data_dict
=
self
.
_getAccessStatus
(
None
)
else
:
return
instance
.
getAccessStatus
()
data_dict
=
instance
.
getAccessStatus
()
last_modified
=
rfc1123_date
(
DateTime
())
# Keep in cache server for 7 days
self
.
REQUEST
.
response
.
setStatus
(
200
)
self
.
REQUEST
.
response
.
setHeader
(
'Cache-Control'
,
'public, max-age=60, stale-if-error=604800'
)
self
.
REQUEST
.
response
.
setHeader
(
'Vary'
,
'REMOTE_USER'
)
self
.
REQUEST
.
response
.
setHeader
(
'Last-Modified'
,
last_modified
)
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml; charset=utf-8'
)
self
.
REQUEST
.
response
.
setBody
(
dumps
(
data_dict
))
return
self
.
REQUEST
.
response
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getComputerStatus'
)
@
convertToStatus
def
getComputerStatus
(
self
,
computer_id
):
"""
Get the connection status of the partition
...
...
@@ -474,11 +467,23 @@ class SlapTool(BaseTool):
validation_state
=
"validated"
)[
0
].
getObject
()
# Be sure to prevent accessing information to disallowed users
compute_node
=
_assertACI
(
compute_node
)
return
compute_node
.
getAccessStatus
()
data_dict
=
compute_node
.
getAccessStatus
()
last_modified
=
rfc1123_date
(
DateTime
())
# Keep in cache server for 7 days
self
.
REQUEST
.
response
.
setStatus
(
200
)
self
.
REQUEST
.
response
.
setHeader
(
'Cache-Control'
,
'public, max-age=60, stale-if-error=604800'
)
self
.
REQUEST
.
response
.
setHeader
(
'Vary'
,
'REMOTE_USER'
)
self
.
REQUEST
.
response
.
setHeader
(
'Last-Modified'
,
last_modified
)
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml; charset=utf-8'
)
self
.
REQUEST
.
response
.
setBody
(
dumps
(
data_dict
))
return
self
.
REQUEST
.
response
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getSoftwareInstallationStatus'
)
@
convertToStatus
def
getSoftwareInstallationStatus
(
self
,
url
,
computer_id
):
"""
Get the connection status of the software installation
...
...
@@ -493,9 +498,22 @@ class SlapTool(BaseTool):
url
,
compute_node
)
except
NotFound
:
return
self
.
_getAccessStatus
(
None
)
data_dict
=
self
.
_getAccessStatus
(
None
)
else
:
return
software_installation
.
getAccessStatus
()
data_dict
=
software_installation
.
getAccessStatus
()
last_modified
=
rfc1123_date
(
DateTime
())
# Keep in cache server for 7 days
self
.
REQUEST
.
response
.
setStatus
(
200
)
self
.
REQUEST
.
response
.
setHeader
(
'Cache-Control'
,
'public, max-age=60, stale-if-error=604800'
)
self
.
REQUEST
.
response
.
setHeader
(
'Vary'
,
'REMOTE_USER'
)
self
.
REQUEST
.
response
.
setHeader
(
'Last-Modified'
,
last_modified
)
self
.
REQUEST
.
response
.
setHeader
(
'Content-Type'
,
'text/xml; charset=utf-8'
)
self
.
REQUEST
.
response
.
setBody
(
dumps
(
data_dict
))
return
self
.
REQUEST
.
response
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getSoftwareReleaseListFromSoftwareProduct'
)
...
...
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