All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 225a2068 authored by Leigh B Stoller's avatar Leigh B Stoller

Add warning when taking a snapshot in the emulab-ops project.

Rearrange things a bit to make the control flow smoother.
parent 5f7477da
......@@ -37,6 +37,7 @@ $(function ()
var multisite = 0;
var APT_NS = "http://www.protogeni.net/resources/rspec/ext/apt-tour/1";
var EMULAB_NS = "http://www.protogeni.net/resources/rspec/ext/emulab/1";
var EMULAB_OPS = "emulab-ops";
var manageTemplate = _.template(manageString);
var waitwaitTemplate = _.template(waitwaitString);
var rendererTemplate = _.template(rendererString);
......@@ -495,15 +496,43 @@ $(function ()
return false;
}
if (window.CLONING) {
console.info("cloning");
// Need to ask if any extra accounts created.
sup.ShowModal('#clone-modal', function () {
if ($('#clone-modal-update-prepare').is(':checked')) {
$('#quickvm_create_profile_form ' +
'[name=update_prepare]').val("yes");
}
SubmitForm();
});
/*
* If cloning into the system project, need to warn the user
* about potentially messing with a system image.
*/
var pid;
if (projlist.length == 1) {
pid = $('$profile_pid').val();
}
else {
pid = $('#profile_pid option:selected').val();
}
if (pid == EMULAB_OPS) {
$('#cancel-update-systemimage').click(function() {
sup.HideModal('#confirm-update-systemimage-modal');
});
$('#confirm-update-systemimage').click(function() {
sup.HideModal('#confirm-update-systemimage-modal');
SubmitForm();
});
sup.ShowModal('#confirm-update-systemimage-modal',
function() {
$('#cancel-update-systemimage')
.off("click");
$('#confirm-update-systemimage')
.off("click");
});
}
else {
// Need to ask if any extra accounts created.
sup.ShowModal('#clone-modal', function () {
if ($('#clone-modal-update-prepare').is(':checked')) {
$('#quickvm_create_profile_form ' +
'[name=update_prepare]').val("yes");
}
SubmitForm();
});
}
}
else {
SubmitForm();
......
......@@ -41,10 +41,12 @@ $(function ()
var user_lockdown = 0;
var lockdown_code = "";
var consolenodes = {};
var diskimages = {};
var showlinktest = false;
var hidelinktest = false;
var extensions = null;
var changingtopo = false;
var EMULAB_OPS = "emulab-ops";
var EMULAB_NS = "http://www.protogeni.net/resources/rspec/ext/emulab/1";
function initialize()
......@@ -1706,6 +1708,19 @@ $(function ()
.parent().addClass('disabled');
}
/*
* Find the disk image (if any) for the node and store it.
*/
if (stype.length) {
var dimage = $(stype).find("disk_image");
if (dimage.length) {
var name = $(dimage).attr("name");
if (name) {
diskimages[node] = name;
}
}
}
/*
* Make a copy of the master context menu and init.
*/
......@@ -1984,40 +1999,6 @@ $(function ()
});
}
//
// Request to start a snapshot. This assumes a single node of course.
//
function StartSnapshot(node_id, update_profile, update_prepare, imagename)
{
sup.ShowWaitWait("Starting image capture, " +
"this can take a minute. Patience please.");
var callback = function(json) {
sup.HideWaitWait();
//console.log("StartSnapshot");
//console.log(json);
if (json.code) {
sup.SpitOops("oops", "Could not start snapshot:<br>" +
"<pre><code>" + json.value + "</code></pre>");
return;
}
ShowProgressModal();
}
var args = {"uuid" : uuid,
"update_profile" : update_profile,
"update_prepare" : update_prepare};
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);
}
//
// This is for snapshot of a single node profile, or a specific
// node in a multi-node profile.
......@@ -2030,21 +2011,44 @@ $(function ()
return;
}
// 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);
//
// Snapshot specific node from the context menu. We give the
// the user some extra options in confirm modal.
// Watch for the case that we would create a new version of a
// system image. Warn the user of this.
//
if (window.APT_OPTIONS.project == EMULAB_OPS) {
$('#cancel-update-systemimage').click(function() {
sup.HideModal('#confirm-update-systemimage-modal');
});
$('#confirm-update-systemimage').click(function() {
sup.HideModal('#confirm-update-systemimage-modal');
var args = {"uuid" : uuid,
"update_profile" : 0,
"update_prepare" : 0};
if (node_id) {
args["node_id"] = node_id;
}
StartSnapshot(args);
});
sup.ShowModal('#confirm-update-systemimage-modal',
function() {
$('#cancel-update-systemimage')
.off("click");
$('#confirm-update-systemimage')
.off("click");
});
return;
}
DoSnapshotNodeAux(node_id);
}
function DoSnapshotNodeAux(node_id)
{
if (node_id) {
// Default to checked any time we show the modal.
$('#snapshot_update_profile').prop("checked", true);
if (ispprofile) {
$('#snapshot_update_profile_div').addClass("hidden");
$('#snapshot_update_script_div').removeClass("hidden");
......@@ -2069,18 +2073,24 @@ $(function ()
$('button#snapshot_confirm').bind("click.snapshot", function (event) {
event.preventDefault();
$('button#snapshot_confirm').unbind("click.snapshot");
if (node_id) {
update_profile =
$('#snapshot_update_profile').is(':checked') ? 1 : 0;
var args = {"uuid" : uuid,
"update_profile" : 1,
"update_prepare" : 0};
if (node_id !== undefined) {
args["node_id"] = node_id;
}
if (node_id && !$('#snapshot_update_profile').is(':checked')) {
args["update_profile"] = 0;
}
if ($('#snapshot_update_prepare').is(':checked')) {
update_prepare = 1;
args["update_prepare"] = 1;
}
if ($('#snapshot_modal #nameyourimage_name').val() != "") {
imagename = $('#snapshot_modal #nameyourimage_name').val();
args["imagename"] =
$('#snapshot_modal #nameyourimage_name').val();
}
sup.HideModal('#snapshot_modal');
StartSnapshot(node_id, update_profile, update_prepare, imagename);
StartSnapshot(args);
});
// Handler for hide modal to unbind the click handler.
......@@ -2089,6 +2099,30 @@ $(function ()
$('button#snapshot_confirm').unbind("click.snapshot");
});
}
function StartSnapshot(args)
{
console.info("sta", args);
sup.HideModal('#snapshot_modal');
sup.ShowWaitWait("Starting image capture, " +
"this can take a minute. Patience please.");
var callback = function(json) {
sup.HideWaitWait();
//console.log("StartSnapshot");
//console.log(json);
if (json.code) {
sup.SpitOops("oops", "Could not start snapshot:<br>" +
"<pre><code>" + json.value + "</code></pre>");
return;
}
ShowProgressModal();
}
var xmlthing =
sup.CallServerMethod(ajaxurl, "status", "SnapShot", args);
xmlthing.done(callback);
}
//
// User clicked on a node, so we want to create a tab to hold
......
......@@ -1179,6 +1179,36 @@ Instructions are optional.
</div>
</div>
</div>
<div id='confirm-update-systemimage-modal' class='modal fade'
data-keyboard='false' data-backdrop='static'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<center>
<h4>You are about to create or update a System Image!</h4>
</center>
<p>
Taking this disk snapshot might result in creating a new
system image or updating an existing system image. Are you
sure you want to do this?
</p>
<p>
<em>Reminder:</em> You will need to run imagerelease on the
cluster (command line).
</p>
<center>
<button type='button' style='margin-right: 20px;'
class='btn btn-primary btn-sm'
id='cancel-update-systemimage'>Cancel</button>
<button class='btn btn-danger btn-sm'
id='confirm-update-systemimage'>Confirm</button>
</center>
</div>
</div>
</div>
</div>
<!-- place to hang the modals for now -->
<div id='showtopomodal_div'></div>
<div id='editmodal_div'></div>
......
......@@ -865,6 +865,36 @@ pre {
</div>
</div>
</div>
<div id='confirm-update-systemimage-modal' class='modal fade'
data-keyboard='false' data-backdrop='static'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<center>
<h4>You are about to create or update a System Image!</h4>
</center>
<p>
Taking this disk snapshot might result in creating a new
system image or updating an existing system image. Are you
sure you want to do this?
</p>
<p>
<em>Reminder:</em> You will need to run <tt>imagerelease</tt> on
the cluster (command line).
</p>
<center>
<button type='button' style='margin-right: 20px;'
class='btn btn-primary btn-sm'
id='cancel-update-systemimage'>Cancel</button>
<button class='btn btn-danger btn-sm'
id='confirm-update-systemimage'>Confirm</button>
</center>
</div>
</div>
</div>
</div>
<div id='waitwait_div'></div>
<div id='terminate_div'></div>
<div id='oops_div'></div>
......
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