X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fcommon%2Factions.php;h=9950d5b11fae0f6163818009d79ae7849b29714b;hb=824042b05cbc6000a370452133db1faa1146b916;hp=0b4353db4d2040abeb8bf00fda320ef1be11cac6;hpb=0348c099125efad7d6adcea30302ee5071a3e1d4;p=plewww.git diff --git a/planetlab/common/actions.php b/planetlab/common/actions.php index 0b4353d..9950d5b 100644 --- a/planetlab/common/actions.php +++ b/planetlab/common/actions.php @@ -87,6 +87,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'; @@ -99,6 +102,10 @@ $known_actions []= "add-tag-type"; // expects: tag_type_id & tagname & description & category & min_role_id $known_actions []= "delete-tag-types"; // expects: tag_type_ids +$known_actions []= "remove-roles-from-tag-type"; +// expects: tag_type_id & role_ids +$known_actions []= "add-role-to-tag-type"; +// expects: tag_type_id_id & id //////////////////////////////////////// tags $known_actions []= "set-tag-on-node"; @@ -701,6 +708,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=$_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']); @@ -715,7 +765,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; } @@ -815,6 +865,30 @@ Our support team will be glad to answer any question that you might have. break; } + case 'remove-roles-from-tag-type' : { + $tag_type_id=$_POST['tag_type_id']; + $role_ids=$_POST['role_ids']; + if ( ! $role_ids) { + drupal_set_error("You have not selected role(s) to remove"); + } else { + foreach( $role_ids as $role_id) + if ( $api->DeleteRoleFromTagType( intval( $role_id ), intval( $tag_type_id ) ) != 1 ) + drupal_set_error ("Could not remove role $role_id from tag type $tag_type_id"); + } + plc_redirect (l_tag_roles($tag_type_id)); + } + + case 'add-role-to-tag-type' : { + $tag_type_id=$_POST['tag_type_id']; + $role_id=$_POST['role_id']; + if ( ! $role_id) { + drupal_set_error ("You have not selected a role to add"); + } else if ($api->AddRoleToTagType( intval( $role_id ), intval( $tag_type_id ) ) != 1) { + drupal_set_error("Could not add role $role_id to tag $tag_type_id"); + } + plc_redirect (l_tag_roles($tag_type_id)); + } + //////////////////////////////////////// tags case 'set-tag-on-node': case 'set-tag-on-interface': {