Commit 21df9fed authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add "frontend" node (-f) option, which is usable with "immediate" mode

(not batchmode!). Basically, do a full experiment setup minus swapin.
This gives you all the DB state so that it can be viewed in the web
page and terminated/swapped/visualized.
parent 7fa79359
...@@ -7,10 +7,10 @@ use Getopt::Std; ...@@ -7,10 +7,10 @@ use Getopt::Std;
# #
sub usage() sub usage()
{ {
die("Usage: batchexp [-i] [-x expires] [-E description] [-g gid] ". die("Usage: batchexp [-i [-f]] [-x expires] [-E description] [-g gid] ".
"[-s] [-n low|high] -p <pid> -e <eid> <nsfile>\n"); "[-s] [-n low|high] -p <pid> -e <eid> <nsfile>\n");
} }
my $optlist = "iE:d:g:x:e:p:sn:"; my $optlist = "iE:d:g:x:e:p:sn:f";
# #
# Configure variables # Configure variables
...@@ -31,6 +31,7 @@ my $mkexpdir = "$TB/libexec/mkexpdir"; ...@@ -31,6 +31,7 @@ my $mkexpdir = "$TB/libexec/mkexpdir";
my $startexp = "$TB/bin/startexp"; my $startexp = "$TB/bin/startexp";
my $tbdata = "tbdata"; my $tbdata = "tbdata";
my $immediate= 0; my $immediate= 0;
my $frontend = 0;
my $dirname; my $dirname;
my $dbuid; my $dbuid;
my @row; my @row;
...@@ -205,11 +206,14 @@ if ($nsfile_string) { ...@@ -205,11 +206,14 @@ if ($nsfile_string) {
# so that the batch daemon will see it and act. # so that the batch daemon will see it and act.
# #
if ($immediate) { if ($immediate) {
if (system("$startexp -g $gid $pid $eid $nsfile")) { my $farg = ($frontend ? "-f" : "");
if (system("$startexp $farg -g $gid $pid $eid $nsfile")) {
# #
# Save a copy of the failed experiment directory for debugging. # Save a copy of the failed experiment directory for debugging.
# #
system("/bin/rm", "-rf", "${dirname}-TBfailed"); system("/bin/rm", "-rf", "${dirname}-TBfailed");
system("/bin/mv", "-f", "${dirname}", "${dirname}-TBfailed"); system("/bin/mv", "-f", "${dirname}", "${dirname}-TBfailed");
fatal("Failed to start experiment $pid/$eid!"); fatal("Failed to start experiment $pid/$eid!");
...@@ -270,6 +274,12 @@ sub ParseArgs() ...@@ -270,6 +274,12 @@ sub ParseArgs()
if (defined($options{"i"})) { if (defined($options{"i"})) {
$immediate = 1; $immediate = 1;
} }
if (defined($options{"f"})) {
$frontend = 1;
}
if ($frontend && !$immediate) {
usage();
}
if (defined($options{"p"})) { if (defined($options{"p"})) {
$pid = $options{"p"}; $pid = $options{"p"};
......
...@@ -15,15 +15,13 @@ use Getopt::Std; ...@@ -15,15 +15,13 @@ use Getopt::Std;
# save off the file in the expinfo directory. The caller (batch daemon) # save off the file in the expinfo directory. The caller (batch daemon)
# opens the file and just passes the name in. I do not like this! # opens the file and just passes the name in. I do not like this!
# #
# usage: startexp [-l] [-b logfile] [-g gid] <pid> <eid> <nsfile>
#
sub usage() sub usage()
{ {
print STDOUT print STDOUT
"Usage: startexp [-l] [-b logfile] [-g gid] <pid> <eid> <nsfile>\n"; "Usage: startexp [-b logfile | -f] [-g gid] <pid> <eid> <nsfile>\n";
exit(-1); exit(-1);
} }
my $optlist = "b:g:"; my $optlist = "b:g:f";
# #
# Configure variables # Configure variables
...@@ -45,6 +43,7 @@ use libtestbed; ...@@ -45,6 +43,7 @@ use libtestbed;
my $tbdir = "$TB/bin/"; my $tbdir = "$TB/bin/";
my $tbdata = "tbdata"; my $tbdata = "tbdata";
my $batch = 0; my $batch = 0;
my $frontend = 0;
my $errorstat= -1; my $errorstat= -1;
my $logname; my $logname;
...@@ -90,6 +89,12 @@ if (defined($options{"b"})) { ...@@ -90,6 +89,12 @@ if (defined($options{"b"})) {
$batch = 1; $batch = 1;
$logname = $options{"b"}; $logname = $options{"b"};
} }
if (defined($options{"f"})) {
$frontend = 1;
}
if ($batch && $frontend) {
usage();
}
if (defined($options{"g"})) { if (defined($options{"g"})) {
$gid = $options{"g"}; $gid = $options{"g"};
...@@ -234,36 +239,39 @@ if (system("$tbdir/tbprerun $pid $eid $nsfile") != 0) { ...@@ -234,36 +239,39 @@ if (system("$tbdir/tbprerun $pid $eid $nsfile") != 0) {
# So fatal errors run tbend. # So fatal errors run tbend.
$estate = EXPTSTATE_PRERUN; $estate = EXPTSTATE_PRERUN;
if (system("$tbdir/tbswapin $pid $eid") != 0) { if (! $frontend) {
$errorstat = $? >> 8; if (system("$tbdir/tbswapin $pid $eid") != 0) {
fatal("tbswapin failed!\n"); $errorstat = $? >> 8;
fatal("tbswapin failed!\n");
}
# So fatal errors run tbswapout,
$estate = EXPTSTATE_ACTIVE;
#
# Look for the unsual case of more than 2 nodes and no vlans. Send a
# warning message.
#
if (ExpNodes($pid, $eid) > 2) {
my $vlans_result =
DBQueryFatal("select * from vlans where ".
"pid='$pid' and eid='$eid'");
if (!$vlans_result->numrows) {
SENDMAIL("$user_name <$user_email>",
"WARNING: Experiment Configuration: $pid/$eid",
"This experiment has zero network links defined.\n".
"Please check your NS file to verify this is what you ".
"want!\n",
"$user_name <$user_email>",
"Cc: $TBOPS", ($nsfile));
}
}
} }
# So fatal errors run tbswapout,
$estate = EXPTSTATE_ACTIVE;
if (system("$tbdir/tbreport -b $pid $eid 2>&1 > $repfile") != 0) { if (system("$tbdir/tbreport -b $pid $eid 2>&1 > $repfile") != 0) {
fatal("tbreport failed!\n"); fatal("tbreport failed!\n");
} }
#
# Look for the unsual case of more than 2 nodes and no vlans. Send a
# warning message.
#
if (ExpNodes($pid, $eid) > 2) {
my $vlans_result =
DBQueryFatal("select * from vlans where pid='$pid' and eid='$eid'");
if (!$vlans_result->numrows) {
SENDMAIL("$user_name <$user_email>",
"WARNING: Experiment Configuration: $pid/$eid",
"This experiment has zero network links defined.\n".
"Please check your NS file to verify this is what you ".
"want!\n",
"$user_name <$user_email>",
"Cc: $TBOPS", ($nsfile));
}
}
# #
# Increment the project experiment count/lastdate. This is informational. # Increment the project experiment count/lastdate. This is informational.
# #
...@@ -295,9 +303,11 @@ my $infodir = "$pid-$eid-" . TBDateTimeFSSafe(); ...@@ -295,9 +303,11 @@ my $infodir = "$pid-$eid-" . TBDateTimeFSSafe();
if (mkdir("$TBINFO/$infodir", 0770)) { if (mkdir("$TBINFO/$infodir", 0770)) {
system("cp $nsfile $TBINFO/$infodir"); system("cp $nsfile $TBINFO/$infodir");
system("cp *.ptop *.top $TBINFO/$infodir");
system("cp assign.log $TBINFO/$infodir");
system("cp $logname $TBINFO/$infodir/$eid.log"); system("cp $logname $TBINFO/$infodir/$eid.log");
if (-e "assign.log") {
system("cp *.ptop *.top $TBINFO/$infodir");
system("cp assign.log $TBINFO/$infodir");
}
if (-e "wanassign.log") { if (-e "wanassign.log") {
system("cp wanassign.log $TBINFO/$infodir"); system("cp wanassign.log $TBINFO/$infodir");
} }
......
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