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()
print("Usage: manage_instance linktest instance [-k | level]\n");
print("Usage: manage_instance writecreds instance directory\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 checkreservation instance days\n");
print("Usage: manage_instance maxextension instance\n");
......@@ -1240,25 +1241,28 @@ sub DoExtend()
my $extensions = $instance->Brand()->ExtensionsEmailAddress();
my $granted = 0;
my $needapproval = 0;
my $inhours = 0;
my $message;
my $reason;
my $errmsg;
usage()
if (!@ARGV);
my $wanted = shift(@ARGV);
if (@ARGV == 2) {
my $arg = shift(@ARGV);
if ($arg eq "-m") {
$reason = shift(@ARGV);
}
else {
my $optlist = "m:f:h";
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
}
usage()
if (!@ARGV);
my $wanted = shift(@ARGV);
if (defined($options{"m"})) {
$reason = $options{"m"};
}
elsif (@ARGV == 1) {
my $filename = shift(@ARGV);
elsif (defined($options{"f"})) {
my $filename = $options{"f"};
if (! -e $filename) {
fatal("$filename does not exist");
}
......@@ -1271,6 +1275,9 @@ sub DoExtend()
}
close(MSG);
}
if (defined($options{"h"})) {
$inhours = 1;
}
#
# Create the webtask object; the web interface gave us an anonymous
# webtask, so we can use it before lock.
......@@ -1352,10 +1359,22 @@ sub DoExtend()
$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.
#
if (!defined($this_user)) {
elsif (!defined($this_user)) {
# Only extend for 24 hours.
$granted = 1;
......@@ -1466,8 +1485,10 @@ sub DoExtend()
# Do the extension.
#
if ($granted) {
if ($errcode = ExtendInternal($slice,
$granted * 3600 * 24, 0, \$errmsg)) {
my $seconds = $granted * 3600;
$seconds *= 24 if (!$inhours);
if ($errcode = ExtendInternal($slice, $seconds, 0, \$errmsg)) {
goto bad;
}
}
......@@ -1478,6 +1499,16 @@ sub DoExtend()
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",
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
#
......
This diff is collapsed.
......@@ -173,9 +173,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
window.location.replace("adminextend.php?uuid=" + uuid);
return;
}
ShowExtendModal(uuid, RequestExtensionCallback, isadmin,
isguest, null, window.APT_OPTIONS.freenodesurl,
window.APT_OPTIONS.extension_requested,
ShowExtendModal(uuid, RequestExtensionCallback, isstud, isguest,
window.APT_OPTIONS.physnode_count,
window.APT_OPTIONS.physnode_hours);
});
......@@ -339,10 +337,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
window.location.replace("adminextend.php?uuid=" + uuid);
return;
}
ShowExtendModal(uuid, RequestExtensionCallback, isadmin, isguest,
window.APT_OPTIONS.extend,
window.APT_OPTIONS.freenodesurl,
window.APT_OPTIONS.extension_requested,
ShowExtendModal(uuid, RequestExtensionCallback, isstud, isguest,
window.APT_OPTIONS.physnode_count,
window.APT_OPTIONS.physnode_hours);
}
......@@ -2367,8 +2362,6 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
}
require(['js/lib/text!template/linktest.md'],
function(md) {
console.info(md);
console.info(marked(md));
$('#linktest-help').html(marked(md));
});
......
......@@ -29,7 +29,7 @@ $APTHOST = "$WWWHOST";
$COOKDIEDOMAIN = "$WWWHOST";
$APTBASE = "$TBBASE/portal";
$APTMAIL = $TBMAIL_OPS;
$EXTENSIONS = $TBMAIL_OPS;
$SUPPORT = $TBMAILADDR_OPS;
$APTTITLE = "Emulab";
$FAVICON = "../favicon.ico";
$APTLOGO = "emulab-logo.svg";
......
......@@ -40,6 +40,7 @@ if ($_SERVER["SERVER_NAME"] == "www.aptlab.net") {
$WWWHOST = "www.aptlab.net";
$APTBASE = "https://www.aptlab.net";
$APTMAIL = "APT Operations <portal-ops@aptlab.net>";
$SUPPORT = "portal-ops@aptlab.net";
$APTTITLE = "APT";
$FAVICON = "aptlab.ico";
$APTLOGO = "aptlogo.png";
......@@ -70,6 +71,7 @@ elseif ($_SERVER["SERVER_NAME"] == "www.cloudlab.us") {
$WWWHOST = "www.cloudlab.us";
$APTBASE = "https://www.cloudlab.us";
$APTMAIL = "CloudLab Operations <portal-ops@cloudlab.us>";
$SUPPORT = "portal-ops@cloudlab.us";
$APTTITLE = "CloudLab";
$FAVICON = "cloudlab.ico";
$APTLOGO = "cloudlogo.png";
......@@ -101,6 +103,7 @@ elseif ($ISALTDOMAIN && $_SERVER["SERVER_NAME"] == "www.phantomnet.org") {
$WWWHOST = "www.phantomnet.org";
$APTBASE = "https://www.phantomnet.org";
$APTMAIL = "PhantomNet Operations <portal-ops@phantomnet.org>";
$SUPPORT = "portal-ops@phantomnet.org";
$APTTITLE = "PhantomNet";
$FAVICON = "phantomnet.ico";
$APTLOGO = "phantomlogo.png";
......
......@@ -86,7 +86,7 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
global $PORTAL_MANUAL, $PORTAL_MOTD_SITEVAR, $PORTAL_HELPFORUM;
global $TBMAINSITE, $APTTITLE, $FAVICON, $APTLOGO, $APTSTYLE, $ISAPT;
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;
$cleanmode = (isset($_COOKIE['cleanmode']) &&
$_COOKIE['cleanmode'] == 1 ? 1 : 0);
......@@ -134,6 +134,8 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
echo " window.HELPFORUM = " .
"'https://groups.google.com/d/forum/${PORTAL_HELPFORUM}';\n";
echo " window.EMBEDDED = $embedded;\n";
echo " window.SUPPORT = '$SUPPORT';\n";
echo " window.APTTILE = '$APTTITLE';\n";
echo "</script>\n";
if ($TBMAINSITE && !$embedded && file_exists("../google-analytics.php")) {
......
......@@ -302,6 +302,7 @@ function Do_RequestExtension()
{
global $instance, $creator, $this_user, $suexec_output;
global $ajax_args;
$inhours = 0;
$autoextend_maximum = TBGetSiteVar("aptui/autoextend_maximum");
if (StatusSetupAjax(1)) {
......@@ -348,6 +349,16 @@ function Do_RequestExtension()
$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 {
if (!isset($ajax_args["reason"]) || $ajax_args["reason"] == "") {
SPITAJAX_ERROR(1, "Missing reason");
......@@ -368,8 +379,9 @@ function Do_RequestExtension()
$webtask = WebTask::CreateAnonymous();
$retval = SUEXEC("nobody", "nobody",
"webmanage_instance -t " . $webtask->task_id() . " -- ".
" extend $uuid $wanted ".
(isset($filename) ? $filename : ""),
" extend $uuid " .
(isset($filename) ? "-f $filename " : "").
($inhours ? "-h " : "") . "$wanted",
SUEXEC_ACTION_IGNORE);
$webtask->Refresh();
if (isset($filename)) {
......
......@@ -51,7 +51,7 @@ $isfadmin = 0;
# Verify page arguments.
#
$reqargs = OptionalPageArguments("uuid", PAGEARG_STRING,
"extend", PAGEARG_INTEGER,
"maxextend", PAGEARG_INTEGER,
"oneonly", PAGEARG_BOOLEAN);
if (!isset($uuid)) {
......@@ -268,10 +268,13 @@ echo " window.APT_OPTIONS.physnode_hours = " .
sprintf("%.2f;\n", $instance->physnode_count() *
((time() - strtotime($instance->created())) / 3600));
echo " window.APT_OPTIONS.freenodesurl = '$freenodes_url';\n";
if (isset($extend) && $extend != "") {
echo " window.APT_OPTIONS.extend = $extend;\n";
if (isset($maxextend) && $maxextend != "") {
# 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 src='js/lib/d3.v3.js'></script>\n";
echo "<script src='js/lib/nv.d3.js'></script>\n";
......
......@@ -128,5 +128,50 @@
</div> <!-- /modal-content -->
</div> <!-- /modal-dialog -->
</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