Commit 4cead7b8 authored by Leigh B Stoller's avatar Leigh B Stoller

First cut at adding reservations to the user extend modal as per

discussion in issue #134. Only studly user see this for now, so
that we can play with phony reservations.
parent e3dbada7
...@@ -50,7 +50,8 @@ sub usage() ...@@ -50,7 +50,8 @@ sub usage()
print("Usage: manage_instance linktest instance [-k | level]\n"); print("Usage: manage_instance linktest instance [-k | level]\n");
print("Usage: manage_instance writecreds instance directory\n"); print("Usage: manage_instance writecreds instance directory\n");
print("Usage: manage_instance updatekeys instance [uid] \n"); print("Usage: manage_instance updatekeys instance [uid] \n");
print("Usage: manage_instance extend instance [-m message] days [filename]\n"); print("Usage: manage_instance extend instance ".
"[-M] [-m message | -f filename] days\n");
print("Usage: manage_instance denyextension instance [-m message] [filename]\n"); print("Usage: manage_instance denyextension instance [-m message] [filename]\n");
print("Usage: manage_instance checkreservation instance days\n"); print("Usage: manage_instance checkreservation instance days\n");
print("Usage: manage_instance maxextension instance\n"); print("Usage: manage_instance maxextension instance\n");
...@@ -1240,25 +1241,28 @@ sub DoExtend() ...@@ -1240,25 +1241,28 @@ sub DoExtend()
my $extensions = $instance->Brand()->ExtensionsEmailAddress(); my $extensions = $instance->Brand()->ExtensionsEmailAddress();
my $granted = 0; my $granted = 0;
my $needapproval = 0; my $needapproval = 0;
my $inhours = 0;
my $message; my $message;
my $reason; my $reason;
my $errmsg; my $errmsg;
usage()
if (!@ARGV);
my $optlist = "m:f:h";
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
}
usage() usage()
if (!@ARGV); if (!@ARGV);
my $wanted = shift(@ARGV); my $wanted = shift(@ARGV);
if (@ARGV == 2) { if (defined($options{"m"})) {
my $arg = shift(@ARGV); $reason = $options{"m"};
if ($arg eq "-m") {
$reason = shift(@ARGV);
}
else {
usage();
}
} }
elsif (@ARGV == 1) { elsif (defined($options{"f"})) {
my $filename = shift(@ARGV); my $filename = $options{"f"};
if (! -e $filename) { if (! -e $filename) {
fatal("$filename does not exist"); fatal("$filename does not exist");
} }
...@@ -1271,6 +1275,9 @@ sub DoExtend() ...@@ -1271,6 +1275,9 @@ sub DoExtend()
} }
close(MSG); close(MSG);
} }
if (defined($options{"h"})) {
$inhours = 1;
}
# #
# Create the webtask object; the web interface gave us an anonymous # Create the webtask object; the web interface gave us an anonymous
# webtask, so we can use it before lock. # webtask, so we can use it before lock.
...@@ -1352,10 +1359,22 @@ sub DoExtend() ...@@ -1352,10 +1359,22 @@ sub DoExtend()
$autoextend_maximum *= 2; $autoextend_maximum *= 2;
} }
#
# If extension is in hours, always grant if < 24 hours.
#
if ($inhours) {
if ($wanted >= 24) {
$errmsg = "If you want more then 24 hours, use days instead.";
goto bad;
}
$message = "Short extension granted for $wanted hours.";
$reason = $message;
$granted = $wanted;
}
# #
# Guest users are treated differently. # Guest users are treated differently.
# #
if (!defined($this_user)) { elsif (!defined($this_user)) {
# Only extend for 24 hours. # Only extend for 24 hours.
$granted = 1; $granted = 1;
...@@ -1466,8 +1485,10 @@ sub DoExtend() ...@@ -1466,8 +1485,10 @@ sub DoExtend()
# Do the extension. # Do the extension.
# #
if ($granted) { if ($granted) {
if ($errcode = ExtendInternal($slice, my $seconds = $granted * 3600;
$granted * 3600 * 24, 0, \$errmsg)) { $seconds *= 24 if (!$inhours);
if ($errcode = ExtendInternal($slice, $seconds, 0, \$errmsg)) {
goto bad; goto bad;
} }
} }
...@@ -1478,6 +1499,16 @@ sub DoExtend() ...@@ -1478,6 +1499,16 @@ sub DoExtend()
my $now = POSIX::strftime("20%y-%m-%d %H:%M:%S %Z", localtime()); my $now = POSIX::strftime("20%y-%m-%d %H:%M:%S %Z", localtime());
my $before = POSIX::strftime("20%y-%m-%d %H:%M:%S %Z", my $before = POSIX::strftime("20%y-%m-%d %H:%M:%S %Z",
localtime($expires_time)); localtime($expires_time));
#
# XXX If in hours, change to 1. Need to come back and fix this.
# Make these fields in the database hours or seconds.
#
if ($inhours) {
$wanted = 1;
$granted = 1;
}
# #
# New extension mechanism # New extension mechanism
# #
......
This diff is collapsed.
...@@ -173,9 +173,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal, ...@@ -173,9 +173,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
window.location.replace("adminextend.php?uuid=" + uuid); window.location.replace("adminextend.php?uuid=" + uuid);
return; return;
} }
ShowExtendModal(uuid, RequestExtensionCallback, isadmin, ShowExtendModal(uuid, RequestExtensionCallback, isstud, isguest,
isguest, null, window.APT_OPTIONS.freenodesurl,
window.APT_OPTIONS.extension_requested,
window.APT_OPTIONS.physnode_count, window.APT_OPTIONS.physnode_count,
window.APT_OPTIONS.physnode_hours); window.APT_OPTIONS.physnode_hours);
}); });
...@@ -339,10 +337,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal, ...@@ -339,10 +337,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
window.location.replace("adminextend.php?uuid=" + uuid); window.location.replace("adminextend.php?uuid=" + uuid);
return; return;
} }
ShowExtendModal(uuid, RequestExtensionCallback, isadmin, isguest, ShowExtendModal(uuid, RequestExtensionCallback, isstud, isguest,
window.APT_OPTIONS.extend,
window.APT_OPTIONS.freenodesurl,
window.APT_OPTIONS.extension_requested,
window.APT_OPTIONS.physnode_count, window.APT_OPTIONS.physnode_count,
window.APT_OPTIONS.physnode_hours); window.APT_OPTIONS.physnode_hours);
} }
...@@ -2367,8 +2362,6 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal, ...@@ -2367,8 +2362,6 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
} }
require(['js/lib/text!template/linktest.md'], require(['js/lib/text!template/linktest.md'],
function(md) { function(md) {
console.info(md);
console.info(marked(md));
$('#linktest-help').html(marked(md)); $('#linktest-help').html(marked(md));
}); });
......
...@@ -29,7 +29,7 @@ $APTHOST = "$WWWHOST"; ...@@ -29,7 +29,7 @@ $APTHOST = "$WWWHOST";
$COOKDIEDOMAIN = "$WWWHOST"; $COOKDIEDOMAIN = "$WWWHOST";
$APTBASE = "$TBBASE/portal"; $APTBASE = "$TBBASE/portal";
$APTMAIL = $TBMAIL_OPS; $APTMAIL = $TBMAIL_OPS;
$EXTENSIONS = $TBMAIL_OPS; $SUPPORT = $TBMAILADDR_OPS;
$APTTITLE = "Emulab"; $APTTITLE = "Emulab";
$FAVICON = "../favicon.ico"; $FAVICON = "../favicon.ico";
$APTLOGO = "emulab-logo.svg"; $APTLOGO = "emulab-logo.svg";
......
...@@ -40,6 +40,7 @@ if ($_SERVER["SERVER_NAME"] == "www.aptlab.net") { ...@@ -40,6 +40,7 @@ if ($_SERVER["SERVER_NAME"] == "www.aptlab.net") {
$WWWHOST = "www.aptlab.net"; $WWWHOST = "www.aptlab.net";
$APTBASE = "https://www.aptlab.net"; $APTBASE = "https://www.aptlab.net";
$APTMAIL = "APT Operations <portal-ops@aptlab.net>"; $APTMAIL = "APT Operations <portal-ops@aptlab.net>";
$SUPPORT = "portal-ops@aptlab.net";
$APTTITLE = "APT"; $APTTITLE = "APT";
$FAVICON = "aptlab.ico"; $FAVICON = "aptlab.ico";
$APTLOGO = "aptlogo.png"; $APTLOGO = "aptlogo.png";
...@@ -70,6 +71,7 @@ elseif ($_SERVER["SERVER_NAME"] == "www.cloudlab.us") { ...@@ -70,6 +71,7 @@ elseif ($_SERVER["SERVER_NAME"] == "www.cloudlab.us") {
$WWWHOST = "www.cloudlab.us"; $WWWHOST = "www.cloudlab.us";
$APTBASE = "https://www.cloudlab.us"; $APTBASE = "https://www.cloudlab.us";
$APTMAIL = "CloudLab Operations <portal-ops@cloudlab.us>"; $APTMAIL = "CloudLab Operations <portal-ops@cloudlab.us>";
$SUPPORT = "portal-ops@cloudlab.us";
$APTTITLE = "CloudLab"; $APTTITLE = "CloudLab";
$FAVICON = "cloudlab.ico"; $FAVICON = "cloudlab.ico";
$APTLOGO = "cloudlogo.png"; $APTLOGO = "cloudlogo.png";
...@@ -101,6 +103,7 @@ elseif ($ISALTDOMAIN && $_SERVER["SERVER_NAME"] == "www.phantomnet.org") { ...@@ -101,6 +103,7 @@ elseif ($ISALTDOMAIN && $_SERVER["SERVER_NAME"] == "www.phantomnet.org") {
$WWWHOST = "www.phantomnet.org"; $WWWHOST = "www.phantomnet.org";
$APTBASE = "https://www.phantomnet.org"; $APTBASE = "https://www.phantomnet.org";
$APTMAIL = "PhantomNet Operations <portal-ops@phantomnet.org>"; $APTMAIL = "PhantomNet Operations <portal-ops@phantomnet.org>";
$SUPPORT = "portal-ops@phantomnet.org";
$APTTITLE = "PhantomNet"; $APTTITLE = "PhantomNet";
$FAVICON = "phantomnet.ico"; $FAVICON = "phantomnet.ico";
$APTLOGO = "phantomlogo.png"; $APTLOGO = "phantomlogo.png";
......
...@@ -86,7 +86,7 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL, ...@@ -86,7 +86,7 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
global $PORTAL_MANUAL, $PORTAL_MOTD_SITEVAR, $PORTAL_HELPFORUM; global $PORTAL_MANUAL, $PORTAL_MOTD_SITEVAR, $PORTAL_HELPFORUM;
global $TBMAINSITE, $APTTITLE, $FAVICON, $APTLOGO, $APTSTYLE, $ISAPT; global $TBMAINSITE, $APTTITLE, $FAVICON, $APTLOGO, $APTSTYLE, $ISAPT;
global $GOOGLEUA, $ISCLOUD, $ISPNET, $ISEMULAB, $TBBASE, $ISEMULAB; global $GOOGLEUA, $ISCLOUD, $ISPNET, $ISEMULAB, $TBBASE, $ISEMULAB;
global $login_user, $login_status; global $login_user, $login_status, $SUPPORT;
global $disable_accounts, $page_title, $drewheader, $embedded; global $disable_accounts, $page_title, $drewheader, $embedded;
$cleanmode = (isset($_COOKIE['cleanmode']) && $cleanmode = (isset($_COOKIE['cleanmode']) &&
$_COOKIE['cleanmode'] == 1 ? 1 : 0); $_COOKIE['cleanmode'] == 1 ? 1 : 0);
...@@ -134,6 +134,8 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL, ...@@ -134,6 +134,8 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
echo " window.HELPFORUM = " . echo " window.HELPFORUM = " .
"'https://groups.google.com/d/forum/${PORTAL_HELPFORUM}';\n"; "'https://groups.google.com/d/forum/${PORTAL_HELPFORUM}';\n";
echo " window.EMBEDDED = $embedded;\n"; echo " window.EMBEDDED = $embedded;\n";
echo " window.SUPPORT = '$SUPPORT';\n";
echo " window.APTTILE = '$APTTITLE';\n";
echo "</script>\n"; echo "</script>\n";
if ($TBMAINSITE && !$embedded && file_exists("../google-analytics.php")) { if ($TBMAINSITE && !$embedded && file_exists("../google-analytics.php")) {
......
...@@ -302,6 +302,7 @@ function Do_RequestExtension() ...@@ -302,6 +302,7 @@ function Do_RequestExtension()
{ {
global $instance, $creator, $this_user, $suexec_output; global $instance, $creator, $this_user, $suexec_output;
global $ajax_args; global $ajax_args;
$inhours = 0;
$autoextend_maximum = TBGetSiteVar("aptui/autoextend_maximum"); $autoextend_maximum = TBGetSiteVar("aptui/autoextend_maximum");
if (StatusSetupAjax(1)) { if (StatusSetupAjax(1)) {
...@@ -348,6 +349,16 @@ function Do_RequestExtension() ...@@ -348,6 +349,16 @@ function Do_RequestExtension()
$reason = $ajax_args["reason"]; $reason = $ajax_args["reason"];
} }
} }
elseif (isset($ajax_args["inhours"])) {
#
# For short extensions, no reason necessary.
#
$inhours = 1;
if ($wanted >= 24) {
SPITAJAX_ERROR(1, "Too big for hourly update");
goto bad;
}
}
else { else {
if (!isset($ajax_args["reason"]) || $ajax_args["reason"] == "") { if (!isset($ajax_args["reason"]) || $ajax_args["reason"] == "") {
SPITAJAX_ERROR(1, "Missing reason"); SPITAJAX_ERROR(1, "Missing reason");
...@@ -368,8 +379,9 @@ function Do_RequestExtension() ...@@ -368,8 +379,9 @@ function Do_RequestExtension()
$webtask = WebTask::CreateAnonymous(); $webtask = WebTask::CreateAnonymous();
$retval = SUEXEC("nobody", "nobody", $retval = SUEXEC("nobody", "nobody",
"webmanage_instance -t " . $webtask->task_id() . " -- ". "webmanage_instance -t " . $webtask->task_id() . " -- ".
" extend $uuid $wanted ". " extend $uuid " .
(isset($filename) ? $filename : ""), (isset($filename) ? "-f $filename " : "").
($inhours ? "-h " : "") . "$wanted",
SUEXEC_ACTION_IGNORE); SUEXEC_ACTION_IGNORE);
$webtask->Refresh(); $webtask->Refresh();
if (isset($filename)) { if (isset($filename)) {
......
...@@ -50,9 +50,9 @@ $isfadmin = 0; ...@@ -50,9 +50,9 @@ $isfadmin = 0;
# #
# Verify page arguments. # Verify page arguments.
# #
$reqargs = OptionalPageArguments("uuid", PAGEARG_STRING, $reqargs = OptionalPageArguments("uuid", PAGEARG_STRING,
"extend", PAGEARG_INTEGER, "maxextend", PAGEARG_INTEGER,
"oneonly", PAGEARG_BOOLEAN); "oneonly", PAGEARG_BOOLEAN);
if (!isset($uuid)) { if (!isset($uuid)) {
SPITHEADER(1); SPITHEADER(1);
...@@ -268,10 +268,13 @@ echo " window.APT_OPTIONS.physnode_hours = " . ...@@ -268,10 +268,13 @@ echo " window.APT_OPTIONS.physnode_hours = " .
sprintf("%.2f;\n", $instance->physnode_count() * sprintf("%.2f;\n", $instance->physnode_count() *
((time() - strtotime($instance->created())) / 3600)); ((time() - strtotime($instance->created())) / 3600));
echo " window.APT_OPTIONS.freenodesurl = '$freenodes_url';\n"; echo " window.APT_OPTIONS.freenodesurl = '$freenodes_url';\n";
if (isset($extend) && $extend != "") { if (isset($maxextend) && $maxextend != "") {
echo " window.APT_OPTIONS.extend = $extend;\n"; # Assumed to be hours.
echo " window.APT_OPTIONS.MAXEXTEND = $maxextend;\n";
}
else {
echo " window.APT_OPTIONS.MAXEXTEND = null;\n";
} }
echo "var FOO = null;\n";
echo "</script>\n"; echo "</script>\n";
echo "<script src='js/lib/d3.v3.js'></script>\n"; echo "<script src='js/lib/d3.v3.js'></script>\n";
echo "<script src='js/lib/nv.d3.js'></script>\n"; echo "<script src='js/lib/nv.d3.js'></script>\n";
......
...@@ -128,5 +128,50 @@ ...@@ -128,5 +128,50 @@
</div> <!-- /modal-content --> </div> <!-- /modal-content -->
</div> <!-- /modal-dialog --> </div> <!-- /modal-dialog -->
</div> <!-- /modal --> </div> <!-- /modal -->
<div id='restricted_extend_modal' class='modal fade'>
<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><h3>Warning</h3></center>
<div>
Your experiment cannot be extended beyond <span id="hours"></span>
hour(s) from now because of a pre-scheduled resource
reservation. Clicking confirm below will result in your
experiment be extended for as long as possible, but be sure to
save all your work before your experiment is terminated. If
this is going to cause undue hardship, please contact
<a class="supportmail"></a> to plead your case.
</div>
<div style="margin-top: 10px">
<button class='btn btn-primary btn-sm align-center'
type='submit' id='confirm-max'>Confirm</button>
</div>
</div>
</div>
</div>
</div>
<div id='no_extend_modal' class='modal fade'>
<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><h3>Warning</h3></center>
<div>
Your experiment cannot be extended because of a
pre-scheduled resource reservation. Please be sure to save
all your work before your experiment is terminated. If this
is going to cause undue hardship, please contact
<a class="supportmail"></a> to plead your case.
</div>
<div style="margin-top: 10px">
<button class='btn btn-primary btn-sm align-center'
data-dismiss='modal'
type='button'>Dismiss</button>
</div>
</div>
</div>
</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