proc nexec { args } {
global remote_exec editor_only
global execSock
- global debug
+ global imunes_debug
if { $remote_exec } {
if { ![info exists execSock] || $execSock == "" } {
if { $remote_exec } {
rexec $execSock $args
} else {
- if { $debug } {
+ if { $imunes_debug } {
puts " -- running: $args"
}
eval exec $args
# * name -- the name of the new interface
#****
proc createIfc { eid type hook } {
- global debug
- if { $debug } {
+ global imunes_debug
+ if { $imunes_debug } {
puts "usli u createIfc $eid $type $hook"
}
}
# * node -- node id
#****
proc l3node.instantiate { eid node } {
- global debug
- if { $debug } {
+ global imunes_debug
+ if { $imunes_debug } {
puts "\nl3node.INSTANTIATE $eid $node"
}
proc l3node.start { eid node } {
global remote_exec execSock
global viewcustomid
- global debug
+ global imunes_debug
- if { $debug } {
+ if { $imunes_debug } {
puts "\nl3node.START $eid $node"
}
# nam omoguci razne korisne stvari tipa proc filesystem itd
upvar 0 ::cf::[set ::curcfg]::[set node]::ve_dir ve_dir
set ve_boot_done "$ve_dir/tmp/imunes-boot-done"
- if { $debug } {
+ if { $imunes_debug } {
puts -nonewline " Waiting for VE $node ($ve_id) to actually start "
while { ! [ file exists $ve_boot_done ] } {
after 300
set peer [peerByIfc $node $ifc]
- if { $debug } {
+ if { $imunes_debug } {
puts " Interface $ifc at $node links to $peer"
}
set bootcfg [[typemodel $node].cfggen $node]
set bootcmd [[typemodel $node].bootcmd $node]
}
- if { $debug } {
+ if { $imunes_debug } {
puts " typemodel = [typemodel $node]"
puts " bootcmd = $bootcmd"
puts " bootcfg = $bootcfg"
}
if { ! $remote_exec } {
if { $bootcmd != "/bin/sh" } {
- if { $debug } {
+ if { $imunes_debug } {
puts " writing $node_dir/boot.conf"
}
set fileId [open $node_dir/boot.conf w]
- if { $debug } {
+ if { $imunes_debug } {
foreach line $bootcfg {
puts $fileId $line
}
}
} else {
nexec create_conf_file $node_dir/boot.conf
- if { $debug } {
+ if { $imunes_debug } {
foreach line $bootcfg {
puts $execSock $line
}
# pa ih se ignorira. Ako se preda prazan red kao naredba, takodjer je
# vracen jedan prazan red pa se i to ignorira.
if { $ret != "TCL_OK" && $ret != ""} {
- if { $debug } {
+ if { $imunes_debug } {
puts " =>Command \"$command\" executed on $node returned: \"$ret\""
}
# TODO: batch mode handling
} else {
# quagga i drugi mogu imati svoje custom skripte za bootanje koja se prepoznaje po
# bootcmdu (interpreteru) koji nije obican shell
- if { $debug } {
+ if { $imunes_debug } {
puts " placing $bootcmd in $node_dir"
}
set bootfile [file tail $bootcmd]
file copy $bootcmd "$node_dir/$bootfile"
set command "/$bootfile boot.conf"
- if { $debug } {
+ if { $imunes_debug } {
puts " will now execute $command in $node_id"
}
# catch nexec vimage $node_id $bootcmd $node_dir/boot.conf >& $node_dir/out.log &"
catch { nexec vzctl exec $node_id $command } ret
if { $ret != "TCL_OK" && $ret != ""} {
- if { $debug } {
+ if { $imunes_debug } {
puts " =>Command \"$command\" executed on $node returned: \"$ret\""
}
# TODO: batch mode handling
#****
proc l3node.shutdown { eid node } {
upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id
- global debug
+ global imunes_debug
- if { $debug } {
+ if { $imunes_debug } {
puts " Stopping VE $node ($node_id)"
}
statline "Stopping VE $node ($node_id)"
proc l3node.destroy { eid node } {
upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id
- global debug
+ global imunes_debug
# TODO serial interface support
# foreach ifc [ifcList $node] {
# }
set msg "Destroying VE $node ($node_id)"
- if { $debug } {
+ if { $imunes_debug } {
puts " $msg"
}
statline $msg
global mac_byte4 mac_byte5
global remote_exec
global eid_base
- global debug
-
- if { $debug } {
+ global imunes_debug
+
+ if { $imunes_debug } {
puts "\n= deployCfg starts ="
}
#jedan od nodeova je sigurno L2, sad provjerava da li se radi o vezi izmedju
#dva L2 uredjaja
if { [[typemodel $lnode1].layer] == "LINK" && [[typemodel $lnode2].layer] == "LINK" } {
- if { $debug } {
+ if { $imunes_debug } {
#slucaj kad su spojena dva huba!!
puts "\n\n*********************************************************************"
puts "**** Panic! Panic! Spojena su dva huba, nemogu ja to!! ***\n"
}
if { $bridgefound == true } {
- if { $debug } {
+ if { $imunes_debug } {
puts "\nBridge $bridge (L2 hub emulation) already exists."
}
} else {
- if { $debug } {
+ if { $imunes_debug } {
puts "\nCreating bridge $bridge (L2 hub emulation)"
}
nexec brctl addbr $bridge
if { [nodeType $bridge_node] == "rj45" } {
set bridge_name [getNodeName $bridge_node]
nexec brctl addif $bridge $bridge_name
- if { $debug } {
+ if { $imunes_debug } {
puts " RJ45 emulacija, spojen na $bridge_name na hostu."
}
}
nexec brctl addif $bridge $port_if
#dize bridge, interesantno ne baca error ako je bridge vec dignut
nexec ip link set up dev $bridge
- if { $debug } {
+ if { $imunes_debug } {
puts " L2 device $bridge is up, added interface $port_if"
}
set bridge "b$eid$lname"
set bridge_node $lname
- if { $debug } {
+ if { $imunes_debug } {
puts "\nCreating bridge $bridge"
}
nexec brctl addif $bridge $host_if_a
nexec brctl addif $bridge $host_if_b
nexec ip link set up dev $bridge
- if { $debug } {
+ if { $imunes_debug } {
puts " Bridge $bridge is up, added interface $host_if_a and $host_if_b"
}
}
}
set msg "Network topology instantiated in [expr [clock seconds] - $t_start] seconds ([llength $node_list] nodes and [llength $link_list] links)."
statline $msg
- if { $debug } {
+ if { $imunes_debug } {
puts "\n$msg"
puts "\n= deployCfg end ="
}
proc vimageCleanup { eid } {
global .c
global execMode
- global debug
+ global imunes_debug
- if { $debug } {
+ if { $imunes_debug } {
puts "\n= Cleanup $eid start ="
}
set t_start [clock seconds]
- if { $debug } {
+ if { $imunes_debug } {
puts "\nBridge cleanup in main host"
}
upvar 0 ::cf::[set ::curcfg]::bridges bridges
if { [ info exists bridges ] && [ llength $bridges ] } {
foreach bridge $bridges {
- if { $debug } {
+ if { $imunes_debug } {
puts " Cleaning up bridge $bridge..."
}
nexec ip link set down dev $bridge
nexec brctl delbr $bridge
}
}
- if { $debug } {
+ if { $imunes_debug } {
puts " Done.\n"
}
# OpenVZ - samo nam treba popis nodeova za pogasiti
upvar 0 ::cf::[set ::curcfg]::node_list node_list
- if { $debug } {
+ if { $imunes_debug } {
puts "Stopping all VEs..."
}
foreach node $node_list {
# bridge suceljem a ne VEom iako su u $node_list, stoga nema se sto gasiti
}
}
- if { $debug } {
+ if { $imunes_debug } {
puts " Done.\n"
puts "Destroying VE private enviroments..."
}
set msg "Cleanup completed in [expr [clock seconds] - $t_start] seconds."
statline $msg
- if { $debug } {
+ if { $imunes_debug } {
puts " $msg"
puts " Done.\n"
puts "\n= Cleanup $eid end ="
# qdisc -- queuing discipline
#****
proc execSetIfcQDisc { eid node ifc qdisc } {
- global debug
+ global imunes_debug
- if { $debug } {
+ if { $imunes_debug } {
puts "execSetIfcQDisc $eid $node $ifc $qdisc"
}
return
# qdrop -- queue dropping policy
#****
proc execSetIfcQDrop { eid node ifc qdrop } {
- global debug
+ global imunes_debug
- if { $debug } {
+ if { $imunes_debug } {
puts "execSetIfcQDrop $eid $node $ifc $qdrop"
}
return
# qlen -- new queue's length
#****
proc execSetIfcQLen { eid node ifc qlen } {
- global debug
+ global imunes_debug
- if { $debug } {
+ if { $imunes_debug } {
puts "execSetIfcQLen $eid $node $ifc $qlen"
}
return
# link -- link id
#****
proc execSetLinkParams { eid link } {
- global debug
+ global imunes_debug
- if { $debug } {
+ if { $imunes_debug } {
puts "execSetLinkParams $eid $link"
}
return