Commit 830abd29 authored by Leigh Stoller's avatar Leigh Stoller

Allow users to name their snapshot images. Turned on for admin/studly

only right now.
parent e38b30c6
......@@ -1862,7 +1862,7 @@ $(function ()
//
// Request to start a snapshot. This assumes a single node of course.
//
function StartSnapshot(node_id, update_profile, update_prepare)
function StartSnapshot(node_id, update_profile, update_prepare, imagename)
{
sup.ShowModal('#waitwait-modal');
......@@ -1883,6 +1883,9 @@ $(function ()
if (node_id !== undefined) {
args["node_id"] = node_id;
}
if (imagename && imagename != "") {
args["imagename"] = imagename;
}
var xmlthing =
sup.CallServerMethod(ajaxurl, "status", "SnapShot", args);
xmlthing.done(callback);
......@@ -1903,6 +1906,7 @@ $(function ()
// Default to update unless checkbox says otherwise.
var update_profile = 1;
var update_prepare = 0;
var imagename = null;
// Default to unchecked any time we show the modal.
$('#snapshot_update_prepare').prop("checked", false);
......@@ -1922,6 +1926,9 @@ $(function ()
$('#snapshot_update_profile_div').removeClass("hidden");
$('#snapshot_update_script_div').addClass("hidden");
}
if (isadmin || isstud) {
$('#snapshot_modal #nameyourimage_div').removeClass("hidden");
}
}
else {
$('#snapshot_update_profile_div').addClass("hidden");
......@@ -1942,8 +1949,11 @@ $(function ()
if ($('#snapshot_update_prepare').is(':checked')) {
update_prepare = 1;
}
if ($('#snapshot_modal #nameyourimage_name').val() != "") {
imagename = $('#snapshot_modal #nameyourimage_name').val();
}
sup.HideModal('#snapshot_modal');
StartSnapshot(node_id, update_profile, update_prepare);
StartSnapshot(node_id, update_profile, update_prepare, imagename);
});
// Handler for hide modal to unbind the click handler.
......
......@@ -944,6 +944,13 @@ function Do_Snapshot()
$ajax_args["update_prepare"]) {
$optargs .= " -U ";
}
if (isset($ajax_args["imagename"]) && $ajax_args["imagename"] != "") {
if (!TBvalid_imagename($ajax_args["imagename"])) {
SPITAJAX_ERROR(1, "Not a valid imagename, alphanumeric only");
return;
}
$optargs .= " -i " . escapeshellarg($ajax_args["imagename"]);
}
#
# Call out to the backend.
......
......@@ -619,7 +619,18 @@ pre {
Check this box if you need to capture the entire disk; you only
need to do this if you put data into one of the unused
partitions on the local disk. <b><em>Do not check this box if you
do not know what this means!</em></b>
do not know what this means!</em></b>
</div>
<div id='nameyourimage_div' class='hidden'>
<br>
<center>
<b>Name your image?</b><br>
<input id="nameyourimage_name"
placeholder="alphanumeric only" type="text">
</center>
Do you want to choose the name of your image yourself? We
do not recommend it, but you can if you want. Alphanumeric
only please.
</div>
<br>
<center>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment