Commit d378fccd authored by Leigh Stoller's avatar Leigh Stoller

Put back tbend. Damn.

parent a3cb8436
#!/usr/bin/perl -w
# tbend
# This cleans up the state after a testbed experiment is finished.
$TBROOT = "@prefix@";
$TBDB = "@TBDBNAME@";
$TBSETUPLIB = "$TBROOT/lib";
$ENV{'PATH'} = "$TBROOT/libexec:$TBROOT/libexec/ir" .
":$TBROOT/libexec/ns2ir:$TBROOT/sbin:$TBROOT/bin:/usr/bin";
push(@INC,$TBSETUPLIB);
require libtbsetup;
require 'ctime.pl';
if ($#ARGV < 1 || $#ARGV > 2 ||
($#ARGV == 2 && $ARGV[0] ne "-nologfile")) {
print STDERR "Syntax: $0 [-nologfile] pid eid\n";
exit(1);
}
if ($#ARGV == 2) {
shift;
$dolog = 0;
}
else {
$dolog = 1;
}
($pid,$eid) = @ARGV;
use DBI;
$dbh=&tbs_initdbi($TBDB);
$prefix = "$pid-$eid";
if ($dolog) {
$logfile = "$prefix-end.log";
&tbs_initlog($logfile);
&tbs_out("Id: $prefix\n");
&tbs_out("Log: $logfile\n");
&tbs_out("\n");
}
&tbs_out("Ending Testbed run for $prefix. " . &ctime(time) . "\n");
&tbs_out("Finding resources.\n");
$sth = $dbh->prepare("SELECT node_id FROM reserved \
WHERE eid=\"$eid\" AND pid=\"$pid\"");
$sth->execute;
@nodes = ();
while (@row = $sth->fetchrow_array) {
push(@nodes,$row[0]);
}
$sth->finish;
&tbs_out("Resetting VLANs\n");
if (&tbs_exec("resetvlans " . join(" ",@nodes))) {
&tbs_out("Failed to reset VLANs\n");
exit(1);
}
&tbs_out("Backing up VLAN configuration\n");
if (&tbs_exec("savevlans")) {
&tbs_out("WARNING: Failed to back up VLAN configuration\n");
}
&tbs_out("Freeing resources\n");
if (&tbs_exec("nfree $pid $eid")) {
&tbs_out("Failed to free resources.\n");
exit(1);
}
&tbs_out("Resetting named maps\n");
if (&tbs_exec("named_setup")) {
&tbs_out("Failed to reset named map.\n");
#
# This is a non-fatal error.
#
}
&tbs_out("Clearing virt_names table\n");
foreach (@nodes) {
$sth = $dbh->prepare("DELETE from virt_names where src_node_id = \"$_\" or dest_node_id = \"$_\"");
$sth->execute;
$sth->finish;
}
&tbs_out("Cleanup finished - " . &ctime(time) . "\n");
0;
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