// expects: node_id
$known_actions []= "update-node";
// expects: node_id, hostname, model
+$known_actions []= "attach-pcu";
+// expects: node_id, pcu_id, port (pcu_id <0 means detach)
//////////////////////////////////////// interfaces
$known_actions []= "delete-interfaces";
// expects: interface_ids
$known_actions []="add-interface";
// expects: node_id & interface details
+$known_actions []="new-interface";
+// expects: node_id
$known_actions []="update-interface";
// expects: interface_id & interface details
}
case 'update-node': {
+ $node_id=intval($_POST['node_id']);
$hostname= $_POST['hostname'];
$model= $_POST['model'];
$fields= array( "hostname"=>$hostname, "model"=>$model );
- $api->UpdateNode( intval( $node_id ), $fields );
+ $api->UpdateNode( $node_id, $fields );
$error= $api->error();
if( empty( $error ) ) {
break;
}
+ // this code will ensure that at most one PCU gets attached to the node
+ case 'attach-pcu': {
+ $node_id=intval($_POST['node_id']);
+ $pcu_id=intval($_POST['pcu_id']);
+ $port=intval($_POST['port']);
+ // always start with deleting former PCUs
+ $nodes = $api->GetNodes(array($node_id),array('pcu_ids'));
+ $former_pcu_ids = $nodes[0]['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);
+ else
+ drupal_set_error ('Could not detach node ' . $node_id . ' from PCU ' . $pcu_id);
+ }
+ // re-attach only if provided pcu_id >=0
+ 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);
+ else
+ drupal_set_error ('Failed to attach node ' . $node_id . ' to PCU ' . $pcu_id . ' on port ' . $port);
+ } else {
+ drupal_set_message ('Detached node from all PCUs');
+ }
+
+ plc_redirect(l_node($node_id));
+ break;
+ }
+
+
//////////////////////////////////////////////////////////// interfaces
case 'delete-interfaces' : {
$interface_ids=$_POST['interface_ids'];
drupal_set_error ("Could not delete all selected interfaces, only $counter were removed");
plc_redirect(l_node($_POST['node_id']));
}
-
+ case 'new-interface': {
+ plc_redirect(l_interface_add($_POST['node_id']));
+ }
case 'add-interface': {
$node_id=$_POST['node_id'];
foreach ($interface_details as $field) {
$fields['login_base'] = $_POST['login_base'];
if ($_POST['max_slices'])
$fields['max_slices'] = intval($_POST['max_slices']);
+ if (isset($_POST['enabled'])) {
+ $fields['enabled'] = (bool)$_POST['enabled'];
+ }
$retcod=$api->UpdateSite( intval( $site_id ), $fields );
if ($retcod == 1)