Commit 1790de6e authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

slapos_jio_api_style: Add Software Instance Certificate Record

The purpose is to remove certificates from the instance json object
parent 7ffbcc55
<?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_get</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_slapos_json_get</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_get_software_instance_certificate</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Get Software Instance Certificates</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}/SoftwareInstanceCertificateRecord_getFromJSON</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>SoftwareInstanceCertificateRecord_getSoftwareInstanceCertificatesAsJSON</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>SoftwareInstanceCertificateRecord_getFromJSON</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstanceCertificateRecord_getFromJSON</string> </value>
</item>
<item>
<key> <string>output_schema</string> </key>
<value> <string>{\n
"$schema": "http://json-schema.org/draft-07/schema#",\n
"title": "X509 Certificates",\n
"description": "X509 Certificates used by the instance to authentify itself on master",\n
"type": "object",\n
"properties": {\n
"reference": {\n
"title": "Software Instance Reference",\n
"description": "Unique identifier of the Software Instance",\n
"type": "string",\n
"maxLength": 50\n
},\n
"key": {\n
"title": "X509 Key",\n
"type": "string",\n
"descritpion": "X509 Key used by the instance to authentify itself on master"\n
},\n
"certificate": {\n
"title": "X509 Certificate",\n
"type": "string",\n
"descritpion": "X509 Certificate used by the instance to authentify itself on master"\n
},\n
"portal_type": {\n
"title": "Portal Type",\n
"const": "Software Instance Certificate Record",\n
"type": "string"\n
}\n
}\n
}</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
"title": "Get Software Instance Certificate",\n
"description": "Data necessary to get Software Instance Certificates",\n
"type": "object",\n
"properties": {\n
"reference": {\n
"title": "Software Instance Id/Reference",\n
"type": "string",\n
"description": "The unique reference of the Software Instance, example: SOFTINST-1234"\n
},\n
"portal_type": {\n
"title": "Portal Type",\n
"const": "Software Instance Certificate Record",\n
"type": "string"\n
}\n
},\n
"required": [\n
"reference",\n
"portal_type"\n
]\n
}\n
</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>01</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<allowed_content_type_list>
<portal_type id="Software Instance">
<item>Software Instance Certificate Record</item>
</portal_type>
</allowed_content_type_list>
\ No newline at end of file
<property_sheet_list>
<portal_type id="Software Instance Certificate Record">
<item>JSONTypeConstraint</item>
</portal_type>
</property_sheet_list>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="JSON Type" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>acquire_local_roles</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>content_icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Software Instance Certificate Record</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>JSON Type</string> </value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>JSONType</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<workflow_chain>
<chain>
<type>Software Instance Certificate Record</type>
<workflow>edit_workflow, validation_workflow</workflow>
</chain>
</workflow_chain>
\ No newline at end of file
import json
software_instance = context.getParentValue()
return json.dumps({
"$schema": json_form.absolute_url().strip() + "/getOutputJSONSchema",
"reference": software_instance.getReference(),
"key": software_instance.getSslKey(),
"certificate": software_instance.getSslCertificate(),
"portal_type": "Software Instance Certificate Record",
}, indent=2)
<?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, json_form</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareInstanceCertificateRecord_getSoftwareInstanceCertificatesAsJSON</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -30,4 +30,17 @@ elif portal_type == "Software Instance":
if software_instance:
return software_instance
elif portal_type == "Software Instance Certificate Record":
if "reference" in data_dict:
software_instance = portal.portal_catalog.getSoftwareInstanceObject(
data_dict["reference"],
include_shared=True
)
if software_instance:
return software_instance.newContent(
temp_object=True,
portal_type="Software Instance Certificate Record",
)
return None
......@@ -3,6 +3,7 @@ Compute Node | slapos_jio_api_put_compute_node
Slave Instance | slapos_jio_api_get_software_instance
Software Installation | slapos_jio_api_get_software_installation
Software Installation | slapos_jio_api_put_software_installation
Software Instance Certificate Record | slapos_jio_api_get_software_instance_certificate
Software Instance | slapos_jio_api_get_software_instance
Software Instance | slapos_jio_api_put_software_instance
jIO Web Section | slapos_jio_api_create_compute_node
......
......@@ -2,6 +2,7 @@ portal_callables/ComputeNode_getFromJSON
portal_callables/ComputeNode_updateFromJSON
portal_callables/SoftwareInstallation_getFromJSON
portal_callables/SoftwareInstallation_updateFromJSON
portal_callables/SoftwareInstanceCertificateRecord_getFromJSON
portal_callables/SoftwareInstance_getFromJSON
portal_callables/SoftwareInstance_updateFromJSON
portal_callables/jIOWebSection_createComputeNodeFromJSON
......
Software Instance | Software Instance Certificate Record
\ No newline at end of file
Software Instance Certificate Record
\ No newline at end of file
Software Instance Certificate Record | JSONTypeConstraint
\ No newline at end of file
Software Instance Certificate Record | edit_workflow
Software Instance Certificate Record | validation_workflow
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment