From 4f4ade3627e5dc05363f47a3ad40382b02dc0e40 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Thu, 4 Jun 2009 10:30:36 +0000 Subject: [PATCH] a little better --- planetlab/common/actions.php | 3 --- planetlab/includes/plc_functions.php | 8 ++++---- planetlab/nodes/node.php | 15 ++++++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/planetlab/common/actions.php b/planetlab/common/actions.php index 15df84d..eff610a 100644 --- a/planetlab/common/actions.php +++ b/planetlab/common/actions.php @@ -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); diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index 03067c6..adffb69 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -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 "
Error " . $text . "
"; -} +////////// +// should use the same channel as the php errors.. +function plc_error_html ($text) { return "
" . $text . "
"; } +function plc_error ($text) { print plc_error_html ("Error " . $text); } function plc_errors ($errors) { if ($errors) { diff --git a/planetlab/nodes/node.php b/planetlab/nodes/node.php index b89041d..4ac43f8 100644 --- a/planetlab/nodes/node.php +++ b/planetlab/nodes/node.php @@ -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(); } -- 2.47.0