From 8a604a89bd644528059bd8abcecff883085532f0 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Oct 2010 14:02:35 -0400 Subject: [PATCH] Add a 'Reboot Node' button that uses the API RebootNodeWithPCU for pcu models: IntelAMT, DRAC, and HPiLO only. --- planetlab/common/actions.php | 18 ++++++++++++++++++ planetlab/nodes/node.php | 22 +++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/planetlab/common/actions.php b/planetlab/common/actions.php index 50f6d81..0b4353d 100644 --- a/planetlab/common/actions.php +++ b/planetlab/common/actions.php @@ -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 diff --git a/planetlab/nodes/node.php b/planetlab/nodes/node.php index 7a863f9..694e05f 100644 --- a/planetlab/nodes/node.php +++ b/planetlab/nodes/node.php @@ -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); -- 2.47.0