Commit 649cd68c authored by Kevin Atkinson's avatar Kevin Atkinson

Add "-N" option to batchexp/swapexp/endexp to suppress most email to

testbed-ops and the user.  Important email that requires testbed-ops
attention, such as on a recursive cleanup error, will still be sent.
In addition mail normally sent to testbed-logs will still be sent.

Also, add "noemail" option to xmlrpc server methods corresponding to
those commands, and "-N" option to related commands in script_wrapper.
parent 45838cbd
......@@ -31,7 +31,7 @@ use Errno qw(EDQUOT);
sub usage()
{
print(STDERR
"Usage: batchexp [-q] [-i [-w]] [-n] [-f] [-E description] [-g gid]\n".
"Usage: batchexp [-q] [-i [-w]] [-n] [-f] [-N] [-E description] [-g gid]\n".
" [-S reason] [-L reason] [-a <time>] [-l <time>]\n".
" -p <pid> -e <eid> <nsfile>\n".
"switches and arguments:\n".
......@@ -49,6 +49,7 @@ sub usage()
"-p <pid> - The project in which to create the experiment\n".
"-g <gid> - The group in which to create the experiment\n".
"-e <eid> - The experiment name (unique, alphanumeric, no blanks)\n".
"-N - Suppress most email to the user and testbed-ops\n".
"<nsfile> - NS file to parse for experiment.\n");
exit(-1);
}
......@@ -58,7 +59,7 @@ sub CheckCopyArgs();
sub CopyInArchive();
sub fatal($;$);
my $optlist = "iE:g:e:p:S:L:a:l:sfwqt:nzc:bx:y:h:jk"; # Enough options?
my $optlist = "iE:g:e:p:S:L:a:l:sfwqt:nzc:bx:y:h:jkN"; # Enough options?
my $batchmode= 1;
my $frontend = 0;
my $waitmode = 0;
......@@ -161,6 +162,7 @@ my $now = localtime();
my $committed = 0;
my $experiment;
my $copy_experiment;
my $noemail = 0;
#
# Verify user and get his DB uid and other info for later.
......@@ -658,7 +660,7 @@ if (! ($frontend || $batchmode)) {
DBQueryFatal("select pid from virt_lans ".
"where pid='$pid' and eid='$eid'");
if (!$vlans_result->numrows) {
if (!$vlans_result->numrows && !$noemail) {
SENDMAIL("$user_name <$user_email>",
"WARNING: Experiment Configuration: $pid/$eid",
"This experiment has zero network links defined.\n".
......@@ -801,12 +803,12 @@ $message .=
"have any questions or comments, please include the output below\n" .
"in your message to $TBOPS";
SENDMAIL("$user_name <$user_email>",
SENDMAIL(($noemail ? $TBLOGS : "$user_name <$user_email>"),
"New Experiment " . (($frontend == 0) ? "Started" : "Created") .
": $pid/$eid",
$message,
"$user_name <$user_email>",
"Bcc: $TBLOGS",
($noemail ? "" : "Bcc: $TBLOGS"),
($repfile, $logname, $nsfile))
if (!$zeemode);
......@@ -893,7 +895,8 @@ sub cleanup()
"",
"Cc: $TBOPS",
"",
($logname, "assign.log", "wanassign.log", $nsfile));
($logname, "assign.log", "wanassign.log", $nsfile))
unless $noemail;
}
#
......@@ -1164,6 +1167,9 @@ sub ParseArgs()
}
}
}
if (defined($options{"N"})) {
$noemail = 1;
}
}
#
......
......@@ -23,22 +23,24 @@ use strict;
sub usage()
{
print(STDERR
"Usage: endexp [-q] [-p] [-b | -w] <eid>\n".
"Usage: endexp [-q] [-p] [-b | -w] [-N] <eid>\n".
"switches and arguments:\n".
"-w - wait for non-batchmode experiment terminate\n".
"-q - be less chatty\n".
"-N - Suppress most email to the user and testbed-ops\n".
"<eid> - The experiment id\n");
exit(-1);
}
sub fatal($;$);
my $optlist = "bwqxp";
my $optlist = "bwqxpN";
my $waitmode = 0;
my $batch = 0;
my $quiet = 0;
my $purge = 0;
my $template_mode = 0;
my $noemail = 0;
#
# Exit codes are important; they tell the web page what has happened so
......@@ -128,6 +130,9 @@ if (defined($options{"q"})) {
if (defined($options{"x"})) {
$template_mode = 1;
}
if (defined($options{"N"})) {
$noemail = 1;
}
usage()
if ($waitmode && $batch);
......@@ -521,12 +526,14 @@ my $message =
"Experiment `$eid' in project `$pid' has been terminated.\n" .
"You may now reuse `$eid' as an experiment name.\n";
SENDMAIL("$user_name <$user_email>",
SENDMAIL(($noemail ? $TBLOGS : "$user_name <$user_email>"),
"Experiment $pid/$eid Terminated",
$message,
"$user_name <$user_email>",
"Cc: $expt_head_name <$expt_head_email>\n".
"Bcc: $TBLOGS", ($logname));
($noemail ? ""
: "Cc: $expt_head_name <$expt_head_email>\n".
"Bcc: $TBLOGS"),
($logname));
exit 0;
......
......@@ -18,7 +18,7 @@ use POSIX qw(isatty setsid);
sub usage()
{
print(STDERR
"Usage: swapexp [-q] [-b | -w] [-i | -a | -f] [-r] [-e]\n".
"Usage: swapexp [-q] [-b | -w] [-i | -a | -f] [-r] [-e] [-N]\n".
" <-s in | out | restart | modify | pause>\n".
" <pid> <eid> [<nsfile>]\n".
"switches and arguments:\n".
......@@ -27,12 +27,13 @@ sub usage()
"-r - reboot nodes when doing a modify experiment\n".
"-e - restart event scheduler when doing a modify experiment\n".
"-s <op> - Operation to perform; one of those listed above\n".
"-N - Suppress most email to the user and testbed-ops\n".
"<pid> - The project the experiment belongs to\n".
"<eid> - The experiment name (id)\n".
"<nsfile> - Optional NS file to parse for experiment modify\n");
exit(-1);
}
my $optlist = "biafres:wqxg";
my $optlist = "biafres:wqxgN";
#
# Exit codes are important; they tell the web page what has happened so
......@@ -110,6 +111,7 @@ my $modifyHosed = 0;
my $modifySwapped = 0;
my $robotexp = 0;
my $template_node = 0;
my $noemail = 0;
my $inout;
my $logfile;
......@@ -184,6 +186,9 @@ if (defined($options{"q"})) {
if (defined($options{"x"})) {
$template_mode = 1;
}
if (defined($options{"N"})) {
$noemail = 1;
}
if (defined($options{"s"})) {
$inout = $options{"s"};
......@@ -1310,12 +1315,13 @@ $message .=
"Appended below is the output. If you have any questions or comments,\n" .
"please include the output in your message to $TBOPS\n";
SENDMAIL("$user_name <$user_email>",
SENDMAIL(($noemail ? $TBLOGS : "$user_name <$user_email>") ,
"Experiment $pid/$eid \u$action",
$message,
($idleswap ? $TBOPS : "$user_name <$user_email>"),
"Cc: $expt_head_name <$expt_head_email>\n".
"Bcc: $TBLOGS",
($noemail ? ""
: "Cc: $expt_head_name <$expt_head_email>\n".
"Bcc: $TBLOGS"),
(($inout eq "restart") ? ($logname) :
(($repfile, $logname), (defined($nsfile) ? ($nsfile) : ()))));
......@@ -1458,7 +1464,8 @@ sub cleanup()
"Cc: $expt_head_name <$expt_head_email> $rcops",
"Cc: $TBOPS $rcops",
$modifyError,
(($logname), (defined($modnsfile) ? ($modnsfile) : ())));
(($logname), (defined($modnsfile) ? ($modnsfile) : ())))
unless $noemail;
}
if ($modifyHosed) {
......
......@@ -1212,8 +1212,12 @@ class experiment:
return EmulabResponse(RESPONSE_SERVERERROR,
output="Server Error")
pass
elif opt == "noemail":
if xbool(val):
argstr += " -N "
pass
pass
pass
if nsfilename:
argstr += " " + nsfilename
pass
......@@ -1272,6 +1276,11 @@ class experiment:
argstr += " -w "
pass
pass
elif opt == "noemail":
if xbool(val):
argstr += " -N "
pass
pass
pass
argstr += " -s " + escapeshellarg(argdict["direction"])
......@@ -1350,6 +1359,11 @@ class experiment:
return EmulabResponse(RESPONSE_SERVERERROR,
output="Server Error")
pass
elif opt == "noemail":
if xbool(val):
argstr += " -N "
pass
pass
pass
argstr += " -s modify"
......@@ -1403,6 +1417,11 @@ class experiment:
argstr += " -w "
pass
pass
elif opt == "noemail":
if xbool(val):
argstr += " -N "
pass
pass
pass
argstr += " " + escapeshellarg(argdict["proj"])
......
......@@ -1205,7 +1205,7 @@ class startexp:
def apply(self):
try:
opts, req_args = getopt.getopt(self.argv,
"iwfqS:L:a:l:E:g:p:e:",
"iwfqS:L:a:l:E:g:p:e:N",
[ "help" ]);
pass
except getopt.error, e:
......@@ -1253,6 +1253,9 @@ class startexp:
elif opt == "-w":
params["wait"] = "yes"
pass
elif opt == "-N":
params["noemail"] = "yes"
pass
pass
# Do this after so --help is seen.
......@@ -1272,7 +1275,7 @@ class startexp:
return rval;
def usage(self):
print "startexp [-q] [-i [-w]] [-f] [-E description] [-g gid]";
print "startexp [-q] [-i [-w]] [-f] [-N] [-E description] [-g gid]";
print " [-S reason] [-L reason] [-a <time>] [-l <time>]";
print " -p <pid> -e <eid> <nsfile>";
print "where:";
......@@ -1288,6 +1291,7 @@ class startexp:
print " -g - The subgroup in which to create the experiment";
print " -p - The project in which to create the experiment";
print " -e - The experiment name (unique, alphanumeric, no blanks)";
print " -N - Suppress most email to the user and testbed-ops";
print "nsfile - NS file to parse for experiment";
wrapperoptions();
return
......@@ -1303,7 +1307,7 @@ class swapexp:
def apply(self):
try:
opts, req_args = getopt.getopt(self.argv, "we:s:", [ "help" ]);
opts, req_args = getopt.getopt(self.argv, "wNe:s:", [ "help" ]);
pass
except getopt.error, e:
print e.args[0]
......@@ -1318,6 +1322,9 @@ class swapexp:
elif opt == "-w":
params["wait"] = "yes"
pass
elif opt == "-N":
params["noemail"] = "yes"
pass
elif opt == "-s":
params["direction"] = val
pass
......@@ -1358,6 +1365,7 @@ class swapexp:
print "where:";
print " -w - Wait for experiment to finish swapping";
print " -e - Project and Experiment ID";
print " -N - Suppress most email to the user and testbed-ops";
print " in - Swap experiment in (must currently be swapped out)";
print " out - Swap experiment out (must currently be swapped in)";
print ""
......@@ -1378,7 +1386,7 @@ class modexp:
def apply(self):
try:
opts, req_args = getopt.getopt(self.argv, "rswe:", [ "help" ]);
opts, req_args = getopt.getopt(self.argv, "rswNe:", [ "help" ]);
pass
except getopt.error, e:
print e.args[0]
......@@ -1399,6 +1407,9 @@ class modexp:
elif opt == "-s":
params["restart_eventsys"] = "yes"
pass
elif opt == "-N":
params["noemail"] = "yes"
pass
elif opt == "-e":
pid,eid = string.split(val, ",")
params["proj"] = pid;
......@@ -1438,13 +1449,14 @@ class modexp:
return rval;
def usage(self):
print "modexp [-r] [-s] [-w] -e pid,eid nsfile";
print "modexp [-r] [-s] [-w] pid eid nsfile";
print "modexp [-r] [-s] [-w] [-N] -e pid,eid nsfile";
print "modexp [-r] [-s] [-w] [-N] pid eid nsfile";
print "where:";
print " -w - Wait for experiment to finish swapping";
print " -e - Project and Experiment ID";
print " -r - Reboot nodes (when experiment is active)";
print " -s - Restart event scheduler (when experiment is active)";
print " -N - Suppress most email to the user and testbed-ops";
print ""
print "By default, modexp runs in the background, sending you email ";
print "when the transition has completed. Use the -w option to wait";
......@@ -1469,7 +1481,7 @@ class endexp:
def apply(self):
try:
opts, req_args = getopt.getopt(self.argv, "we:", [ "help" ]);
opts, req_args = getopt.getopt(self.argv, "wNe:", [ "help" ]);
pass
except getopt.error, e:
print e.args[0]
......@@ -1484,6 +1496,9 @@ class endexp:
elif opt == "-w":
params["wait"] = "yes"
pass
elif opt == "-N":
params["noemail"] = "yes"
pass
elif opt == "-e":
pid,eid = string.split(val, ",")
params["proj"] = pid;
......@@ -1511,11 +1526,12 @@ class endexp:
return rval;
def usage(self):
print "endexp [-w] -e pid,eid";
print "endexp [-w] pid eid";
print "endexp [-w] [-N] -e pid,eid";
print "endexp [-w] [-N] pid eid";
print "where:";
print " -w - Wait for experiment to finish terminating";
print " -e - Project and Experiment ID";
print " -N - Suppress most email to the user and testbed-ops";
print ""
print "By default, endexp runs in the background, sending you email ";
print "when the transition has completed. Use the -w option to wait";
......
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