From: Barış Metin Date: Tue, 16 Nov 2010 11:41:56 +0000 (+0100) Subject: reduce ~400 api calls to a single one X-Git-Tag: plewww-4.3-55~1^2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=261d4e7ad9b06abcd1d960cb8d4a65e95a80d605;p=plewww.git reduce ~400 api calls to a single one --- diff --git a/planetlab/slices/slice.php b/planetlab/slices/slice.php index 24f89a5..b69e88c 100644 --- a/planetlab/slices/slice.php +++ b/planetlab/slices/slice.php @@ -933,15 +933,24 @@ $tag_value_threshold=24; $form->start(); $table->start(); if ($tags) { + // Get hostnames for nodes in a single pass + $_node_ids = array(); + foreach ($tags as $tag) { + if ($tag['node_id']) { + array_push($_node_ids, $tag['node_id']); + } + } + $_nodes = $api->GetNodes(array('node_id' => $_node_ids), array('node_id', 'hostname')); + $_hostnames = array(); + foreach ($_nodes as $_node) { + $_hostnames[$_node['node_id']] = $_node['hostname']; + } + + // Loop through tags again to display foreach ($tags as $tag) { $node_name = "ALL"; if ($tag['node_id']) { - $tag_nodes = $api->GetNodes(array('node_id'=>$tag['node_id'])); - if ($profiling) plc_debug_prof('9 node for slice tag',count($tag_nodes)); - if($tag_nodes) { - $node = $tag_nodes[0]; - $node_name = $node['hostname']; - } + $node_name = $_hostnames[$tag['node_id']]; } $nodegroup_name="n/a"; if ($tag['nodegroup_id']) {