Merge branch 'master' of ssh://git.onelab.eu/git/plewww
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 29 Apr 2011 08:19:03 +0000 (10:19 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 29 Apr 2011 08:19:03 +0000 (10:19 +0200)
planetlab/common/actions.php
planetlab/includes/plc_functions.php
planetlab/nodes/node.php
planetlab/sites/pcu.php
planetlab/sites/site.php

index c4290af..7f751b0 100644 (file)
@@ -393,8 +393,10 @@ switch ($action) {
  case 'reboot-node-with-pcu': {
    $node_id=intval($_POST['node_id']);
    $hostname= $_POST['hostname'];
+   $test = $_POST['test'];
+   settype($test, "boolean");
 
-   $ret = $api->RebootNodeWithPCU( $node_id );
+   $ret = $api->RebootNodeWithPCU( $node_id, $test );
    $error= $api->error();
 
    if( empty( $error ) ) {
index a51bf59..a05fdd9 100644 (file)
@@ -75,6 +75,7 @@ function l_actions_download ()                { return "/db/nodes/node_downloads.php"; }
 function l_register_node ()            { return "/registerwizard/index.php"; }
 function l_pcu_add ()                  { return "/registerwizard/index.php/register/stage1_addpcu"; }
 function l_pcu ($pcu_id)               { return "/db/sites/pcu.php?id=$pcu_id"; }
+function l_pcu_href ($pcu_id, $text)           { return href(l_pcu($pcu_id), $text); }
 
 function l_nodes ()                    { return "/db/nodes/index.php"; }
 function l_nodes_peer ($peer_id)       { return "/db/nodes/index.php?peerscope=$peer_id"; }
index cfce37e..f976f50 100644 (file)
@@ -261,9 +261,19 @@ I've experienced a problem rebooting $hostname with the pcu_id $pcu_id;
     $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();
+    // NOTE: not sure how to make the buttons display side-by-side...
+    $reboot = $details->form_start_html(l_actions(),array("action"=>"reboot-node-with-pcu",
+                                "node_id"=>$node_id, "hostname"=>$hostname, "test"=>FALSE));
+    $reboot .= $email . $details->form->submit_html("submit","Reboot Node");
+    $reboot .= $details->form_end_html();
+
+    $reboot .= $details->form_start_html(l_actions(),array("action"=>"reboot-node-with-pcu",
+                                "node_id"=>$node_id, "hostname"=>$hostname, "test"=>TRUE));
+    $reboot .= $details->form->submit_html("submit","Test PCU");
+    $reboot .= $details->form_end_html();
+
+    $details->tr($reboot, "right");
+
 }
 $details->space();
 
index a0fffcd..1ec3089 100644 (file)
@@ -87,6 +87,12 @@ if( !$_GET['id'] ) {
                
   }
        
+  if( in_array( 10, $_roles) ) {
+      $is_admin= true;
+  } else {
+      $is_admin = false;
+  }
+
   if( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $pcu_info[0]['site_id'], $_person['site_ids'] ) ) || ( in_array( 40, $_roles ) && in_array( $pcu_info[0]['site_id'], $_person['site_ids'] ) ) )
     $pcu_controller= true;
 
@@ -128,12 +134,13 @@ if( !$_GET['id'] ) {
     echo "</td></tr>\n
          <tr><th>Model: </th><td>";
   
-  if( $pcu_controller )
+  // NOTE: in general, this value should not be edited, so only allow admins.
+  if( $pcu_controller && $is_admin )
     echo "<input type=text name='model' value='";
                
   echo $pcu_info[0]['model'];
   
-  if( $pcu_controller )
+  if( $pcu_controller && $is_admin )
     echo "'>";
   
   echo "</td></tr>\n
index d80dc5f..760cb0e 100644 (file)
@@ -264,7 +264,7 @@ if ( $local_peer ) {
     if (empty($ports)) return plc_error_html('???');
     $port=$ports[0];
     $pcu=$pcu_hash[$pcu_id];
-    $display= $pcu['hostname'] . ' : ' . $port;
+    $display= l_pcu_href($pcu_id, $pcu['hostname'] . ' : ' . $port);
     $pcu_hash[$pcu_id]['displayed']=true;
     return $display;
   }