$known_actions []= "update-node";
// expects: node_id, hostname, model
$known_actions []= "attach-pcu";
-// expects: node_id, pcu_id, port_id (pcu_id <0 means detach)
+// expects: node_id, pcu_id, port (pcu_id <0 means detach)
//////////////////////////////////////// interfaces
$known_actions []= "delete-interfaces";
// this code will ensure that at most one PCU gets attached to the node
case 'attach-pcu': {
- $node_id=$_POST['node_id'];
- $pcu_id=$_POST['node_id'];
- $port=$_POST['port'];
+ $node_id=intval($_POST['node_id']);
+ $pcu_id=intval($_POST['pcu_id']);
+ $port=intval($_POST['port']);
// always start with deleting former PCUs
- $former_pcu_ids = $api->GetNodes(array($node_id),array('pcu_ids'));
+ $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_error ('Could not detach from PCU ' . $pcu_id);
- }
+ if ($api->DeleteNodeFromPCU($node_id,$former_pcu_id) == 1)
+ drupal_set_message ('Detached node ' . $node_id . ' from PCU ' . $pcu_id);
+ else
+ 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);
$details->form_end();
if ($privileges) $details->space();
+////////////////////
// PCU stuff - not too sure why, but GetPCUs is not exposed to the 'user' role
$display_pcus = (plc_is_admin() || plc_is_pi() || plc_is_tech());
if ($display_pcus) {
} else {
$pcu_add_link = href (l_pcu_add(),plc_add_icon());
- $pcu_selectors = array(array('display'=>'None','value'=>-1));
+ // first option in pcus
+ if ($pcu_ids)
+ $none_detach = 'Detach';
+ else
+ $none_detach='None';
+ $pcu_selectors = array(array('display'=>$none_detach,'value'=>-1));
+ // one option per site pcu
foreach ($site_pcus as $site_pcu) {
$selector=array('display'=>$site_pcu['hostname'],'value'=>$site_pcu['pcu_id']);
if ($pcu_id == $site_pcu['pcu_id']) $selector['selected']=true;
$details->space();
}
+//////////////////// type & version
$details->th_td("Type",$node_type);
$details->th_td("Version",$version);
// let's use plc_objects