Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
d378fccd
Commit
d378fccd
authored
Mar 19, 2001
by
Leigh B. Stoller
Browse files
Put back tbend. Damn.
parent
a3cb8436
Changes
1
Hide whitespace changes
Inline
Side-by-side
tbsetup/tbend.in
0 → 100644
View file @
d378fccd
#!/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
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment