Commit 9e55651a authored by Leigh Stoller's avatar Leigh Stoller

Add wholedisk option to the Create Image modal:

1. The Geni path already supported this, just needed to add it to the
   web UI and plumb it through.

2. This is featurized, so on the Mothership only users with the feature
   will see this, not something we want mere users to do.
parent 9f1b6c28
......@@ -2532,7 +2532,7 @@ sub ConsoleURL($$)
sub CreateImage($$$$;$$$$$)
{
my ($self, $sliver_urn, $imagename, $update_prepare,
$copyback_uuid, $bsname, $nosnapshot, $mustnotexist) = @_;
$copyback_uuid, $bsname, $nosnapshot, $mustnotexist, $wholedisk) = @_;
my $authority = $self->GetGeniAuthority();
my $geniuser = $self->instance()->GetGeniUser();
my $slice = $self->instance()->GetGeniSlice();
......@@ -2569,6 +2569,8 @@ sub CreateImage($$$$;$$$$$)
if ($nosnapshot);
$args->{'mustnotexist'} = 1
if ($mustnotexist);
$args->{'wholedisk'} = 1
if ($wholedisk);
my $cmurl = $authority->url();
$cmurl = devurl($cmurl) if ($usemydevtree);
......
......@@ -806,7 +806,7 @@ sub DoSnapShotInternal($$$$$)
my $response = $aggregate->CreateImage($sliver_urn,
$dataset->dataset_id(), 0,
$dataset->_copyback_uuid(),
$bsname, 0, 0);
$bsname, 0, 0, 0);
if ($response->code() != GENIRESPONSE_SUCCESS) {
$errmsg = "SnapshotDataset failed: ". $response->output() . "\n";
goto failed;
......
......@@ -300,12 +300,13 @@ sub DoSnapshot()
my $swebtask;
my $nosnapshot = 0;
my $mustnotexist = 0;
my $wholedisk = 0;
my $update_prepare = 0;
my $doversions = 0;
my $usetracker = 0;
my $operation = "image-only"; # Default to just snapshot.
my $optlist = "n:i:u:Uc:O:Ss";
my $optlist = "n:i:u:Uc:O:Sse";
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
......@@ -331,6 +332,11 @@ sub DoSnapshot()
if (defined($options{"s"})) {
$nosnapshot = 1;
}
if (defined($options{"e"})) {
$wholedisk = 1;
# Must be a brand new image for wholedisk.
$mustnotexist = 1;
}
if (defined($options{"S"})) {
$nosnapshot = 1;
$mustnotexist = 1;
......@@ -585,7 +591,7 @@ sub DoSnapshot()
my $response =
$aggregate->CreateImage($sliver_urn, $imagename,
$update_prepare, $copyback_uuid,
undef, $nosnapshot, $mustnotexist);
undef, $nosnapshot, $mustnotexist, $wholedisk);
if (!defined($response)) {
$errmsg = "Internal error creating image";
if (!$nosnapshot) {
......
......@@ -223,10 +223,11 @@ else {
#
sub CreateProfile()
{
my $optlist = "s:c:Un:";
my $optlist = "s:c:Un:e";
my $snap = 0;
my $copy = 0;
my $prepare = 0;
my $wholedisk = 0;
my $copyuuid;
my $fromrepo = 0;
my $instance;
......@@ -246,6 +247,9 @@ sub CreateProfile()
if (defined($options{"U"})) {
$prepare = 1;
}
if (defined($options{"e"})) {
$wholedisk = 1;
}
if (defined($options{"n"})) {
$node_id = $options{"n"};
}
......@@ -396,7 +400,8 @@ sub CreateProfile()
my $ptask_id = $pwebtask->task_id();
# But the image details are stored in the instance webtask.
my $iwebtask = $instance->webtask();
my $prepopt = $prepare ? "-U" : "";
my $prepopt = $prepare ? "-U " : "";
$prepopt .= $wholedisk ? "-e " : "";
if ($profile->Lock()) {
$profile->Delete(1);
......
......@@ -21,7 +21,8 @@ $(function ()
var isfadmin = 0;
var isguest = 0;
var isstud = 0;
var isscript = 0;
var wholedisk = 0;
var isscript = 0;
var dossh = 1;
var profile_uuid= null;
var extend = null;
......@@ -58,6 +59,7 @@ $(function ()
isfadmin= window.APT_OPTIONS.isfadmin;
isstud = window.APT_OPTIONS.isstud;
isguest = (window.APT_OPTIONS.registered ? false : true);
wholedisk = window.APT_OPTIONS.wholedisk;
dossh = window.APT_OPTIONS.dossh;
extend = window.APT_OPTIONS.extend || null;
isscript = window.APT_OPTIONS.isscript;
......@@ -2052,6 +2054,7 @@ $(function ()
switch($(this).val()) {
case 'update-profile':
$('#snapshot-name-div').addClass("hidden");
$('#snapshot-wholedisk-div').addClass("hidden");
$('#snapshot_modal .choose-project-div').addClass("hidden");
break;
case 'copy-profile':
......@@ -2059,6 +2062,9 @@ $(function ()
$('#snapshot-name-div .new-profile').removeClass("hidden");
$('#snapshot-name-div .image-only').addClass("hidden");
$('#snapshot-name-div').removeClass("hidden");
if (wholedisk) {
$('#snapshot-wholedisk-div').removeClass("hidden");
}
if (0 && projlist.length > 1) {
$('#snapshot_modal .choose-project-div')
.removeClass("hidden");
......@@ -2068,6 +2074,9 @@ $(function ()
$('#snapshot-name-div .new-profile').addClass("hidden");
$('#snapshot-name-div .image-only').removeClass("hidden");
$('#snapshot-name-div').removeClass("hidden");
if (wholedisk) {
$('#snapshot-wholedisk-div').removeClass("hidden");
}
$('#snapshot_modal .choose-project-div').addClass("hidden");
break;
}
......@@ -2142,7 +2151,8 @@ $(function ()
$('#snapshot_modal .project-error').addClass("hidden");
// Default to unchecked any time we show the modal.
$('#snapshot_update_prepare').prop("checked", false);
//$('#snapshot_update_prepare').prop("checked", false);
//$('#snapshot-wholedisk').prop("checked", false);
//
// Watch for the case that we would create a new version of a
......@@ -2219,6 +2229,12 @@ $(function ()
if ($('#snapshot_update_prepare').is(':checked')) {
args["update_prepare"] = 1;
}
if (wholedisk &&
$('#snapshot-wholedisk').is(':checked') &&
(operation == "copy-profile" ||
operation == "new-profile" || operation == "image-only")) {
args["wholedisk"] = 1;
}
$('button#snapshot_confirm').unbind("click.snapshot");
if (operation == "copy-profile" || operation == "new-profile") {
NewProfile(args);
......@@ -2250,6 +2266,17 @@ $(function ()
console.log(json);
if (json.code) {
if (json.code == 17 && _.has(args, "wholedisk")) {
sup.SpitOops("oops",
"There is already an image with the " +
"the name you requested. When using the " +
"<em>wholedisk</em> option, you must create " +
"a brand new image. " +
"If you really want to use this name, " +
"please <a href='list-images.php'>" +
"delete the existing image first</a>.");
return;
}
sup.SpitOops("oops", "Could not start snapshot:<br>" +
"<pre><code>" + json.value + "</code></pre>");
return;
......
......@@ -979,6 +979,9 @@ function Do_Snapshot()
$ajax_args["update_prepare"]) {
$optargs .= " -U ";
}
if (isset($ajax_args["wholedisk"]) && $ajax_args["wholedisk"]) {
$optargs .= " -e ";
}
if (isset($ajax_args["nosnapshot"]) && $ajax_args["nosnapshot"]) {
$optargs .= " -S ";
}
......
......@@ -185,10 +185,11 @@ $freenodes_url = Aggregate::Lookup($instance->aggregate_urn())->FreeNodesURL()
$lockout = $instance->extension_lockout();
$isopenstack = $instance->isopenstack();
$paniced = $instance->paniced();
$project = $instance->pid();
$group = $instance->gid();
$pid = $instance->pid();
$gid = $instance->gid();
$extensions = ExtensionInfo::LookupForInstance($instance);
$isstud = (isset($this_user) && $this_user->stud() ? 1 : 0);
$wholedisk = FeatureEnabled("WholeDiskImage", $creator, $instance->Group());
#
# We give ssh to the creator (real user or guest user).
......@@ -248,6 +249,7 @@ echo " window.APT_OPTIONS.isfadmin = $isfadmin;\n";
echo " window.APT_OPTIONS.isstud = $isstud;\n";
echo " window.APT_OPTIONS.cansnap = $cansnap;\n";
echo " window.APT_OPTIONS.canclone = $canclone;\n";
echo " window.APT_OPTIONS.wholedisk = $wholedisk;\n";
echo " window.APT_OPTIONS.snapping = $snapping;\n";
echo " window.APT_OPTIONS.hidelinktest = false;\n";
echo " window.APT_OPTIONS.oneonly = $oneonly;\n";
......@@ -259,8 +261,8 @@ echo " window.APT_OPTIONS.admin_lockdown = $admin_lockdown;\n";
echo " window.APT_OPTIONS.lockout = $lockout;\n";
echo " window.APT_OPTIONS.isopenstack = $isopenstack;\n";
echo " window.APT_OPTIONS.paniced = $paniced;\n";
echo " window.APT_OPTIONS.project = '$project';\n";
echo " window.APT_OPTIONS.group = '$group';\n";
echo " window.APT_OPTIONS.project = '$pid';\n";
echo " window.APT_OPTIONS.group = '$gid';\n";
echo " window.APT_OPTIONS.extension_requested = " .
$instance->extension_requested() . ";\n";
echo " window.APT_OPTIONS.extension_denied = $extension_denied;\n";
......
......@@ -666,6 +666,23 @@ pre {
checking this box needlessly can have negative side effects.
</div>
</div>
<div id='snapshot-wholedisk-div' class="hidden"
style="display: inline-block; width: 80%;">
<br>
<b>Whole disk image?</b>
<br>
<center>
<input type=checkbox
id='snapshot-wholedisk' value=yes>
</center>
<div style="text-align: left;">
Check this box if you need to capture more then just the primary
partition of your disk. For example, you created a file system on
parition two, and want to include that in your new disk image.
<b><em>Do not check this box if you do not need to do this or
do not know what this means!</em></b>
</div>
</div>
</div>
</div>
<div class="fhide step2" data-step="2">
......@@ -826,11 +843,11 @@ pre {
checking this box needlessly can have negative side effects.
<br>
</div>
<div id='wholedisk_div' class='hidden'>
<div id='snapshot-wholedisk-div' class='hidden'>
<br>
<center>
Whole disk image?<br>
<input type=checkbox id=wholedisk value=yes>
<input type=checkbox id='snapshot-wholedisk' value=yes>
</center>
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
......
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