Add a 'Reboot Node' button that uses the API RebootNodeWithPCU for pcu models:
authorroot <root@pl-service-04.cs.princeton.edu>
Fri, 1 Oct 2010 18:02:35 +0000 (14:02 -0400)
committerroot <root@pl-service-04.cs.princeton.edu>
Fri, 1 Oct 2010 18:02:35 +0000 (14:02 -0400)
IntelAMT, DRAC, and HPiLO only.

planetlab/common/actions.php
planetlab/nodes/node.php

index 50f6d81..0b4353d 100644 (file)
@@ -51,6 +51,8 @@ $known_actions []= "update-node";
 //     expects:        node_id, hostname, model
 $known_actions []= "attach-pcu";
 //     expects:        node_id, pcu_id, port (pcu_id <0 means detach)
+$known_actions []= "reboot-node-with-pcu";
+//     expects:        node_id
 
 //////////////////////////////////////// interfaces
 $known_actions []= "delete-interfaces";        
@@ -380,6 +382,22 @@ switch ($action) {
    plc_redirect(l_node($node_id));
    break;
  }
+
+ case 'reboot-node-with-pcu': {
+   $node_id=intval($_POST['node_id']);
+   $hostname= $_POST['hostname'];
+
+   $ret = $api->RebootNodeWithPCU( $node_id );
+   $error= $api->error();
+
+   if( empty( $error ) ) {
+     drupal_set_message("Reboot node $hostname: $ret");
+     plc_redirect(l_node($node_id));
+   } else {
+     drupal_set_error($error);
+   }
+   break;
+ }
    
 
 //////////////////////////////////////////////////////////// interfaces
index 7a863f9..694e05f 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,18 @@ if ($display_pcus) {
     
   $details->th_td("PCU",$pcu_value_area);
   $details->form_end();
-  $details->space();
  }
 
+//////////////////// Reboot Node
+if ( $display_reboot_button ) 
+{
+    $details->form_start(l_actions(),array("action"=>"reboot-node-with-pcu", "node_id"=>$node_id, "hostname"=>$hostname));
+    $details->tr_submit("submit", "Reboot Node");
+    $details->form_end();
+    //if ($privileges) $details->space();
+}
+$details->space();
+
 //////////////////// type & version
 $details->th_td("Type",$node_type);
 $details->th_td("Version",$version);