Commit 0b9c74c8 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Cédric Le Ninivin

slapos_jio_api_style: Search Instance By API Revision

parent ff625229
...@@ -80,10 +80,10 @@ ...@@ -80,10 +80,10 @@
"type": "string",\n "type": "string",\n
"description": "URL of the software release used by the software instance"\n "description": "URL of the software release used by the software instance"\n
},\n },\n
"processing_timestamp": {\n "api_revision": {\n
"title": "Processing Timestamp",\n "title": "API Revision",\n
"type": "number",\n "type": "string",\n
"description": "Timestamp set by the master node to mark when it was last processed in the master node. If it has been processed on master, it needs reprocessing on the compute node."\n "description": "The API Revision is set by the master node to mark when the element was last processed. It is incremental. If revision has changed, critical data has been updated"\n
},\n },\n
"portal_type": {\n "portal_type": {\n
"title": "Portal Type",\n "title": "Portal Type",\n
...@@ -111,10 +111,10 @@ ...@@ -111,10 +111,10 @@
"enum": ["started", "stopped", "destroyed"],\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 "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 },\n
"processing_timestamp": {\n "api_revision": {\n
"title": "Processing Timestamp",\n "title": "API Revision",\n
"type": "number",\n "type": "string",\n
"description": "Timestamp set by the master node to mark when it was last processed in the master node. If it has been processed on master, it needs reprocessing on the compute node."\n "description": "The API Revision is set by the master node to mark when the element was last processed. It is incremental. If revision has changed, critical data has been updated"\n
},\n },\n
"portal_type": {\n "portal_type": {\n
"title": "Portal Type",\n "title": "Portal Type",\n
...@@ -171,10 +171,10 @@ ...@@ -171,10 +171,10 @@
"enum": ["started", "stopped", "destroyed"],\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 "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 },\n
"from_processing_timestamp": {\n "from_api_revision": {\n
"title": "From Processing Timestamp",\n "title": "From API Revision",\n
"type": "number",\n "type": "string",\n
"description": "Filter by processing timestamp. Returns the list of elements having a processing timestamp higher or equal to the one inputed. The Processing Timestamp is set by the master node to mark when the element was last processed. If it has been processed on master, it needs reprocessing on the compute node."\n "description": "Filter by API Revision. Returns the list of elements having an api revision higher or equal to the one inputed. The API Revision is set by the master node to mark when the element was last processed. It is incremental. If revision has changed, critical data has been updated"\n
},\n },\n
"portal_type": {\n "portal_type": {\n
"title": "Portal Type",\n "title": "Portal Type",\n
...@@ -208,10 +208,10 @@ ...@@ -208,10 +208,10 @@
"enum": ["started", "stopped", "destroyed"],\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 "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 },\n
"from_processing_timestamp": {\n "from_api_revision": {\n
"title": "From Processing Timestamp",\n "title": "From API Revision",\n
"type": "number",\n "type": "string",\n
"description": "Filter by processing timestamp. Returns the list of elements having a processing timestamp higher or equal to the one inputed. The Processing Timestamp is set by the master node to mark when the element was last processed. If it has been processed on master, it needs reprocessing on the compute node."\n "description": "Filter by API Revision. Returns the list of elements having an api revision higher or equal to the one inputed. The API Revision is set by the master node to mark when the element was last processed. It is incremental. If revision has changed, critical data has been updated"\n
},\n },\n
"portal_type": {\n "portal_type": {\n
"title": "Portal Type",\n "title": "Portal Type",\n
......
...@@ -20,8 +20,8 @@ if portal_type == "Software Instance": ...@@ -20,8 +20,8 @@ if portal_type == "Software Instance":
search_kw = { search_kw = {
"portal_type": "Software Instance", "portal_type": "Software Instance",
"validation_state": "validated", "validation_state": "validated",
"select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference", "url_string", "slap_date"), "select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference", "url_string", "jio_api_revision.revision"),
"sort_on": ("slap_date", "ASC"), "sort_on": ("jio_api_revision.revision", "ASC"),
"limit": limit "limit": limit
} }
...@@ -35,9 +35,8 @@ if portal_type == "Software Instance": ...@@ -35,9 +35,8 @@ if portal_type == "Software Instance":
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: if "state" in data_dict:
search_kw["slap_state"] = reverse_slap_state_dict.get(data_dict["state"], "") search_kw["slap_state"] = reverse_slap_state_dict.get(data_dict["state"], "")
if "from_processing_timestamp" in data_dict: if "from_api_revision" in data_dict:
search_kw["slap_date"] = ">= %s" % DateTime(data_dict["from_processing_timestamp"]) search_kw["jio_api_revision.revision"] = "> %s" % data_dict["from_api_revision"]
result_list = [{ result_list = [{
"title": x.title, "title": x.title,
"reference": x.reference, "reference": x.reference,
...@@ -45,15 +44,15 @@ if portal_type == "Software Instance": ...@@ -45,15 +44,15 @@ if portal_type == "Software Instance":
"state": slap_state_dict.get(x.slap_state, ""), "state": slap_state_dict.get(x.slap_state, ""),
"compute_partition_id": x.aggregate_reference, "compute_partition_id": x.aggregate_reference,
"software_release_uri": x.url_string, "software_release_uri": x.url_string,
"processing_timestamp": int(x.slap_date), "api_revision": x.revision,
} for x in portal.portal_catalog(**search_kw)] } for x in portal.portal_catalog(**search_kw)]
elif portal_type == "Shared Instance": elif portal_type == "Shared Instance":
search_kw = { search_kw = {
"portal_type": "Slave Instance", "portal_type": "Slave Instance",
"validation_state": "validated", "validation_state": "validated",
"select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference", "slap_date"), "select_list": ("title", "reference", "portal_type", "slap_state", "aggregate_reference", "jio_api_revision.revision"),
"sort_on": ("slap_date", "ASC"), "sort_on": ("jio_api_revision.revision", "ASC"),
"limit": limit "limit": limit
} }
if "host_instance_reference" in data_dict: if "host_instance_reference" in data_dict:
...@@ -73,8 +72,8 @@ elif portal_type == "Shared Instance": ...@@ -73,8 +72,8 @@ elif portal_type == "Shared Instance":
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: if "state" in data_dict:
search_kw["slap_state"] = reverse_slap_state_dict.get(data_dict["state"], "") search_kw["slap_state"] = reverse_slap_state_dict.get(data_dict["state"], "")
if "from_processing_timestamp" in data_dict: if "from_api_revision" in data_dict:
search_kw["slap_date"] = ">= %s" % DateTime(data_dict["from_processing_timestamp"]) search_kw["jio_api_revision.revision"] = "> %s" % data_dict["from_api_revision"]
result_list = [{ result_list = [{
"title": x.title, "title": x.title,
...@@ -82,7 +81,7 @@ elif portal_type == "Shared Instance": ...@@ -82,7 +81,7 @@ elif portal_type == "Shared Instance":
"portal_type": "Shared Instance", "portal_type": "Shared Instance",
"state": slap_state_dict.get(x.slap_state, ""), "state": slap_state_dict.get(x.slap_state, ""),
"compute_partition_id": x.aggregate_reference, "compute_partition_id": x.aggregate_reference,
"processing_timestamp": int(x.slap_date), "api_revision": x.revision,
# Slave Instance don't have url_string cataloged. Selecting it return 0 result each time # Slave Instance don't have url_string cataloged. Selecting it return 0 result each time
#"software_release_uri": x.url_string, #"software_release_uri": x.url_string,
} for x in portal.portal_catalog(**search_kw)] } for x in portal.portal_catalog(**search_kw)]
......
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