Moved nodes2.php to the correct path (sorry for this)
[plewww.git] / planetlab / slices / slice2.php
index a793905..2862f1b 100644 (file)
@@ -406,12 +406,11 @@ $toggle->end();
 //     (.) type is passed to the javascript table, for sorting (default is 'string')
 
 // minimal list as a start
-$node_fixed_columns = array('hostname','node_id','peer_id','slice_ids_whitelist',
+$node_fixed_columns = array('hostname','node_id','peer_id','slice_ids_whitelist', 'site_id',
                            'run_level','boot_state','last_contact','node_type');
 // create a VisibleTags object : basically the list of tag columns to show
-$visibletags = new VisibleTags ($api, 'node');
-$visiblecolumns = $visibletags->column_names();
-$node_columns=array_merge($node_fixed_columns,$visiblecolumns);
+//$visibletags = new VisibleTags ($api, 'node');
+//$visiblecolumns = $visibletags->column_names();
 
 // optimizing calls to GetNodes
 //$all_nodes=$api->GetNodes(NULL,$node_columns);
@@ -437,7 +436,9 @@ $tag_columns = $visibletags->headers();
 // extra columns that are not tags (for the moment not sorted correctly)
 
 $extra_columns = array();
-//$extra_columns[]=array('tagname'=>'site_id', 'header'=>'SN', 'type'=>'string', 'title'=>'Site name', 'description'=>'Site name');
+$extra_columns[]=array('tagname'=>'sitename', 'header'=>'SN', 'type'=>'string', 'title'=>'Site name', 'fetched'=>true);
+$extra_columns[]=array('tagname'=>'domain', 'header'=>'DN', 'type'=>'string', 'title'=>'Toplevel domain name', 'fetched'=>true);
+$extra_columns[]=array('tagname'=>'ipaddress', 'header'=>'IP', 'type'=>'string', 'title'=>'IP Address', 'fetched'=>true);
 
 //get user's column configuration
 
@@ -470,7 +471,7 @@ foreach ($PersonTags as $ptag) {
 $sliceconf_exists = false;
 if ($column_configuration == "")
 {
-       $column_configuration = $slice_id.";";
+       $column_configuration = $slice_id.";default";
        $sliceconf_exists = true;
 }
 else {
@@ -492,7 +493,7 @@ else {
 }
 
 if ($sliceconf_exists == false)
-       $column_configuration = $column_configuration.";".$slice_id.";";
+       $column_configuration = $column_configuration.";".$slice_id.";default";
 
 //print("<br>slice configuration = ".$slice_column_configuration);
 
@@ -505,7 +506,9 @@ else
 
 $ConfigureColumns =new PlekitColumns($full_configuration, $fix_columns, $tag_columns, $extra_columns);
 
-$node_columns = $ConfigureColumns->node_tags();
+$visiblecolumns = $ConfigureColumns->node_tags();
+
+$node_columns=array_merge($node_fixed_columns,$visiblecolumns);
 //print_r($node_columns);
 $all_nodes=$api->GetNodes(NULL,$node_columns);
 
@@ -686,6 +689,20 @@ $ConfigureColumns->javascript_init();
 $toggle_nodes->end();
 
 
+$all_sites=$api->GetSites(NULL, array('site_id','login_base'));
+$site_hash=array();
+foreach ($all_sites as $site) $site_hash[$site['site_id']]=$site['login_base'];
+
+$interface_columns=array('ip','node_id','interface_id');
+$interface_filter=array('is_primary'=>TRUE);
+$interfaces=$api->GetInterfaces($interface_filter,$interface_columns);
+
+$interface_hash=array();
+foreach ($interfaces as $interface) $interface_hash[$interface['node_id']]=$interface;
+
+
+
+
 
 //////////////////// nodes currently in
 $toggle_nodes=new PlekitToggle('my-slice-nodes-current',
@@ -696,7 +713,7 @@ $toggle_nodes->start();
 $headers=array();
 $notes=array();
 //$notes=array_merge($notes,$visibletags->notes());
-$notes [] = "For information about the different columns please see the <b>node table layout</b> tab above";
+$notes [] = "For information about the different columns please see the <b>node table layout</b> tab above or <b>mouse over</b> the column headers";
 
 /*
 $headers['peer']='string';
@@ -740,6 +757,16 @@ $table->cell($node['node_id'], array('display'=>'none'));
   $table->cell ($label,array('class'=>$class));
   $table->cell( ($node['node_type']=='reservable')?reservable_mark():"" );
 
+  $hostname=$node['hostname'];
+  $ip=$interface_hash[$node['node_id']]['ip'];
+  $interface_id=$interface_hash[$node['node_id']]['interface_id'];
+
+//extra columns
+$node['domain'] = topdomain($hostname);
+$node['sitename'] = l_site_t($node['site_id'],$site_hash[$node['site_id']]);
+$node['ipaddress'] = l_interface_t($interface_id,$ip);
+
+
  //foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);
  $ConfigureColumns->cells($table, $node);
 
@@ -799,7 +826,7 @@ if ($privileges) {
     $headers = array_merge($ConfigureColumns->get_headers(),$add_header);
 
     //$notes=array_merge($notes,$visibletags->notes());
-    $notes [] = "For information about the different columns please see the <b>node table layout</b> tab above";
+$notes [] = "For information about the different columns please see the <b>node table layout</b> tab above or <b>mouse over</b> the column headers";
     
     $table=new PlekitTable('add_nodes',$headers,NULL, $table_options);
     $form=new PlekitForm(l_actions(),
@@ -817,6 +844,14 @@ $table->cell($node['node_id'], array('display'=>'none'));
        $table->cell ($label,array('class'=>$class));
        $table->cell( ($node['node_type']=='reservable')?reservable_mark():"" );
 
+       //extra columns
+         $hostname=$node['hostname'];
+         $ip=$interface_hash[$node['node_id']]['ip'];
+         $interface_id=$interface_hash[$node['node_id']]['interface_id'];
+       $node['domain'] = topdomain($hostname);
+       $node['sitename'] = l_site_t($node['site_id'],$site_hash[$node['site_id']]);
+       $node['ipaddress'] = l_interface_t($interface_id,$ip);
+
        //foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);
        $ConfigureColumns->cells($table, $node);