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
Léo-Paul Géneau
slapos.core
Commits
c219f1fb
Commit
c219f1fb
authored
Mar 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
slapos_jio_api_style: Add action to create Compute node and retrieve certificates
parent
d5581972
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
381 additions
and
0 deletions
+381
-0
master/bt5/slapos_jio_api_style/ActionTemplateItem/portal_types/jIO%20Web%20Section/slapos_jio_api_create_compute_node.xml
...IO%20Web%20Section/slapos_jio_api_create_compute_node.xml
+81
-0
master/bt5/slapos_jio_api_style/PathTemplateItem/portal_callables/jIOWebSection_createComputeNodeFromJSON.xml
...tal_callables/jIOWebSection_createComputeNodeFromJSON.xml
+86
-0
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api.xml
...pi_style/SkinTemplateItem/portal_skins/slapos_jio_api.xml
+26
-0
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/ComputeNode_approveComputer.py
...ortal_skins/slapos_jio_api/ComputeNode_approveComputer.py
+20
-0
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/ComputeNode_approveComputer.xml
...rtal_skins/slapos_jio_api/ComputeNode_approveComputer.xml
+62
-0
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_createComputeNode.py
...l_skins/slapos_jio_api/jIOWebSection_createComputeNode.py
+39
-0
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_createComputeNode.xml
..._skins/slapos_jio_api/jIOWebSection_createComputeNode.xml
+62
-0
master/bt5/slapos_jio_api_style/bt/template_action_path_list
master/bt5/slapos_jio_api_style/bt/template_action_path_list
+1
-0
master/bt5/slapos_jio_api_style/bt/template_format_version
master/bt5/slapos_jio_api_style/bt/template_format_version
+1
-0
master/bt5/slapos_jio_api_style/bt/template_path_list
master/bt5/slapos_jio_api_style/bt/template_path_list
+1
-0
master/bt5/slapos_jio_api_style/bt/template_skin_id_list
master/bt5/slapos_jio_api_style/bt/template_skin_id_list
+1
-0
master/bt5/slapos_jio_api_style/bt/title
master/bt5/slapos_jio_api_style/bt/title
+1
-0
No files found.
master/bt5/slapos_jio_api_style/ActionTemplateItem/portal_types/jIO%20Web%20Section/slapos_jio_api_create_compute_node.xml
0 → 100644
View file @
c219f1fb
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ActionInformation"
module=
"Products.CMFCore.ActionInformation"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
action_type/object_slapos_json_post
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
category
</string>
</key>
<value>
<string>
object_slapos_json_post
</string>
</value>
</item>
<item>
<key>
<string>
condition
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
icon
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
slapos_jio_api_create_compute_node
</string>
</value>
</item>
<item>
<key>
<string>
permissions
</string>
</key>
<value>
<tuple>
<string>
View
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
priority
</string>
</key>
<value>
<float>
10.0
</float>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Create Compute Node
</string>
</value>
</item>
<item>
<key>
<string>
visible
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Expression"
module=
"Products.CMFCore.Expression"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
text
</string>
</key>
<value>
<string>
string:${object_url}/jIOWebSection_createComputeNodeFromJSON
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_jio_api_style/PathTemplateItem/portal_callables/jIOWebSection_createComputeNodeFromJSON.xml
0 → 100644
View file @
c219f1fb
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"JSON Form"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
after_method_id
</string>
</key>
<value>
<string>
jIOWebSection_createComputeNode
</string>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
application/json
</string>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
jIOWebSection_createComputeNodeFromJSON
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
jIOWebSection_createComputeNodeFromJSON
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
JSON Form
</string>
</value>
</item>
<item>
<key>
<string>
text_content
</string>
</key>
<value>
<string>
{\n
"$schema": "http://json-schema.org/draft-07/schema#",\n
"$id": "compute-node-base-schema.json",\n
"title": "Compute Node",\n
"description": "Compute Node",\n
"type": "object",\n
"properties": {\n
"portal_type": {\n
"title": "Portal Type",\n
"const": "Compute Node",\n
"type": "string"\n
},\n
"title": {\n
"title": "Title",\n
"type": "string",\n
"maxLength": 200\n
},\n
"network": {},\n
"site": {},\n
"project": {},\n
"monitoring": {},\n
"capacity_scope": {},\n
"upgrade_scope": {},\n
"allocation_scope": {\n
"type": "string"\n
},\n
"os_type": {\n
"title": "OS Type",\n
"type": "string",\n
"description": "Type of the OS of the current Compute Node"\n
},\n
"public_ipv4_address": {\n
"title": "Public IPV4 Address",\n
"type":"string"\n
},\n
"python_version": {\n
"title": "Python Version",\n
"type": "string"\n
},\n
"slapos_version": {\n
"title": "SlapOS Version",\n
"type": "string"\n
}\n
},\n
"required": ["title", "portal_type"]\n
}\n
</string>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
001
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api.xml
0 → 100644
View file @
c219f1fb
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Folder"
module=
"OFS.Folder"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_objects
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
slapos_jio_api
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/ComputeNode_approveComputer.py
0 → 100644
View file @
c219f1fb
import
json
portal
=
context
.
getPortalObject
()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
request
=
context
.
REQUEST
response
=
request
.
RESPONSE
if
person
is
None
:
response
.
setStatus
(
403
)
else
:
compute_node
=
context
compute_node
.
generateCertificate
()
compute_node
.
approveComputeNodeRegistration
()
response
.
setHeader
(
'Content-Type'
,
"application/json"
)
return
json
.
dumps
({
"certificate"
:
request
.
get
(
'compute_node_certificate'
),
"key"
:
request
.
get
(
'compute_node_key'
),
"reference"
:
compute_node
.
getReference
(),
"relative_url"
:
compute_node
.
getRelativeUrl
()
})
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/ComputeNode_approveComputer.xml
0 → 100644
View file @
c219f1fb
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ComputeNode_approveComputer
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_createComputeNode.py
0 → 100644
View file @
c219f1fb
log_error
=
context
.
ERP5Site_logApiErrorAndReturn
import
json
portal
=
context
.
getPortalObject
()
person
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
request
=
context
.
REQUEST
response
=
request
.
RESPONSE
if
person
is
None
:
response
.
setStatus
(
403
)
else
:
request_kw
=
dict
(
compute_node_title
=
data_dict
[
"title"
],
approve_registration
=
False
,
)
person
.
requestComputeNode
(
**
request_kw
)
compute_node
=
context
.
restrictedTraverse
(
context
.
REQUEST
.
get
(
'compute_node'
))
web_site
=
context
.
getWebSiteValue
()
slapos_master_web_url
=
web_site
.
getLayoutProperty
(
"configuration_slapos_master_web_url"
,
default
=
web_site
.
absolute_url
()
)
request_url
=
"%s/%s"
%
(
slapos_master_web_url
,
"%s/ComputeNode_approveComputer"
%
compute_node
.
getRelativeUrl
())
person
.
requestToken
(
request_url
=
request_url
)
access_token_id
=
context
.
REQUEST
.
get
(
"token"
)
response
.
setHeader
(
'Content-Type'
,
"application/json"
)
return
json
.
dumps
({
"$schema"
:
context
.
getPortalObject
().
portal_types
.
restrictedTraverse
(
compute_node
.
getPortalType
()).
absolute_url
()
+
"/getTextContent"
,
"title"
:
compute_node
.
getTitle
(),
"id"
:
compute_node
.
getRelativeUrl
(),
"reference"
:
compute_node
.
getReference
(),
"access_token"
:
"V2/"
+
compute_node
.
getId
()
+
"/"
+
access_token_id
,
"access_token_url"
:
request_url
,
"modification_date"
:
compute_node
.
getModificationDate
().
HTML4
(),
})
master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_createComputeNode.xml
0 → 100644
View file @
c219f1fb
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
data_dict, form_reference
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
jIOWebSection_createComputeNode
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_jio_api_style/bt/template_action_path_list
0 → 100644
View file @
c219f1fb
jIO Web Section | slapos_jio_api_create_compute_node
\ No newline at end of file
master/bt5/slapos_jio_api_style/bt/template_format_version
0 → 100644
View file @
c219f1fb
1
\ No newline at end of file
master/bt5/slapos_jio_api_style/bt/template_path_list
0 → 100644
View file @
c219f1fb
portal_callables/jIOWebSection_createComputeNodeFromJSON
\ No newline at end of file
master/bt5/slapos_jio_api_style/bt/template_skin_id_list
0 → 100644
View file @
c219f1fb
slapos_jio_api
\ No newline at end of file
master/bt5/slapos_jio_api_style/bt/title
0 → 100644
View file @
c219f1fb
slapos_jio_api_style
\ No newline at end of file
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