From 3c389f8cf57b86ff5c717a217cef71cf3a6479b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Le=20Ninivin?= <cedric.leninivin@nexedi.com> Date: Wed, 14 Sep 2022 16:03:34 +0000 Subject: [PATCH] slapos_jio_api_style: Fix Search Shared Instance --- .../jIOWebSection_searchInstanceFromJSON.xml | 94 ++++++++++++------- .../jIOWebSection_searchInstance.py | 9 +- 2 files changed, 67 insertions(+), 36 deletions(-) diff --git a/master/bt5/slapos_jio_api_style/PathTemplateItem/portal_callables/jIOWebSection_searchInstanceFromJSON.xml b/master/bt5/slapos_jio_api_style/PathTemplateItem/portal_callables/jIOWebSection_searchInstanceFromJSON.xml index 2601a39da..c142c2a1b 100644 --- a/master/bt5/slapos_jio_api_style/PathTemplateItem/portal_callables/jIOWebSection_searchInstanceFromJSON.xml +++ b/master/bt5/slapos_jio_api_style/PathTemplateItem/portal_callables/jIOWebSection_searchInstanceFromJSON.xml @@ -40,40 +40,70 @@ "description": "Contains a representation of the items",\n "type": "array",\n "items": {\n - "type": "object",\n - "title": "Item",\n - "properties": {\n - "reference": {\n - "title": "Software Instance Reference",\n - "description": "Unique identifier of the Software Instance",\n - "type": "string"\n + "anyOf": [\n + {\n + "type": "object",\n + "title": "Software Instance",\n + "properties": {\n + "reference": {\n + "title": "Software Instance Reference",\n + "description": "Unique identifier of the Software Instance",\n + "type": "string"\n + },\n + "title": {\n + "title": "Unique Title of the Instance",\n + "type": "string"\n + },\n + "state": {\n + "title": "Requested State",\n + "type": "string",\n + "enum": ["started", "stopped", "destroyed"],\n + "description": "State of the requested instance. It is functionnal when started. In stopped state, all services are stopped. If destroyed, it will remove the instance."\n + },\n + "compute_partition_id": {\n + "title": "Compute Partition Id",\n + "type": "string",\n + "description": "Id Of the Requesting Compute Partition, used by Slap Client when an instance is requesting an instance"\n + },\n + "software_release_uri": {\n + "title": "Software Release URI",\n + "type": "string",\n + "description": "URL of the software release used by the software instance"\n + },\n + "portal_type": {\n + "title": "Portal Type",\n + "const": "Software Instance",\n + "type": "string"\n + }\n + }\n },\n - "title": {\n - "title": "Unique Title of the Instance",\n - "type": "string"\n - },\n - "state": {\n - "title": "Requested State",\n - "type": "string",\n - "enum": ["started", "stopped", "destroyed"],\n - "description": "State of the requested instance. It is functionnal when started. In stopped state, all services are stopped. If destroyed, it will remove the instance."\n - },\n - "compute_partition_id": {\n - "title": "Compute Partition Id",\n - "type": "string",\n - "description": "Id Of the Requesting Compute Partition, used by Slap Client when an instance is requesting an instance"\n - },\n - "software_release_uri": {\n - "title": "Software Release URI",\n - "type": "string",\n - "description": "URL of the software release used by the software instance"\n - },\n - "portal_type": {\n - "title": "Portal Type",\n - "const": "Software Instance",\n - "type": "string"\n + {\n + "type": "object",\n + "title": "Shared Instance",\n + "properties": {\n + "reference": {\n + "title": "Software Instance Reference",\n + "description": "Unique identifier of the Software Instance",\n + "type": "string"\n + },\n + "title": {\n + "title": "Unique Title of the Instance",\n + "type": "string"\n + },\n + "state": {\n + "title": "Requested State",\n + "type": "string",\n + "enum": ["started", "stopped", "destroyed"],\n + "description": "State of the requested instance. It is functionnal when started. In stopped state, all services are stopped. If destroyed, it will remove the instance."\n + },\n + "portal_type": {\n + "title": "Portal Type",\n + "const": "Shared Instance",\n + "type": "string"\n + }\n + }\n }\n - }\n + ]\n }\n }\n }\n diff --git a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_searchInstance.py b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_searchInstance.py index 850cfa49f..5605116d7 100644 --- a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_searchInstance.py +++ b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api/jIOWebSection_searchInstance.py @@ -44,7 +44,7 @@ elif portal_type == "Shared Instance": search_kw = { "portal_type": "Slave Instance", "validation_state": "validated", - "select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference", "url_string") + "select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference") } if "host_instance_reference" in data_dict: host_instance_list = portal.portal_catalog( @@ -66,10 +66,11 @@ elif portal_type == "Shared Instance": result_list = [{ "title": x.title, "reference": x.reference, - "portal_type": x.portal_type, - "state": x.slap_state, + "portal_type": "Shared Instance", + "state": slap_state_dict.get(x.slap_state, ""), "compute_partition_id": x.aggregate_reference, - "software_release_uri": x.url_string, + # Slave Instance don't have url_string cataloged. Selecting it return 0 result each time + #"software_release_uri": x.url_string, } for x in portal.portal_catalog(**search_kw)] else: -- 2.30.9