a little better
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 4 Jun 2009 10:30:36 +0000 (10:30 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 4 Jun 2009 10:30:36 +0000 (10:30 +0000)
planetlab/common/actions.php
planetlab/includes/plc_functions.php
planetlab/nodes/node.php

index 15df84d..eff610a 100644 (file)
@@ -340,9 +340,7 @@ switch ($action) {
    $port=intval($_POST['port']);
    // always start with deleting former PCUs
    $nodes = $api->GetNodes(array($node_id),array('pcu_ids'));
-   drupal_set_message('got ' . count($nodes) . ' nodes');
    $former_pcu_ids = $nodes[0]['pcu_ids'];
-   drupal_set_message('got ' . count($former_pcu_ids) . ' former_pcu_ids');
    if ($former_pcu_ids) foreach ($former_pcu_ids as $former_pcu_id) {
        if ($api->DeleteNodeFromPCU($node_id,$former_pcu_id) == 1) 
         drupal_set_message ('Detached node ' . $node_id . ' from PCU ' . $pcu_id);
@@ -350,7 +348,6 @@ switch ($action) {
         drupal_set_error ('Could not detach node ' . $node_id . ' from PCU ' . $pcu_id);
      }
    // re-attach only if provided pcu_id >=0
-   plc_debug('pcu_id',$pcu_id);
    if ($pcu_id >= 0) {
      if ($api->AddNodeToPCU($node_id,$pcu_id,$port) == 1)
        drupal_set_message ('Attached node ' . $node_id . ' to PCU ' . $pcu_id . ' on port ' . $port);
index 03067c6..adffb69 100644 (file)
@@ -328,10 +328,10 @@ function plc_itemize ($messages, $class="") {
   return $formatted;
 }
 
-function plc_error ($text) {
-  // should use the same channel as the php errors..
-  print "<div class='plc-error'> Error " . $text . "</div>";
-}
+//////////
+// should use the same channel as the php errors..
+function plc_error_html ($text)                { return  "<div class='plc-error'> " . $text . "</div>"; }
+function plc_error ($text)             { print plc_error_html ("Error " . $text); }
 
 function plc_errors ($errors) {
   if ($errors) {
index b89041d..4ac43f8 100644 (file)
@@ -166,7 +166,7 @@ if ($display_pcus) {
   $site_pcus = $api->GetPCUs(array('site_id'=>$site_id));
   // not sure what the exact semantics is, but I expect pcu_ids and ports should have same cardinality
   if (count ($pcu_ids) != count ($ports)) 
-    $pcu_string = "Unexpected condition: " . count($pcu_ids) . " pcu_ids and " . count($ports) . " ports";
+    $pcu_string = plc_error_html("Unexpected condition: " . count($pcu_ids) . " pcu_ids and " . count($ports) . " ports");
   else if (count($pcu_ids) == 0) 
     $pcu_string = plc_warning_html("No PCU !");
   else if (count($pcu_ids) == 1) {
@@ -175,12 +175,12 @@ if ($display_pcus) {
     $pcu_columns = array('hostname');
     $pcu=search_pcu($site_pcus,$pcu_id);
     if ( ! $pcu ) 
-      $pcu_string = "Cannot find PCU " . $pcu_id;
-    else
-      $pcu_string = $pcu['hostname'] . " on port " . $port;
+      $pcu_string = plc_error_html("Cannot find PCU " . $pcu_id);
+    // else : regular case - don't set pcu_string
   } else 
     $pcu_string = plc_warning_html("More than one PCU attached ? ");
 
+  // in the regular case, pcu_string is not set here
   
   $details->form_start(l_actions(),array("action"=>"attach-pcu","node_id"=>$node_id));
   // prepare selectors
@@ -220,7 +220,12 @@ if ($display_pcus) {
     $pcu_update_area = $pcu_add_link . " " . $pcu_chooser . " " . $port_chooser . " " . $pcu_attach_button;
   }
 
-  $details->th_td("PCU",plc_vertical_table(array($pcu_string,$pcu_update_area)));
+  if ($pcu_string) 
+    $pcu_value_area=plc_vertical_table(array($pcu_string,$pcu_update_area));
+  else 
+    $pcu_value_area=$pcu_update_area;
+    
+  $details->th_td("PCU",$pcu_value_area);
   $details->form_end();
   $details->space();
  }