Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
35743fb4
Commit
35743fb4
authored
Jul 07, 2022
by
Cédric Le Ninivin
Committed by
Cédric Le Ninivin
Mar 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_computer_immobilisation: Add asJSONText on Computer
parent
777a1620
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
6 deletions
+75
-6
bt5/erp5_computer_immobilisation/DocumentTemplateItem/portal_components/document.erp5.Computer.py
...tTemplateItem/portal_components/document.erp5.Computer.py
+47
-0
bt5/erp5_computer_immobilisation/PortalTypeTemplateItem/portal_types/Compute%20Node.xml
...on/PortalTypeTemplateItem/portal_types/Compute%20Node.xml
+28
-6
No files found.
bt5/erp5_computer_immobilisation/DocumentTemplateItem/portal_components/document.erp5.Computer.py
View file @
35743fb4
...
...
@@ -31,6 +31,8 @@ from Products.ERP5Type import Permissions, PropertySheet
from
erp5.component.document.JSONType
import
JSONType
from
erp5.component.document.Machine
import
Machine
import
json
class
Computer
(
Machine
,
JSONType
):
"""
This class represents a computer like personal computer, printer, router.
...
...
@@ -58,3 +60,48 @@ class Computer(Machine, JSONType):
,
PropertySheet
.
TextDocument
,
PropertySheet
.
JSONTypeConstraint
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asJSONText'
)
def
asJSONText
(
self
):
"""
Return a minimal representation of the Compute Node
"""
compute_node_dict
=
{
"$schema"
:
self
.
getPortalObject
().
portal_types
.
restrictedTraverse
(
self
.
getPortalType
()
).
absolute_url
()
+
"/getTextContent"
,
"portal_type"
:
"Compute Node"
,
"id"
:
self
.
getReference
().
decode
(
"UTF-8"
),
"title"
:
self
.
getTitle
().
decode
(
"UTF-8"
),
"compute_partition_list"
:
[],
}
compute_partition_list
=
self
.
contentValues
(
portal_type
=
"Compute Partition"
,
checked_permission
=
"View"
)
for
compute_partition
in
compute_partition_list
:
ip_list
=
[]
full_ip_list
=
[]
for
internet_protocol_address
in
compute_partition
.
contentValues
(
portal_type
=
'Internet Protocol Address'
):
# XXX - There is new values, and we must keep compatibility
address_tuple
=
(
internet_protocol_address
.
getNetworkInterface
(
''
).
decode
(
"UTF-8"
),
internet_protocol_address
.
getIpAddress
().
decode
(
"UTF-8"
))
if
internet_protocol_address
.
getGatewayIpAddress
(
''
)
and
\
internet_protocol_address
.
getNetmask
(
''
):
address_tuple
=
address_tuple
+
(
internet_protocol_address
.
getGatewayIpAddress
().
decode
(
"UTF-8"
),
internet_protocol_address
.
getNetmask
().
decode
(
"UTF-8"
),
internet_protocol_address
.
getNetworkAddress
(
''
).
decode
(
"UTF-8"
))
full_ip_list
.
append
(
address_tuple
)
else
:
ip_list
.
append
(
address_tuple
)
compute_node_dict
[
"compute_partition_list"
].
append
({
"partition_id"
:
compute_partition
.
getReference
(),
"ip_list"
:
ip_list
,
})
return
json
.
dumps
(
compute_node_dict
,
indent
=
2
)
bt5/erp5_computer_immobilisation/PortalTypeTemplateItem/portal_types/Compute%20Node.xml
View file @
35743fb4
...
...
@@ -73,11 +73,33 @@
"type": "string",\n
"maxLength": 200\n
},\n
"reference": {\n
"title": "Compute Node Reference",\n
"description": "Unique identifier of the Compute Node",\n
"type": "string",\n
"maxLength": 50\n
"compute_partition_list": {\n
"title": "Compute Partition List",\n
"type": "array",\n
"descritpion": "List Compute Node Partitions hosted on the computer",\n
"items": {\n
"type": "object",\n
"title": "Compute Node Partition",\n
"description": "Compute Node Partitions host Software Instances",\n
"properties": {\n
"partition_id": {\n
"title": "Partition ID",\n
"descritpion": "Unique ID of the Compute Node Partition",\n
"type": "string"\n
},\n
"ip_list": {\n
"title": "IP List",\n
"type": "array",\n
"descritpion": "List of IPs usable by the Software Instance on the partition",\n
"items": {\n
"type": "array",\n
"items": {\n
"type": "string"\n
}\n
}\n
}\n
}\n
}\n
},\n
"access_token": {\n
"title": "Access Token",\n
...
...
@@ -88,7 +110,7 @@
"certificate_url_access": {\n
"title": "Certificate URL Access",\n
"type": "string",\n
"description": "If defined, url to retrieve certificates"
,
\n
"description": "If defined, url to retrieve certificates"\n
},\n
"slapos_master_web": {\n
"title": "SlapOS Master Web Interface",\n
...
...
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