Fix a typo
[plewww.git] / planetlab / nodes / node.php
index 5236503..7e02522 100644 (file)
@@ -152,6 +152,7 @@ $details->tr_submit("submit","Update Node");
 $details->form_end();
 if ($privileges) $details->space();
 
+$display_reboot_button = FALSE;
 ////////////////////
 // PCU stuff - not too sure why, but GetPCUs is not exposed to the 'user' role
 $display_pcus = ( $local_peer && (plc_is_admin() || plc_is_pi() || plc_is_tech()));
@@ -174,9 +175,15 @@ if ($display_pcus) {
     $port=$ports[0];
     $pcu_columns = array('hostname');
     $pcu=search_pcu($site_pcus,$pcu_id);
-    if ( ! $pcu ) 
+    if ( ! $pcu ) {
       $pcu_string = plc_error_html("Cannot find PCU " . $pcu_id);
-    // else : regular case - don't set pcu_string
+    } else {
+      // else : regular case - don't set pcu_string
+      // NOTE: temporarily only offer the reboot_button for DC7x00, DRAC, and HPiLO PCU models
+      if ( $pcu['model'] == "IntelAMT" || $pcu['model'] == "DRAC" || $pcu['model'] == "HPiLO" ){
+        $display_reboot_button = TRUE;
+      }
+    }
   } else 
     $pcu_string = plc_warning_html("More than one PCU attached ? ");
 
@@ -227,9 +234,39 @@ if ($display_pcus) {
     
   $details->th_td("PCU",$pcu_value_area);
   $details->form_end();
-  $details->space();
  }
 
+//////////////////// Reboot Node
+if ( $display_reboot_button ) 
+{
+    if ( ! empty($_SESSION['messages']) ) {
+        $msg = $_SESSION['messages']['status'][0];
+    } else {
+        $msg = "";
+    }
+    $body="Hello,
+
+This message is a template from the 'Report a problem' link on the node details page.
+
+I've experienced a problem rebooting $hostname with the pcu_id $pcu_id; 
+
+    http://".PLC_WWW_HOST."/db/sites/pcu.php?id=$pcu_id
+    http://".PLC_WWW_HOST."/db/nodes/node.php?id=$node_id\n\n";
+
+    if ( $msg != "" ) {
+        $body .= "The last time I tried, it returned:\n    $msg\n\n";
+    }
+    $body .= "And, this is what I've tried, which leads me to believe that there is a bug on your side:";
+
+    $url=rawurlencode($body);
+    $email = "<font style='font-size: smaller'>><a href=\"mailto:".PLC_MAIL_SUPPORT_ADDRESS."?Subject=Reporting a problem rebooting $hostname&Body=$url\">Report a problem</a></font>";
+
+    $details->form_start(l_actions(),array("action"=>"reboot-node-with-pcu", "node_id"=>$node_id, "hostname"=>$hostname));
+    print $details->tr_html($email . $details->form->submit_html("submit","Reboot Node"), "right");
+    $details->form_end();
+}
+$details->space();
+
 //////////////////// type & version
 $details->th_td("Type",$node_type);
 $details->th_td("Version",$version);
@@ -241,7 +278,8 @@ $details->th_td("Last contact",$Node->lastContact());
 
 // boot area
 $details->space ();
-$details->th_td ("Observed Boot state",$run_level . ( $Node->stale() ? " -- stale value" : "" ));
+$stale_text =  $Node->stale() ? ("... (more than " . Node::stale_text() . " ago)") : "" ;
+$details->th_td ("Observed Boot state", $run_level . $stale_text);
 if ( ! ($local_peer && $privileges)) {
   // just display it
   $boot_value=$boot_state;
@@ -329,7 +367,6 @@ $form->start();
       $table->row_start();
       $peers->cell ($table,$slice['peer_id']);
       $table->cell (l_slice_t ($slice['slice_id'],$slice['name']));
-      # xxx l_sliver not implemented yet - what should we show exactly ?
       $table->cell (l_sliver_t ($node_id,$slice['slice_id'],'sliver tags'));
       $table->row_end();
     }
@@ -349,7 +386,7 @@ if ( $local_peer ) {
   $tagnames = array_map ("get_tagname",$tags);
   $nodegroups_hash=plc_nodegroup_global_hash($api,$tagnames);
   
-  $toggle = new PlekitToggle ('tags',count_english_warning($tags,'tag'),
+  $toggle = new PlekitToggle ('tags',count_english($tags,'tag'),
                              array('bubble'=>'Inspect and set tags on that node',
                                    'visible'=>get_arg('show_tags',false)));
   $toggle->start();
@@ -432,6 +469,8 @@ if ( $local_peer ) {
     $headers["Type"]="string";
     $headers["MAC"]="string";
     $headers["bw limit"]="sortBandwidth";
+    $headers["tags"]=array('type'=>'int',
+                          'title'=>"number of tags set on interface");
     // a single symbol, marking 'p' for primary and a delete button for non-primary
     if ( $privileges ) $headers[plc_delete_icon()]='string';
 
@@ -451,6 +490,8 @@ if ( $local_peer ) {
       $table->cell($interface['type']);
       $table->cell($interface['mac']);
       $table->cell(pretty_bandwidth($interface['bwlimit']));
+      $table->cell(href(l_interface_tags($interface_id),
+                       count($interface['interface_tag_ids'])));
       if ( $privileges ) {
        if ($interface['is_primary']) {
          $table->cell(plc_bubble("p","Cannot delete a primary interface"));