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