Commit 6e5ff1ad authored by Christopher Alfeld's avatar Christopher Alfeld
Browse files

tbprerun.tcl - Integrated with reservation system.

tbrun.tcl - Integrated with ifc_boot
test.ns - Changed a bit.
tbend.tcl - Added - Does clean up.
parent b1bbc849
#!/usr/local/bin/tclsh
proc outs {args} {
global logFp
if {[llength $args] == 1} {
set out stdout
set s [lindex $args 0]
} else {
set out [lindex $args 0]
set s [lindex $args 1]
}
puts $out $s
puts $logFp $s
}
if {[file dirname [info script]] == "."} {
set updir ".."
} else {
set updir [file dirname [file dirname [info script]]]
}
set nfree "$updir/db/nfree"
set libir "$updir/ir/libir.tcl"
set resetvlans "$updir/switch_tools/intel510/resetvlans.tcl"
source $libir
namespace import TB_LIBIR::ir
if {$argc != 1} {
puts stderr "Syntax: $argv0 <ir-file>"
exit 1
}
set nsFile [lindex $argv 0]
set t [split $nsFile .]
set prefix [join [lrange $t 0 [expr [llength $t] - 2]] .]
set irFile "$prefix.ir"
set logFile "$prefix.log"
if {[catch "open $logFile a+" logFp]} {
puts stderr "Could not open $logFile for writing."
exit 1
}
outs "Input: $irFile"
outs "Log: $logFile"
if {! [file exists $irFile]} {
outs stderr "$irFile does not exist"
exit 1
}
outs ""
outs "Ending Testbed run for $irFile. [clock format [clock seconds]]"
ir read $irFile
outs "Unallocating resources"
set nodemap [ir get /virtual/nodes]
set machines {}
foreach pair $nodemap {
lappend machines [lindex $pair 1]
}
if {[catch "exec $nfree $prefix $machines >@ $logFp 2>@ $logFp err"]} {
outs stderr "Error freeing resources. ($err)"
exit 1
}
outs "Resetting VLANs"
if {[catch "exec $resetvlans $machines >@ $logFp 2>@ $logFp" err]} {
outs stderr "Error reseting vlans ($err)"
exit 1
}
......@@ -22,6 +22,14 @@ if {[file dirname [info script]] == "."} {
set ns2ir "$updir/ir/ns2ir/parse.tcl"
set assign "$updir/ir/assign.tcl"
set handle_ip "$updir/ir/handle_ip.tcl"
set avail "$updir/db/avail"
set ptopgen "$updir/db/ptopgen"
set ptopfile "$updir/ir/testbed.ptop"
set reserve "$updir/db/nalloc"
set libir "$updir/ir/libir.tcl"
source $libir
namespace import TB_LIBIR::ir
if {$argc != 1} {
puts stderr "Syntax: $argv0 <ns-file>"
......@@ -60,7 +68,11 @@ if {! [file exists $irFile]} {
exit 1
}
outs "PLACEHOLDER - Determining available resources."
outs "Determining available resources."
if {[catch "exec $avail type=pc OS=FreeBSD ver extras | $ptopgen > $ptopfile 2>@ $logFp" err]} {
outs stderr "Error determining available resources. ($err)"
exit 1
}
outs "Allocating resources - This may take a while."
if {[catch "exec $assign $irFile >@ $logFp 2>@ $logFp" err]} {
......@@ -68,7 +80,18 @@ if {[catch "exec $assign $irFile >@ $logFp 2>@ $logFp" err]} {
exit 1
}
outs "PLACEHODLER - Reserving resources."
ir read $irFile
set nodemap [ir get /virtual/nodes]
set machines {}
foreach pair $nodemap {
lappend machines [lindex $pair 1]
}
outs "PLACEHOLDER - Reserving resources."
if {[catch "exec $reserve $prefix $machines >@ $logFp 2>@ $logFp" err]} {
outs stderr "Error reserving resources. ($err)"
exit 1
}
outs "Allocating IP addresses."
if {[catch "exec $handle_ip $irFile $nsFile >@ $logFp 2>@ $logFp" err]} {
......
......@@ -14,14 +14,17 @@ proc outs {args} {
puts $logFp $s
}
if {[file dirname [info script]] == "."} {
set scriptdir [file dirname [info script]]
if {$scriptdir == "."} {
set updir ".."
} else {
set updir [file dirname [file dirname [info script]]]
set updir [file dirname $scriptdir]
}
set snmpit "$updir/switch_tools/intel510/snmpit"
set resetvlans "$updir/switch_tools/intel510/resetvlans.tcl"
set libir "$updir/ir/libir.tcl"
set ir2ifc "$scriptdir/ir2ifc"
set ifcboot "$scriptdir/ifc_boot"
source $libir
namespace import TB_LIBIR::ir
......@@ -69,11 +72,18 @@ if {[catch "exec $snmpit -u -f $irFile >@ $logFp 2>@ $logFp" err]} {
exit 1
}
outs "PLACEHOLDER - Verifying virtual network."
#outs "PLACEHOLDER - Verifying virtual network."
outs "PLACEHOLDER - Copying disk images."
outs "PLACEHOLDER - Booting for the first time."
outs "PLACEHOLDER - Verifying OS functionality."
outs "PLACEHOLDER - Setting up interfaces."
# XXX - This should only be done for linux/freebsd OSs
outs "Setting up interfaces."
if {[catch "exec cat $irFile | $ir2ifc | $ifcboot >@ $logFp 2>@ $logFp" err]} {
outs stderr "Error setting interfaces ($err)"
exit 1
}
outs "PLACEHOLDER - Installing secondary pacakages."
outs "PLACEHOLDER - Rebooting."
outs "Testbed ready for use."
......
set ns [new Simulator]
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set node0 [$ns node]
set node1 [$ns node]
set node2 [$ns node]
$ns duplex-link $n0 $n1 100Mb 10ms DropTail
$ns duplex-link $n1 $n2 100Mb 10ms DropTail
$ns duplex-link $node0 $node1 100Mb .1ms DropTail
$ns duplex-link $node1 $node2 100Mb .1ms DropTail
#TB set-ip n0 192.168.14.52
#TB set-ip-interface n2 n1 192.168.5.1
#TB set-ip node0 192.168.14.52
#TB set-ip-interface node2 node1 192.168.5.1
$ns run
Supports Markdown
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