Commit 7b33717e authored by Leigh Stoller's avatar Leigh Stoller

Give user option to update the master password files when taking a

Snapshot. This is not yet plumbed through for Clone.
parent 279bee26
......@@ -178,8 +178,9 @@ sub DoSnapshot()
my $node_id;
my $imagename;
my $update_profile;
my $update_prepare = 0;
my $optlist = "n:i:u:";
my $optlist = "n:i:u:U";
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
......@@ -196,6 +197,9 @@ sub DoSnapshot()
usage();
}
}
if (defined($options{"U"})) {
$update_prepare = 1;
}
if ($old_status ne "ready") {
fatal("Instance must be in the ready state to take a snapshot");
......@@ -349,6 +353,9 @@ sub DoSnapshot()
"credentials" => [$slice_credential->asString(),
$speaksfor_credential->asString()],
};
if ($update_prepare) {
$args->{'update_prepare'} = 1;
}
#
# This returns pretty fast, and then the imaging takes place in
# the background at the aggregate.
......
......@@ -2432,6 +2432,7 @@ sub CreateImage($)
my $imagename = $argref->{'imagename'};
my $sliver_urn = $argref->{'sliver_urn'};
my $wholedisk = 0;
my $update_prepare = 0;
my $bsname;
require EmulabConstants;
......@@ -2447,6 +2448,8 @@ sub CreateImage($)
}
$wholedisk = 1
if (exists($argref->{'wholedisk'}) && $argref->{'wholedisk'});
$update_prepare = 1
if (exists($argref->{'update_prepare'}) && $argref->{'update_prepare'});
# Optional blockstore name.
if (exists($argref->{'bsname'})) {
$bsname = $argref->{'bsname'};
......@@ -2651,6 +2654,7 @@ dataset:
#
$opt = "";
$opt .= " -b $bsname" if (defined($bsname));
$opt .= " -U " if ($update_prepare);
if ($WITHPROVENANCE) {
$imagename .= ":" . $image->version();
}
......
......@@ -54,10 +54,11 @@ sub usage()
" -s Create descriptor but do not snapshot\n".
" -n Impotent mode\n".
" -F Create a full image even if deltas are on\n".
" -U Tell prepare to update master password files\n".
" -w Wait for image to be created\n");
exit(-1);
}
my $optlist = "densg:wFr:b:";
my $optlist = "densg:wFr:b:U";
my $debug = 0;
my $wholedisk = 0;
my $impotent = 0;
......@@ -67,6 +68,7 @@ my $waitmode = 0;
my $nodelta = 0; # To pass to create_image.
my $global = 0;
my $shared = 0;
my $update_prepare = 0;
my $bsname;
my ($base_osinfo, $base_image);
......@@ -134,6 +136,9 @@ if (defined($options{"w"})) {
if (defined($options{"F"})) {
$nodelta = 1;
}
if (defined($options{"U"})) {
$update_prepare = 1;
}
if (defined($options{"b"})) {
$bsname = $options{"b"};
......@@ -374,6 +379,9 @@ if (defined($image)) {
my $opts = "-p $pid ";
$opts .= "-w " if ($waitmode);
$opts .= "-F " if ($nodelta);
$opts .= "-U " if ($update_prepare);
print STDERR "FOO: $opts\n";
#
# Mike says do not pass versioned imagenames to create_image when
......@@ -588,6 +596,7 @@ if ($nosnapshot) {
my $opts = "-p $pid ";
$opts .= "-w " if ($waitmode);
$opts .= "-F " if ($nodelta);
$opts .= "-U " if ($update_prepare);
$output = emutil::ExecQuiet("$CREATEIMAGE $opts $imagename $node_id");
if ($?) {
print STDERR $output;
......
......@@ -107,12 +107,13 @@ sub usage()
" image instead when a delta would be more than\n".
" <pct> percent the size of a full image.\n".
"-M - do not boot info MFS, run with ssh from current OS\n".
"-U - Tell prepare to update master password files\n".
"-p <pid> - project ID of the image; defaults to system project\n".
"<imagename> - imagename to use\n".
"<node> - nodeid to create the image from\n");
exit(-1);
}
my $optlist = "p:wsNdfeDSMA:Fb:";
my $optlist = "p:wsNdfeDSMA:Fb:U";
my $waitmode = 0;
my $usessh = 0;
my $usenfs = 0;
......@@ -123,6 +124,7 @@ my $nodelta = 0;
my $nomfs = 0;
my $signature= 0;
my $deltapct = 0;
my $update_prepare = 0;
my $bsname;
my $webtask;
......@@ -281,6 +283,9 @@ if (defined($options{"M"})) {
$nomfs = 1;
$usessh = 1;
}
if (defined($options{"U"})) {
$update_prepare = 1;
}
if (defined($options{"A"})) {
if (!$WITHDELTAS) {
print STDERR "Delta image support not enabled\n";
......@@ -1089,6 +1094,24 @@ if ($isec2node) {
goto ec2done;
}
#
# Big hack; we want to tell the node to update the master password
# files. But need to do this in a backwards compatable manner, and
# in way that does not require too much new plumbing. So, just touch
# file in /var/run, the current version of prepare looks for it.
#
if ($update_prepare) {
my $SAVEUID = $UID;
$EUID = $UID = 0;
my $cmd = "$TB/bin/sshtb -n -o ConnectTimeout=10 ".
"-host $node_id touch /var/run/updatemasterpasswdfiles";
print STDERR "About to: '$cmd'\n" if ($debug);
system($cmd);
fatal("'$cmd' failed")
if ($?);
$EUID = $UID = $SAVEUID;
}
#
# Virtnodes.
# Run on vnode host.
......
......@@ -1217,7 +1217,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
//
// Request to start a snapshot. This assumes a single node of course.
//
function StartSnapshot(node_id, update_profile)
function StartSnapshot(node_id, update_profile, update_prepare)
{
if (node_id === undefined) {
node_id = "";
......@@ -1239,7 +1239,8 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
sup.CallServerMethod(ajaxurl, "status", "SnapShot",
{"uuid" : uuid,
"node_id" : node_id,
"update_profile" : update_profile});
"update_profile" : update_profile,
"update_prepare" : update_prepare});
xmlthing.done(callback);
}
......@@ -1251,6 +1252,10 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
{
// Default to update unless checkbox says otherwise.
var update_profile = 1;
var update_prepare = 0;
// 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
......@@ -1274,8 +1279,11 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
if (node_id && $('#snapshot_update_profile').is(':checked')) {
update_profile = 1;
}
if (node_id && $('#snapshot_update_prepare').is(':checked')) {
update_prepare = 1;
}
sup.HideModal('#snapshot_modal');
StartSnapshot(node_id, update_profile);
StartSnapshot(node_id, update_profile, update_prepare);
});
// Handler for hide modal to unbind the click handler.
......
......@@ -411,6 +411,7 @@ function Do_RequestExtension()
if (! ISADMIN()) {
$instance->SetExtensionReason($reason);
}
$instance->BumpExtensionCount($granted);
}
elseif ($retval > 0) {
SPITAJAX_ERROR(1, $suexec_output);
......@@ -461,6 +462,7 @@ function needAdminApproval($wanted, $granted, $reason, $message)
"From: " . $creator->email());
$instance->SetExtensionReason($reason);
$instance->BumpExtensionCount($granted);
# XXX
SPITAJAX_ERROR(2, "Your request requires admininstrator approval".
......@@ -576,6 +578,10 @@ function Do_Snapshot()
$optargs .= " -u all ";
}
}
if (isset($ajax_args["update_prepare"]) &&
$ajax_args["update_prepare"]) {
$optargs .= " -U ";
}
#
# Call out to the backend.
......
......@@ -255,7 +255,20 @@
updated. If you uncheck the box, you will need to modify the
profile source code yourself (you will receive email with the
name/url of the new image).
<br>
<br>
<br>
</div>
<div id='snapshot_update_prepare_div'>
<center>
<b>Did you add any accounts or groups to your image?</b>
<br>
<input type=checkbox
id='snapshot_update_prepare' value=yes>
</center>
Check this box if you installed any software that added new
users or groups. If you are not sure, ask us first since
checking this box needlessly can have negative side effects.
<br>
</div>
<div id='wholedisk_div' class='hidden'>
<br>
......@@ -268,6 +281,7 @@
partitions on the local disk. <b><em>Do not check this box if you
do not know what this means!</em></b>
</div>
<br>
<center>
<button style='margin-right: 20px;'
class='btn btn-primary btn-sm'
......
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