+ if ($values) foreach ($values as $t) {
+ //print_r($t);
+ //print("<hr>");
+ $result[$t['hostname']] = "";
+ foreach ($t['colocated'] as $ll) {
+
+ if (strpos($result[$t['hostname']]['all'],$ll['platform_name']) === false) {
+ if ($result[$t['hostname']]['all'] != "")
+ $result[$t['hostname']]['all'] .= ",";
+ $result[$t['hostname']]['all'] .= $ll['platform_name'];
+ }
+
+ if ($ll['platform_name'] == 'SONoMA') {
+ if (strpos($result[$t['hostname']]['sonoma'],$ll['peer_name']) === false) {
+ if ($result[$t['hostname']]['sonoma'] != "")
+ $result[$t['hostname']]['sonoma'] .= ",";
+ $result[$t['hostname']]['sonoma'] .= $ll['peer_name'];
+ }
+ }
+
+ if ($ll['platform_name'] == 'TDMI') {
+ if (strpos($result[$t['hostname']]['tdmi'],$ll['peer_name']) === false) {
+ if ($result[$t['hostname']]['tdmi'] != "")
+ $result[$t['hostname']]['tdmi'] .= ",";
+ $result[$t['hostname']]['tdmi'] .= $ll['peer_name'];
+ }
+ }
+ }
+ }
+
+ $this->TopHatAgents = $result;
+
+ //print_r($this->TopHatAgents);
+
+ return $result;
+}
+
+function getTopHatData($data, $planetlab_nodes) {
+
+ $tophat_auth = array( 'AuthMethod' => 'password', 'Username' => 'guest@top-hat.info', 'AuthString' => 'guest');
+ $tophat_api = new TopHatAPI($tophat_auth);
+
+ $requested_data = explode(",", $data);
+
+ $r = array ('hostname');
+
+ foreach ($requested_data as $rd)
+ if ($rd) $r[] = $rd;
+
+ //print ("Requesting data from TopHat ...");
+ //print_r($r);
+
+ $values = $tophat_api->Get('ips', 'latest', array('hostname' => $planetlab_nodes), $r );
+
+ $result = array();
+
+ if ($values) foreach ($values as $t)
+ foreach ($requested_data as $rd)
+ if ($rd) $result[$t['hostname']][$rd] = $t[$rd];
+
+ //print_r($result);
+
+ return $result;
+}
+
+function getTopHatRefNodes() {
+
+ $tophat_auth = array( 'AuthMethod' => 'password', 'Username' => 'guest@top-hat.info', 'AuthString' => 'guest');
+ $tophat_api = new TopHatAPI($tophat_auth);
+
+ //print "calling tophat for agents";
+
+ $agents = $tophat_api->Get('agents', 'latest', array('peer_name'=>array('PLC', 'PLE'), 'agent_status'=> 'OK'), array('hostname'));
+
+ //print_r($agents);
+
+ return $agents;
+
+}
+
+function getPairwise($ref_node, $planetlab_nodes, $command, $data) {
+
+ $tophat_auth = array( 'AuthMethod' => 'password', 'Username' => 'guest@top-hat.info', 'AuthString' => 'guest');
+ $tophat_api = new TopHatAPI($tophat_auth);
+
+ $traceroute = $tophat_api->Get($command, 'latest', array('src_hostname' => $ref_node, 'dst_hostname' => $planetlab_nodes), array('dst_hostname', $data) );
+
+ print "Got result: ".$traceroute;
+
+ $hopcount = array();
+
+ if ($traceroute)
+ {
+ foreach ($traceroute as $t)
+ {
+ $hopcount[$t['dst_hostname']]=$t[$data];
+ //print " current: ".$t['dst_hostname'].":".$t['hop_count'];
+ }
+
+ return $hopcount;
+ }
+ else
+ return "";
+}
+
+function comon_query_nodes($requested_data) {
+
+ $comon_url = "http://comon.cs.princeton.edu";
+ $comon_api_url = "status/tabulator.cgi?table=table_nodeviewshort&format=formatcsv&dumpcols='name";
+
+ if (MYSLICE_COMON_URL != "")
+ $comon_url = MYSLICE_COMON_URL;
+
+ $url = $comon_url."/".$comon_api_url.$requested_data."'";
+
+ //print ("Retrieving comon data for url ".$url);
+
+ $sPattern = '\', \'';
+ $sReplace = '|';
+
+ $str=file_get_contents($url);
+
+ if ($str === false)
+ return '';
+
+ $result=preg_replace( $sPattern, $sReplace, $str );
+ $sPattern = '/\s+/';
+ $sReplace = ';';
+ $result=preg_replace( $sPattern, $sReplace, $result );
+
+ $comon_data = explode(";", $result);
+ $cl = array();
+ $comon_values = array();
+
+ foreach ($comon_data as $cd) {
+ $cc = explode("|", $cd);
+ if ($cc[0] == "name") {
+ $cl = $cc;
+ }
+ $comon_values[$cc[0]] = array();
+ $cindex=1;
+ foreach ($cl as $cltag) {
+ if ($cltag != "name")
+ $comon_values[$cc[0]][$cltag] = $cc[$cindex++];
+ }
+ }