From 1503995b254cf9116e65df4c74ec5d2a4134347a Mon Sep 17 00:00:00 2001 From: Josip Rodin Date: Sun, 13 Sep 2009 14:57:25 +0200 Subject: [PATCH] node_id varijabla je stajala neiskoristena pod OpenVZ-om, pa sam je iskoristio za support za vise paralelenih eksperimenata; razni cleanupi --- linux/appstart.tcl | 6 ++--- linux/exec.tcl | 58 +++++++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/linux/appstart.tcl b/linux/appstart.tcl index 41bb41c..16af1d0 100644 --- a/linux/appstart.tcl +++ b/linux/appstart.tcl @@ -15,7 +15,7 @@ proc spawnShell { node cmd } { upvar 0 ::cf::[set ::curcfg]::eid eid global remote_exec exec_host gui_unix - set node_id $eid\.$node + upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id if { $remote_exec } { nexec vimageShellServer.sh $node_id 1234 $cmd & @@ -29,9 +29,9 @@ proc spawnShell { node cmd } { } else { # OpenVZ vzctl enter mod support, inace shell nema $PROMPT if { $cmd == "/bin/sh" } { - set shellcommand "vzctl enter $node" + set shellcommand "vzctl enter $node_id" } else { - set shellcommand "vzctl exec $node $cmd" + set shellcommand "vzctl exec $node_id $cmd" } nexec xterm -sb -rightbar \ -T "IMUNES: [getNodeName $node] (console)" \ diff --git a/linux/exec.tcl b/linux/exec.tcl index 9f747e6..05f86b8 100755 --- a/linux/exec.tcl +++ b/linux/exec.tcl @@ -103,7 +103,7 @@ proc setOperMode { mode } { puts "\nsetOperMode $mode" if { $mode == "exec" } { ;# let's try something, sockets should be opened - puts $::env(USERNAME) +# puts Running as $::env(USERNAME)... if { $editor_only } { ;# if set in nexec or open_exec_sockets .menubar.experiment entryconfigure "Execute" -state disabled return @@ -265,39 +265,39 @@ proc l3node.instantiate { eid node } { puts "\nl3node.INSTANTIATE $eid $node" upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id - upvar 0 ::cf::[set ::curcfg]::[set node]::openvz_node_id openvz_node_id + upvar 0 ::cf::[set ::curcfg]::[set node]::ve_id ve_id # ovdje bismo mogli napraviti OpenVZ conf file za ovaj node # ali pustamo vzctl create da ga sam automatski izgenerira iz # vps-basic sample datoteke u /etc/vz/conf/ # puts " nexec vimage -c $node_id " - nexec vzctl create $openvz_node_id --ostemplate imunes-openvz + nexec vzctl create $ve_id --ostemplate imunes-openvz # Dodjela naseg kratkog node ida njegovom numerickom VE ID-u opcijom --name -# TODO: ako bude potreban support za vise paralelenih eksperimenata, -# trebat ce VE name podesiti s prefiksom $eid (i analogno u vimageCleanup) - nexec vzctl set $openvz_node_id --name $node --save +# Zbog supporta za vise paralelnih eksperimenata, VE name je +# node_id tako da sadrzi i $node i prefiks $eid + nexec vzctl set $ve_id --name $node_id --save # puts " nexec vimage $node_id hostname [getNodeName $node] " - nexec vzctl set $node --hostname [getNodeName $node] --save + nexec vzctl set $node_id --hostname [getNodeName $node] --save # feature FreeBSD-a only (expandanje @ u symlinkovima kao node id) # puts " nexec vimage $node_id sysctl vfs.morphing_symlinks=1 " - nexec vzctl start $node + nexec vzctl start $node_id # s Linux/OpenVZ moramo pricekati da se izvrti init procedura, koja # nam omoguci razne korisne stvari tipa proc filesystem itd - upvar 0 ::cf::[set ::curcfg]::[set node]::openvz_node_dir openvz_node_dir - set openvz_node_dir "/var/lib/vz/private/$openvz_node_id" - set openvz_boot_done "$openvz_node_dir/tmp/imunes-boot-done" - puts " waiting for VE $openvz_node_id to actually start..." - while { ! [ file exists $openvz_boot_done ] } { + upvar 0 ::cf::[set ::curcfg]::[set node]::ve_dir ve_dir + set ve_dir "/var/lib/vz/private/$ve_id" + set ve_boot_done "$ve_dir/tmp/imunes-boot-done" + puts " waiting for VE $ve_id to actually start..." + while { ! [ file exists $ve_boot_done ] } { after 100 } - puts " detected VE $openvz_node_id done" - file delete $openvz_boot_done + puts " detected VE $ve_id done" + file delete $ve_boot_done foreach ifc [ifcList $node] { switch -exact [string range $ifc 0 2] { @@ -331,7 +331,7 @@ proc l3node.instantiate { eid node } { } } # puts " nexec vimage $node_id ifconfig $ifc link $ether " - nexec vzctl {set} $node --netif_add $ifc,$ether,$ifid,$host_ether + nexec vzctl {set} $node_id --netif_add $ifc,$ether,$ifid,$host_ether set ngnodemap($ifc@$node_id) $ifid } ser { @@ -430,8 +430,8 @@ proc l3node.start { eid node } { # nexec mkdir $node_dir # nexec chmod 1777 $node_dir # na Linuxu VEovi imaju svaki svoj dir - upvar 0 ::cf::[set ::curcfg]::[set node]::openvz_node_dir openvz_node_dir - set node_dir $openvz_node_dir + upvar 0 ::cf::[set ::curcfg]::[set node]::ve_dir ve_dir + set node_dir $ve_dir # TODO: konfiguriranje MTU-a zasad ne podrzavamo (kao ni ostale L2 parametre) # foreach ifc [ifcList $node] { @@ -512,7 +512,7 @@ proc l3node.start { eid node } { puts " executing on $node: $line" set command $line if { "$command" != "" } { - catch { nexec vzctl exec $node $command } ret + catch { nexec vzctl exec $node_id $command } ret # Ispravno izvedene naredbe u OpenVZ VE vracaju jedan prazan red # pa ih se ignorira. Ako se preda prazan red kao naredba, takodjer je # vracen jedan prazan red pa se i to ignorira. @@ -533,7 +533,7 @@ proc l3node.start { eid node } { set command "$bootcmd boot.conf" 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 $command } ret + catch { nexec vzctl exec $node_id $command } ret if { $ret != "TCL_OK" && $ret != ""} { puts " =>Command \"$command\" executed on $node returned: \ \"$ret\"" @@ -588,6 +588,8 @@ proc l3node.shutdown { eid node } { #**** proc l3node.destroy { eid node } { + upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id + # TODO serial interface support # foreach ifc [ifcList $node] { # puts " nexec vimage $eid ngctl msg $ifc@$node_id: shutdown " @@ -601,9 +603,9 @@ proc l3node.destroy { eid node } { # puts "nexec vimage -d $node_id" statline "Stopping VE $node" - nexec vzctl stop $node + nexec vzctl stop $node_id statline "Destroying VE $node" - nexec vzctl destroy $node + nexec vzctl destroy $node_id # FreeBSD-only: # set node_dir "/tmp/$eid/$node" @@ -661,11 +663,13 @@ proc deployCfg {} { foreach node $node_list { namespace eval ::cf::[set ::curcfg]::[set node] {} upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id - set node_id "$eid\.$node" - # OpenVZ VE ID moze biti samo numericki, dok nas node_id sadrzi - # delimiter tocku i slovo n, pa te znakove moramo izbaciti - upvar 0 ::cf::[set ::curcfg]::[set node]::openvz_node_id openvz_node_id - set openvz_node_id $eid[string range $node 1 end] + # OpenVZ VE ID i name ne mogu sadrzavati znak tocku, a ni ne + # treba nam posebno (jer je samo vizualni delimiter), pa je izbacena + set node_id "$eid$node" + # OpenVZ VE ID moze biti samo numericki, dok nas node_id + # na pocetku ima i slovo n, pa taj prvi znak moramo izbaciti + upvar 0 ::cf::[set ::curcfg]::[set node]::ve_id ve_id + set ve_id $eid[string range $node 1 end] set type [nodeType $node] set name [getNodeName $node] if { $type != "pseudo" } { -- 2.39.5