X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fcommon%2Factions.php;h=8c4beab6e8233b001949ab2960ebed7b3b6c5dbe;hb=9d5da0d9968a075070eb8c5b75d8267d082bec31;hp=ba6010493bb723631bacc1ffe70bf2ff0c78d9e9;hpb=1d3fcb7473152b367367cc32574b8b126dbc6e26;p=plewww.git diff --git a/planetlab/common/actions.php b/planetlab/common/actions.php index ba60104..8c4beab 100644 --- a/planetlab/common/actions.php +++ b/planetlab/common/actions.php @@ -5,7 +5,8 @@ require_once 'plc_login.php'; // Get session and API handles require_once 'plc_session.php'; -global $plc, $api; +require_once 'plc_api.php'; +global $plc, $api, $adm; //print header require_once 'plc_drupal.php'; @@ -48,7 +49,7 @@ $known_actions []= "node-boot-state"; $known_actions []= "delete-node"; // expects: node_id $known_actions []= "update-node"; -// expects: node_id, hostname, model +// expects: node_id, hostname, model, node_type $known_actions []= "attach-pcu"; // expects: node_id, pcu_id, port (pcu_id <0 means detach) $known_actions []= "reboot-node-with-pcu"; @@ -87,6 +88,9 @@ $known_actions []= 'remove-nodes-from-slice'; // expects: slice_id & node_ids $known_actions []= 'add-nodes-in-slice'; // expects: slice_id & node_ids +$known_actions []= 'update-initscripts'; +// expects: slice_id & name & previous-initscript & previous-initscript-code +// & initscript & initscript-code $known_actions []= 'delete-slice-tags'; // expects: slice_tag_id $known_actions []= 'add-slice-tag'; @@ -345,8 +349,9 @@ switch ($action) { $node_id=intval($_POST['node_id']); $hostname= $_POST['hostname']; $model= $_POST['model']; + $node_type= $_POST['node_type']; - $fields= array( "hostname"=>$hostname, "model"=>$model ); + $fields= array( "hostname"=>$hostname, "model"=>$model, "node_type"=>$node_type ); $api->UpdateNode( $node_id, $fields ); $error= $api->error(); @@ -390,8 +395,10 @@ switch ($action) { case 'reboot-node-with-pcu': { $node_id=intval($_POST['node_id']); $hostname= $_POST['hostname']; + $test = $_POST['test']; + settype($test, "boolean"); - $ret = $api->RebootNodeWithPCU( $node_id ); + $ret = $api->RebootNodeWithPCU( $node_id, $test ); $error= $api->error(); if( empty( $error ) ) { @@ -631,7 +638,7 @@ Our support team will be glad to answer any question that you might have. } } if ($success) { - $api->NotifyPersons($notify_person_ids,$notify_subject,$notify_body); + $adm->NotifyPersons($notify_person_ids,$notify_subject,$notify_body); drupal_set_message ("Deleted $counter person(s)"); } else @@ -671,7 +678,7 @@ Our support team will be glad to answer any question that you might have. } } if ($success) { - $api->NotifyPersons($notify_person_ids,$notify_subject,$notify_body); + $adm->NotifyPersons($notify_person_ids,$notify_subject,$notify_body); drupal_set_message ("Added $counter person(s)"); } else @@ -705,6 +712,49 @@ Our support team will be glad to answer any question that you might have. break; } + case 'update-initscripts': { +// expects: slice_id & name & previous-initscript & previous-initscript-code +// & initscript & initscript-code + $slice_id = intval ($_POST['slice_id']); + $previous_initscript=$_POST['previous-initscript']; + $initscript=$_POST['initscript']; + $previous_initscript_code=html_entity_decode($_POST['previous-initscript-code']); + $initscript_code=$_POST['initscript-code']; + + $changes=FALSE; + if (strcmp($initscript,$previous_initscript) != 0) { + $newvalue=$api->SetSliceInitscript($slice_id,$initscript); + $status = (strcmp($newvalue,$initscript)==0) ? "OK" : "failed"; + if (! $initscript) drupal_set_message("Removed shared initscript '" . $previous_initscript . "' " . $status); + else drupal_set_message("Replaced shared initscript with '" . $initscript . "' " . $status); + $changes=TRUE; + } + + // somehow some \r chars make it here; just ignore them + $previous_initscript_code=str_replace("\r","",$previous_initscript_code); + // plc_debug_txt('previous initscript_code after cr',$previous_initscript_code); + + $initscript_code=str_replace("\r","",$initscript_code); + // make sure the script ends with a single \n + $initscript_code=trim($initscript_code); + if (!empty($initscript_code) && $initscript_code[strlen($initscript_code)-1] != "\n") + $initscript_code.="\n"; + // plc_debug_txt('initscript_code after cr & nl/eof',$initscript_code); + + if (strcmp($initscript_code,$previous_initscript_code) != 0) { + $newvalue=$api->SetSliceInitscriptCode($slice_id,$initscript_code); + // plc_debug_txt('newvalue',$newvalue); + $status=(strcmp($newvalue,$initscript_code)==0) ? "OK" : "failed"; + if (! $initscript_code) drupal_set_message("Removed initscript code " . $status); + else drupal_set_message("Installed new initscript code " . $status); + $changes=TRUE; + } + if (!$changes) drupal_set_message("No changes required in initscript"); + plc_redirect(l_slice($slice_id) . "&show_details=0&show_initscripts=1" ); + break; + } + + case 'delete-slice-tags': { $slice_id = intval($_POST['slice_id']); $slice_tag_ids = array_map("intval", $_POST['slice_tag_ids']); @@ -719,7 +769,7 @@ Our support team will be glad to answer any question that you might have. } if ($success) drupal_set_message ("Deleted $count slice tag(s)"); - plc_redirect(l_slice($slice_id) . "&show_tags=true" ); + plc_redirect(l_slice($slice_id) . "&show_tags=1" ); break; }