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
if REQUEST is not None:
raise Unauthorized
compute_node_dict = {}
compute_partition_dict = {}
node_dict = {}
partition_dict = {}
for compute_node in compute_node_list:
news_dict = compute_node.ComputeNode_getNewsDict()
compute_node_dict[compute_node.getReference()] = news_dict["compute_node"]
compute_partition_dict[compute_node.getReference()] = news_dict["partition"]
reference = compute_node.getReference()
node_dict[reference] = compute_node.getAccessStatus()
partition_dict[reference] = compute_node.getComputePartitionNewsDict()
return {"compute_node": compute_node_dict,
"partition": compute_partition_dict,
return {"compute_node": node_dict,
"partition": partition_dict,
"reference": context.getReference(),
"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 '
if context.getPortalType() == "Organisation":
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in context.Organisation_getComputeNodeTrackingList()])
return base_url + "aggregate_reference:(%s)" % compute_node_reference
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")])
if context.getPortalType() in ["Organisation", "Computer Network"]:
if compute_node_list is None:
return ""
compute_node_reference = ",".join([ '"' + i.getReference() + '"' for i in compute_node_list])
return base_url + "aggregate_reference:(%s)" % compute_node_reference
if context.getPortalType() == "Instance Tree":
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>compute_node_list=None</string> </value>
</item>
<item>
<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