Commit 56af70cf authored by Leigh Stoller's avatar Leigh Stoller

Add some minor logging changes for ProtoGeni experiments.

parent 4bef47d0
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -833,7 +833,7 @@ SENDMAIL(($noemail ? $TBLOGS : "$user_name <$user_email>"),
"$user_name <$user_email>",
($noemail ? "" : "Bcc: $TBLOGS"),
($repfile, $logname, $nsfile))
if (!$zeemode);
if (! ($zeemode || $genimode));
# Done!
exit(0);
......
......@@ -34,11 +34,14 @@ sub usage()
sub fatal($;$);
my $optlist = "bwqxpN";
my $optlist = "bwqxpNfog";
my $waitmode = 0;
my $batch = 0;
my $quiet = 0;
my $purge = 0;
my $force = 0;
my $genimode = 0;
my $lockforce= 0;
my $template_mode = 0;
my $noemail = 0;
......@@ -119,9 +122,18 @@ if (@ARGV != 1) {
if (defined($options{"b"})) {
$batch = 1;
}
if (defined($options{"g"})) {
$genimode = 1;
}
if (defined($options{"p"})) {
$purge = 1;
}
if (defined($options{"f"})) {
$force = 1;
}
if (defined($options{"o"})) {
$lockforce = 1;
}
if (defined($options{"w"})) {
$waitmode = 1;
}
......@@ -315,7 +327,7 @@ else {
ExitWithStatus(1,
"Experiment $pid/$eid is locked down; cannot swap!\n")
if ($lockdown);
if ($lockdown && !$lockforce);
#
# Must be unlocked if called by the user.
......@@ -394,7 +406,7 @@ my $expt_head_email = $swapper->email();
#
# If not in batch mode, go into the background. Parent exits.
#
if (!$batch && !$template_mode) {
if (! ($batch || $template_mode || $genimode)) {
# Cleanup
$experiment->CleanLogFiles() == 0
or fatal("Could not clean up logfiles!");
......@@ -527,6 +539,8 @@ if ($estate ne EXPTSTATE_TERMINATED) {
#
# Try to copy off the files for testbed information gathering.
# Note that the logfile will not contain anything printed after
# this point.
#
$experiment->SaveLogFiles();
......@@ -556,35 +570,34 @@ $experiment->ClearReservedVlanTags() == 0 or
fatal("Could not delete reserved vlan tags for $experiment");
#
# Cleanup DB state and remove directory. Purge flag is optional and generally
# used by admins for cleaning up bad DB state caused by script errors.
# Send email now, since once we call Delete() the log file is going
# to be unlinked.
#
$experiment->Delete($purge);
if (! ($batch || $template_mode || $genimode)) {
my $message =
"Experiment `$eid' in project `$pid' has been terminated.\n" .
"You may now reuse `$eid' as an experiment name.\n";
#
# In batch mode, exit now.
#
if ($batch || $template_mode) {
exit(0);
SENDMAIL(($noemail ? $TBLOGS : "$user_name <$user_email>"),
"Experiment $pid/$eid Terminated",
$message,
"$user_name <$user_email>",
($noemail ? ""
: "Cc: $expt_head_name <$expt_head_email>\n".
"Bcc: $TBLOGS"),
($logname));
}
#
# Send email notification to user.
# Cleanup DB state and remove directory. Purge flag is optional and generally
# used by admins for cleaning up bad DB state caused by script errors.
#
my $message =
"Experiment `$eid' in project `$pid' has been terminated.\n" .
"You may now reuse `$eid' as an experiment name.\n";
SENDMAIL(($noemail ? $TBLOGS : "$user_name <$user_email>"),
"Experiment $pid/$eid Terminated",
$message,
"$user_name <$user_email>",
($noemail ? ""
: "Cc: $expt_head_name <$expt_head_email>\n".
"Bcc: $TBLOGS"),
($logname));
$experiment->Delete($purge);
exit 0;
# In batch mode, exit now.
exit(0)
if ($batch || $template_mode || $genimode);
exit(0);
sub fatal($;$)
{
......@@ -602,7 +615,7 @@ sub fatal($;$)
#
# In batch mode, exit without sending the email.
#
if ($batch) {
if ($batch || $genimode) {
exit(-1);
}
......
......@@ -34,7 +34,7 @@ sub usage()
"<nsfile> - Optional NS file to parse for experiment modify\n");
exit(-1);
}
my $optlist = "biafres:wqxgNXn";
my $optlist = "biafres:wqxgNXno";
#
# Exit codes are important; they tell the web page what has happened so
......@@ -99,6 +99,7 @@ my $batch = 0;
my $idleswap = 0;
my $autoswap = 0;
my $force = 0;
my $lockforce= 0;
my $reboot = 0;
my $waitmode = 0;
my $quiet = 0;
......@@ -169,6 +170,9 @@ if (defined($options{"a"})) {
if (defined($options{"f"})) {
$force = 1;
}
if (defined($options{"o"})) {
$lockforce = 1;
}
if (defined($options{"g"})) {
$genimode = 1;
$noswapout = 1;
......@@ -643,7 +647,7 @@ else {
ExitWithStatus(1,
"Experiment $pid/$eid is locked down; cannot swap!\n")
if ($lockdown);
if ($lockdown && !$lockforce);
#
# Check the state for the various operations.
......@@ -1492,6 +1496,9 @@ sub cleanup()
# Unlock and reset state to its terminal value.
$experiment->Unlock();
return
if ($genimode);
#
# Clear the cancel flag now that the operation is complete. Must be done
# after we change the experiment state (above).
......
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