more memory needed for the nodes page
[plewww.git] / planetlab / nodes / nodes.php
index fca8214..ebe8079 100644 (file)
@@ -20,7 +20,7 @@ require_once 'linetabs.php';
 require_once 'table.php';
 require_once 'nifty.php';
 
-ini_set("memory_limit","48M");
+ini_set("memory_limit","64M");
 
 // -------------------- 
 // recognized URL arguments
@@ -28,11 +28,17 @@ $peerscope=$_GET['peerscope'];
 $pattern=$_GET['pattern'];
 $site_id=intval($_GET['site_id']);
 $slice_id=intval($_GET['slice_id']);
+$person_id=intval($_GET['person_id']);
 
 // --- decoration
 $title="Nodes";
 $tabs=array();
-$tabs []= tab_nodes_mysite();
+$tabs []= tab_nodes();
+if (count (plc_my_site_ids()) == 1) {
+    $tabs []= tab_nodes_mysite();
+} else {
+    $tabs []= tab_nodes_all_mysite();
+}
 $tabs []= tab_nodes_local();
 
 // -------------------- 
@@ -54,9 +60,8 @@ function node_status ($node) {
   return plc_vertical_table($messages,'plc-warning');
 }
 
-
 // fetch nodes 
-$node_columns=array('hostname','node_type','site_id','node_id','boot_state','interface_ids','peer_id', 'arch','slice_ids');
+$node_columns=array('hostname','node_type','site_id','node_id','boot_state','run_level','interface_ids','peer_id', 'arch','slice_ids');
 // server-side filtering - set pattern in $_GET for filtering on hostname
 if ($pattern) {
   $node_filter['hostname']=$pattern;
@@ -88,6 +93,23 @@ if ($slice_id) {
   $node_filter['node_id'] = $slice['node_ids'];
  }
 
+// person_id is set : this is mostly oriented towards people managing several sites
+if ($person_id) {
+  // avoid doing a useless call to GetPersons if the person_id is already known though $plc,
+  // as this is mostly done for the 'all my sites nodes' link
+  if ($person_id == plc_my_person_id()) { 
+    $person=plc_my_person();
+    $site_ids = plc_my_site_ids();
+  } else {
+    // fetch the person's site_ids
+    $persons = $api->GetPersons(array('person_id'=>$person_id),array('person_id','email','site_ids'));
+    $person=$persons[0];
+    $site_ids=$person['site_ids'];
+  }
+  $title .= t_person($person);
+  $node_filter['site_id']=$site_ids;
+ }
+
 // go
 $nodes=$api->GetNodes($node_filter,$node_columns);
 
@@ -127,21 +149,21 @@ if ( ! $nodes ) {
   
 $nifty=new PlekitNifty ('','objects-list','big');
 $nifty->start();
-$headers = array ();
+$headers = array (); $offset=0;
+if (plc_is_admin()) { $headers["I"]="int"; $offset=1; }
 $headers["P"]="string";
 $headers["R"]="string";
 $headers["Site"]="string";
 $headers["State"]="string";
 $headers["Hostname"]="string";
 $headers["Type"]="string";
-$headers["IP"]="IPAddress";
+$headers["IP"]="sortIPAddress";
 $headers["A"]="string";
 $headers["S"]='int';
-if (plc_is_admin()) $headers["I"]="int";
 $headers["?"]="string";
 
 # initial sort on hostnames
-$table=new PlekitTable ("nodes",$headers,4);
+$table=new PlekitTable ("nodes",$headers,4+$offset);
 $table->start();
 
 $peers = new Peers ($api);
@@ -158,26 +180,32 @@ foreach ($nodes as $node) {
   $node_type = $node['node_type'];
   
   $table->row_start();
+  if (plc_is_admin()) $table->cell(l_node_t($node_id,$node_id));
   $peers->cell ($table,$peer_id);
   $table->cell (topdomain($hostname));
   $table->cell (l_site_t($site_id,$login_base));
-  $table->cell ($node['boot_state']);
+  if ($node['run_level']) {
+      $table->cell($node['run_level']);
+  } else {
+      $table->cell ($node['boot_state'] . '*');
+  }
   $table->cell (l_node_t($node_id,$hostname));
   $table->cell ($node_type);
   $table->cell (l_interface_t($interface_id,$ip),array('only-if'=> !$peer_id));
   $table->cell ($node['arch'],array('only-if'=> !$peer_id));
   $table->cell (count($node['slice_ids']));
-  if (plc_is_admin()) $table->cell(l_node_t($node_id,$node_id));
   $table->cell (node_status($node));
   $table->row_end();
   
 }
 
 $notes=array();
+if (plc_is_admin()) $notes []= "I = node_id";
 $notes []= "R = region";
 $notes []= "A = arch";
 $notes []= "S = number of slivers";
-if (plc_is_admin()) $notes []= "I = node_id";
+$notes []= "? = status";
+$notes []= "status* = node doesn't have an observed state, preferred state is displayed";
 $table->end(array('notes'=>$notes));
 $nifty->end();