Commit 170b1ddb authored by Kirk Webb's avatar Kirk Webb

Re-arrange batch system front-end to match Web UI behavior

* autoswap time and idleswap time defaults are inherited from the
  associated sitevars.

 - "general/autoswap_threshold", and "idle/threshold", respectively

* autoswap default state follows associated sitevar ("general/autoswap_mode").

* Any user-requested autoswap duration is checked against the
  "general/autoswap_ max" sitevar.

 - Admins can override.

* Any user-requested idleswap duration is checked against the "idle/threshold"
  sitevar.

 - Admins can override.

* Disabling swapping (-S option) is prohibited, except by admins.

* Removed all special-case checks for requests coming via the XMLRPC server.
parent 589ed7d4
...@@ -173,8 +173,9 @@ my $noswap_reason; ...@@ -173,8 +173,9 @@ my $noswap_reason;
my $idleswap = 1; my $idleswap = 1;
my $idleswaptime = 60 * TBGetSiteVar("idle/threshold"); my $idleswaptime = 60 * TBGetSiteVar("idle/threshold");
my $noidleswap_reason; my $noidleswap_reason;
my $autoswap = 0; my $autoswap = TBGetSiteVar("general/autoswap_mode") ? 1 : 0;
my $autoswaptime = 60 * TBGetSiteVar("general/autoswap_max"); my $autoswaptime = 60 * TBGetSiteVar("general/autoswap_threshold");
my $AUTOSWAPMAX = 60 * TBGetSiteVar("general/autoswap_max");
my $idleignore = 0; my $idleignore = 0;
my $priority = TB_EXPTPRIORITY_LOW; my $priority = TB_EXPTPRIORITY_LOW;
my $exptstate = EXPTSTATE_NEW(); my $exptstate = EXPTSTATE_NEW();
...@@ -250,6 +251,9 @@ if (!defined($gid)) { ...@@ -250,6 +251,9 @@ if (!defined($gid)) {
if (!defined($description)) { if (!defined($description)) {
$description = "Created by $user_uid"; $description = "Created by $user_uid";
} }
if (!$swappable && !TBAdmin()) {
tbdie("Only testbed admins can disable swapping!");
}
if (! $swappable && (!defined($noswap_reason) || $noswap_reason eq "")) { if (! $swappable && (!defined($noswap_reason) || $noswap_reason eq "")) {
tbdie("Must provide a reason with -S option (not swappable reason)!"); tbdie("Must provide a reason with -S option (not swappable reason)!");
} }
...@@ -1148,6 +1152,7 @@ sub ParseArgs() ...@@ -1148,6 +1152,7 @@ sub ParseArgs()
tbdie("Improper noswap reason!"); tbdie("Improper noswap reason!");
} }
$swappable = 0; $swappable = 0;
$autoswap = 0;
$noswap_reason = $options{"S"}; $noswap_reason = $options{"S"};
} }
if (defined($options{"L"})) { if (defined($options{"L"})) {
...@@ -1163,6 +1168,12 @@ sub ParseArgs() ...@@ -1163,6 +1168,12 @@ sub ParseArgs()
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR)) { TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR)) {
tbdie("Improper idleswap timeout!"); tbdie("Improper idleswap timeout!");
} }
# Don't allow caller to increase idleswap time beyond the
# sitevar-enforced limit. $idleswaptime was previously set to
# the maximum (via the sitevar).
if ($options{"l"} > $idleswaptime && !TBAdmin()) {
tbdie("Idle-swap time provided is larger than site-imposed maximum!");
}
$idleswap = 1; $idleswap = 1;
$idleswaptime = $options{"l"}; $idleswaptime = $options{"l"};
} }
...@@ -1171,6 +1182,11 @@ sub ParseArgs() ...@@ -1171,6 +1182,11 @@ sub ParseArgs()
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR)) { TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR)) {
tbdie("Improper autoswap timeout!"); tbdie("Improper autoswap timeout!");
} }
# Don't allow caller to increase autoswap time beyond the
# sitevar-enforced limit.
if ($options{"a"} > $AUTOSWAPMAX && !TBAdmin()) {
tbdie("Auto-swap time provided is larger than site-imposed maximum!");
}
$autoswap = 1; $autoswap = 1;
$autoswaptime = $options{"a"}; $autoswaptime = $options{"a"};
} }
...@@ -1242,24 +1258,6 @@ sub ParseArgs() ...@@ -1242,24 +1258,6 @@ sub ParseArgs()
} }
if (defined($options{"R"})) { if (defined($options{"R"})) {
$fromrpc = 1; $fromrpc = 1;
#
# Do not allow certain options to be turned off.
#
if (!$autoswap) {
tbdie("Not allowed to disable autoswap from XMLRPC server");
}
if ($autoswaptime > (24 * 60)) {
tbdie("Maximum autoswap timeout is 24 hours from XMLRPC server");
}
if (!$idleswap) {
tbdie("Not allowed to disable idleswap from XMLRPC server");
}
if ($idleswaptime > (4 * 60)) {
tbdie("Maximum autoswap timeout is 4 hours from XMLRPC server");
}
if (!$swappable) {
tbdie("Not allowed to disable swappable from XMLRPC server");
}
} }
} }
......
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