Commit d3dfa4a3 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Speed up getMonitorUrl for status

  Dont fetch the list twice for Network and Organisation
  We dont use Project anymore
  Direct call API for getAccessStatus instead call ComputeNode_getNewsDict
parent b72b662d
...@@ -2,15 +2,15 @@ from zExceptions import Unauthorized ...@@ -2,15 +2,15 @@ from zExceptions import Unauthorized
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
compute_node_dict = {} node_dict = {}
compute_partition_dict = {} partition_dict = {}
for compute_node in compute_node_list: for compute_node in compute_node_list:
news_dict = compute_node.ComputeNode_getNewsDict() reference = compute_node.getReference()
compute_node_dict[compute_node.getReference()] = news_dict["compute_node"] node_dict[reference] = compute_node.getAccessStatus()
compute_partition_dict[compute_node.getReference()] = news_dict["partition"] partition_dict[reference] = compute_node.getComputePartitionNewsDict()
return {"compute_node": compute_node_dict, return {"compute_node": node_dict,
"partition": compute_partition_dict, "partition": partition_dict,
"reference": context.getReference(), "reference": context.getReference(),
"portal_type": context.getPortalType(), "portal_type": context.getPortalType(),
"monitor_url": context.Base_getStatusMonitorUrl()} "monitor_url": context.Base_getStatusMonitorUrl(compute_node_list=compute_node_list)}
base_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND ' base_url = 'https://monitor.app.officejs.com/#/?page=ojsm_dispatch&query=portal_type:"Software Instance" AND '
if context.getPortalType() == "Organisation": if context.getPortalType() in ["Organisation", "Computer Network"]:
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in context.Organisation_getComputeNodeTrackingList()]) if compute_node_list is None:
return base_url + "aggregate_reference:(%s)" % compute_node_reference return ""
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in compute_node_list])
if context.getPortalType() == "Project":
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in context.Project_getComputeNodeTrackingList()])
return base_url + "aggregate_reference:(%s)" % compute_node_reference
if context.getPortalType() == "Computer Network":
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in context.getSubordinationRelatedValueList(portal_type="Compute Node")])
return base_url + "aggregate_reference:(%s)" % compute_node_reference return base_url + "aggregate_reference:(%s)" % compute_node_reference
if context.getPortalType() == "Instance Tree": if context.getPortalType() == "Instance Tree":
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>compute_node_list=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
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