Commit fb789ba2 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Romain Courteaud

slapos_jio_api_style: Add State parameter in search instance

parent af9d9744
...@@ -115,6 +115,12 @@ ...@@ -115,6 +115,12 @@
"type": "string",\n "type": "string",\n
"description": "Title of the Instance at the root of the instance tree. This is the title of the instance that has been requested by the user."\n "description": "Title of the Instance at the root of the instance tree. This is the title of the instance that has been requested by the user."\n
},\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 "portal_type": {\n
"title": "Portal Type",\n "title": "Portal Type",\n
"const": "Software Instance",\n "const": "Software Instance",\n
...@@ -141,6 +147,12 @@ ...@@ -141,6 +147,12 @@
"type": "string",\n "type": "string",\n
"description": "Title of the Instance at the root of the instance tree. This is the title of the instance that has been requested by the user."\n "description": "Title of the Instance at the root of the instance tree. This is the title of the instance that has been requested by the user."\n
},\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 "portal_type": {\n
"title": "Portal Type",\n "title": "Portal Type",\n
"const": "Shared Instance",\n "const": "Shared Instance",\n
......
portal_type = data_dict["portal_type"] portal_type = data_dict["portal_type"]
portal = context.getPortalObject() portal = context.getPortalObject()
reverse_slap_state_dict = {
"stopped": "stop_requested",
"started": "start_requested",
"destroyed": "destroy_requested",
}
slap_state_dict = { slap_state_dict = {
"stop_requested": "stopped", "stop_requested": "stopped",
"start_requested": "started", "start_requested": "started",
...@@ -22,6 +28,8 @@ if portal_type == "Software Instance": ...@@ -22,6 +28,8 @@ if portal_type == "Software Instance":
search_kw["aggregate_reference"] = data_dict["compute_partition_id"] search_kw["aggregate_reference"] = data_dict["compute_partition_id"]
if "root_instance_title" in data_dict: if "root_instance_title" in data_dict:
search_kw["strict_specialise_title"] = data_dict["root_instance_title"] search_kw["strict_specialise_title"] = data_dict["root_instance_title"]
if "state" in data_dict:
search_kw["slap_state"] = reverse_slap_state_dict.get(data_dict["state"], "")
result_list = [{ result_list = [{
"title": x.title, "title": x.title,
...@@ -53,7 +61,8 @@ elif portal_type == "Shared Instance": ...@@ -53,7 +61,8 @@ elif portal_type == "Shared Instance":
search_kw["strict_aggregate_uid"] = host_instance_list[0].getObject().getAggregateUid() search_kw["strict_aggregate_uid"] = host_instance_list[0].getObject().getAggregateUid()
if "root_instance_title" in data_dict: if "root_instance_title" in data_dict:
search_kw["strict_specialise_title"] = data_dict["root_instance_title"] search_kw["strict_specialise_title"] = data_dict["root_instance_title"]
#return portal.portal_catalog(src__=1, **search_kw) if "state" in data_dict:
search_kw["slap_state"] = reverse_slap_state_dict.get(data_dict["state"], "")
result_list = [{ result_list = [{
"title": x.title, "title": x.title,
"reference": x.reference, "reference": x.reference,
......
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