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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
52515da3
Commit
52515da3
authored
Jul 07, 2022
by
Cédric Le Ninivin
Committed by
Romain Courteaud
Nov 18, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: Add asJSONText on Software Installation
parent
b4a96a5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
2 deletions
+41
-2
master/bt5/slapos_cloud/DocumentTemplateItem/portal_components/document.erp5.SoftwareInstallation.py
...m/portal_components/document.erp5.SoftwareInstallation.py
+29
-0
master/bt5/slapos_cloud/PortalTypeTemplateItem/portal_types/Software%20Installation.xml
...TypeTemplateItem/portal_types/Software%20Installation.xml
+12
-2
No files found.
master/bt5/slapos_cloud/DocumentTemplateItem/portal_components/document.erp5.SoftwareInstallation.py
View file @
52515da3
...
@@ -31,6 +31,8 @@ from Products.ERP5Type import Permissions, PropertySheet
...
@@ -31,6 +31,8 @@ from Products.ERP5Type import Permissions, PropertySheet
from
erp5.component.document.Item
import
Item
from
erp5.component.document.Item
import
Item
from
erp5.component.document.JSONType
import
JSONType
from
erp5.component.document.JSONType
import
JSONType
import
json
class
SoftwareInstallation
(
Item
,
JSONType
):
class
SoftwareInstallation
(
Item
,
JSONType
):
"""
"""
This class represents a computer like personal computer, printer, router.
This class represents a computer like personal computer, printer, router.
...
@@ -47,3 +49,30 @@ class SoftwareInstallation(Item, JSONType):
...
@@ -47,3 +49,30 @@ class SoftwareInstallation(Item, JSONType):
property_sheets
=
(
PropertySheet
.
TextDocument
property_sheets
=
(
PropertySheet
.
TextDocument
,
PropertySheet
.
JSONTypeConstraint
,
PropertySheet
.
JSONTypeConstraint
)
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asJSONText'
)
def
asJSONText
(
self
):
requested_state
=
self
.
getSlapState
()
if
requested_state
==
"stop_requested"
:
state
=
'stopped'
elif
requested_state
in
(
"start_requested"
,
"started"
):
state
=
'available'
elif
requested_state
==
"destroy_requested"
:
state
=
'destroyed'
else
:
raise
ValueError
(
"Unknown slap state : %s"
%
requested_state
)
# software instance has to define an xml parameter
status_dict
=
self
.
getAccessStatus
()
result
=
{
"$schema"
:
self
.
getPortalObject
().
portal_types
.
restrictedTraverse
(
self
.
getPortalType
()).
absolute_url
()
+
"/getTextContent"
,
"reference"
:
self
.
getReference
().
decode
(
"UTF-8"
),
"software_release_uri"
:
self
.
getUrlString
(),
"compute_node_id"
:
self
.
getAggregateReference
(),
"state"
:
state
,
"reported_state"
:
status_dict
.
get
(
"state"
),
"status_message"
:
status_dict
.
get
(
"text"
),
}
result
.
update
()
return
json
.
dumps
(
result
,
indent
=
2
)
master/bt5/slapos_cloud/PortalTypeTemplateItem/portal_types/Software%20Installation.xml
View file @
52515da3
...
@@ -72,13 +72,23 @@
...
@@ -72,13 +72,23 @@
"description": "State of the requested software",\n
"description": "State of the requested software",\n
"default": "available"\n
"default": "available"\n
},\n
},\n
"reported_state": {\n
"title": "Reported State",\n
"type": "string",\n
"enum": ["available", "destroyed", "building", ""],\n
"description": "State reported by the node installing the Software Installation"\n
},\n
"status_message": {\n
"title": "Status Message",\n
"description": "Last Message received for the Software Installation",\n
"type": "string"\n
},\n
"portal_type": {\n
"portal_type": {\n
"title": "Portal Type",\n
"title": "Portal Type",\n
"const": "Software Installation",\n
"const": "Software Installation",\n
"type": "string"\n
"type": "string"\n
}\n
}\n
},\n
}\n
"required": ["portal_type", "software_release_uri", "compute_node_id"]\n
}\n
}\n
</string>
</value>
</string>
</value>
</item>
</item>
...
...
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