$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);
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);
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) {
$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) {
$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
$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();
}