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
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
Jérome Perrin
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
Changes
1
Hide 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):
...
@@ -118,24 +118,6 @@ def convertToREST(function):
wrapper
.
__doc__
=
function
.
__doc__
wrapper
.
__doc__
=
function
.
__doc__
return
wrapper
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
):
def
_assertACI
(
document
):
sm
=
getSecurityManager
()
sm
=
getSecurityManager
()
...
@@ -448,7 +430,6 @@ class SlapTool(BaseTool):
...
@@ -448,7 +430,6 @@ class SlapTool(BaseTool):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getComputerPartitionStatus'
)
'getComputerPartitionStatus'
)
@
convertToStatus
def
getComputerPartitionStatus
(
self
,
computer_id
,
computer_partition_id
):
def
getComputerPartitionStatus
(
self
,
computer_id
,
computer_partition_id
):
"""
"""
Get the connection status of the partition
Get the connection status of the partition
...
@@ -458,13 +439,25 @@ class SlapTool(BaseTool):
...
@@ -458,13 +439,25 @@ class SlapTool(BaseTool):
computer_id
,
computer_id
,
computer_partition_id
)
computer_partition_id
)
except
NotFound
:
except
NotFound
:
return
self
.
_getAccessStatus
(
None
)
data_dict
=
self
.
_getAccessStatus
(
None
)
else
:
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
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getComputerStatus'
)
'getComputerStatus'
)
@
convertToStatus
def
getComputerStatus
(
self
,
computer_id
):
def
getComputerStatus
(
self
,
computer_id
):
"""
"""
Get the connection status of the partition
Get the connection status of the partition
...
@@ -474,11 +467,23 @@ class SlapTool(BaseTool):
...
@@ -474,11 +467,23 @@ class SlapTool(BaseTool):
validation_state
=
"validated"
)[
0
].
getObject
()
validation_state
=
"validated"
)[
0
].
getObject
()
# Be sure to prevent accessing information to disallowed users
# Be sure to prevent accessing information to disallowed users
compute_node
=
_assertACI
(
compute_node
)
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
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getSoftwareInstallationStatus'
)
'getSoftwareInstallationStatus'
)
@
convertToStatus
def
getSoftwareInstallationStatus
(
self
,
url
,
computer_id
):
def
getSoftwareInstallationStatus
(
self
,
url
,
computer_id
):
"""
"""
Get the connection status of the software installation
Get the connection status of the software installation
...
@@ -493,9 +498,22 @@ class SlapTool(BaseTool):
...
@@ -493,9 +498,22 @@ class SlapTool(BaseTool):
url
,
url
,
compute_node
)
compute_node
)
except
NotFound
:
except
NotFound
:
return
self
.
_getAccessStatus
(
None
)
data_dict
=
self
.
_getAccessStatus
(
None
)
else
:
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
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getSoftwareReleaseListFromSoftwareProduct'
)
'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