]> git.entuzijast.net Git - imunes.git/commitdiff
prepravio node_id handling tako da ga se ne konstruira non-stop nego se u deployCfg...
authorJosip Rodin <joy@numa-ubuntu-vm.(none)>
Sun, 13 Sep 2009 11:40:40 +0000 (13:40 +0200)
committerJosip Rodin <joy@numa-ubuntu-vm.(none)>
Sun, 13 Sep 2009 11:40:40 +0000 (13:40 +0200)
linux/exec.tcl

index fd864da53d12a7d4ce4b6a5c876c65771929facc..7ff0340baef8129e005749ff210fb4076b38f4c0 100755 (executable)
@@ -264,10 +264,8 @@ proc l3node.instantiate { eid node } {
 
        puts "\nl3node.INSTANTIATE $eid $node"
 
-    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
-    set openvz_node_id $eid[string range $node 1 end]
+       upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id
+       upvar 0 ::cf::[set ::curcfg]::[set node]::openvz_node_id openvz_node_id
 
 # ovdje bismo mogli napraviti OpenVZ conf file za ovaj node
 # ali pustamo vzctl create da ga sam automatski izgenerira iz
@@ -291,7 +289,7 @@ proc l3node.instantiate { eid node } {
 
 # s Linux/OpenVZ moramo pricekati da se izvrti init procedura, koja
 # nam omoguci razne korisne stvari tipa proc filesystem itd
-    global openvz_node_dir
+    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..."
@@ -392,7 +390,7 @@ proc l3node.instantiate { eid node } {
 #****
 proc l3node.nghook { eid node ifc } {
     set ifnum [string range $ifc 3 end]
-    set node_id "$eid\.$node"
+       upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id
     switch -exact [string range $ifc 0 2] {
        eth {
            return [list $ifc@$node_id ether]
@@ -423,16 +421,17 @@ proc l3node.start { eid node } {
     
        puts "\nl3node.START $eid $node"
     
-    set node_id "$eid\.$node"
+       upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id
 
 # na FreeBSD-u vimagei imaju shared filesystem
-# na Linuxu VEovi to nemaju
 #    set node_dir "/tmp/$eid/$node"
 #    puts "    would recreate node_dir (/tmp/$eid/$node)"
 #    nexec rm -fr $node_dir
 #    nexec mkdir $node_dir
 #    nexec chmod 1777 $node_dir
-    global openvz_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
 
 # TODO: konfiguriranje MTU-a zasad ne podrzavamo (kao ni ostale L2 parametre)
 #    foreach ifc [ifcList $node] {
@@ -490,10 +489,10 @@ proc l3node.start { eid node } {
        set bootcmd [[typemodel $node].bootcmd $node]
     }
     puts "  typemodel=[typemodel $node]"
-#    puts "bootcfg=$bootcfg i bootcmd=$bootcmd"
+    puts "bootcfg=$bootcfg i bootcmd=$bootcmd"
     if { ! $remote_exec } {
         if { $bootcmd != "/bin/sh" } {
-               puts "  would write node_dir/boot.conf"
+               puts "  would write $node_dir/boot.conf"
                set fileId [open $node_dir/boot.conf w]
                foreach line $bootcfg {
                    puts $fileId $line
@@ -501,9 +500,9 @@ proc l3node.start { eid node } {
                close $fileId
         }
     } else {
-       nexec create_conf_file $node_dir/boot.conf
-       foreach line $bootcfg {
-           puts $execSock $line
+               nexec create_conf_file $node_dir/boot.conf
+               foreach line $bootcfg {
+                   puts $execSock $line
        }
        nexec close_conf_file
     }
@@ -531,9 +530,9 @@ proc l3node.start { eid node } {
     } else {
 # quagga i drugi mogu imati svoje custom skripte za bootanje koja se prepoznaje po
 # bootcmdu (interpreteru) koji nije obican shell
-        puts " would execute bootcmd $bootcmd boot.conf in $node_id"
-#       catch nexec vimage $node_id $bootcmd $node_dir/boot.conf >& $node_dir/out.log &"
                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
            if { $ret != "TCL_OK" && $ret != ""} {
             puts "  =>Command \"$command\" executed on $node returned: \
@@ -561,7 +560,7 @@ proc l3node.start { eid node } {
 #   * node -- node id
 #****
 proc l3node.shutdown { eid node } {
-    set node_id "$eid\.$node"
+       upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id
     puts "nexec vimage $node_id kill -9 -1 2> /dev/null"
     foreach ifc [ifcList $node] {
        foreach ipv4 [getIfcIPv4addr $node $ifc] {
@@ -588,6 +587,8 @@ proc l3node.shutdown { eid node } {
 #   * node -- node id
 #****
 proc l3node.destroy { eid node } {
+# FIXME
+#      upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id
     set node_id $node
     foreach ifc [ifcList $node] {
        puts " nexec vimage $eid ngctl msg $ifc@$node_id: shutdown "
@@ -602,7 +603,7 @@ proc l3node.destroy { eid node } {
     nexec vzctl stop $node
     nexec vzctl destroy $node
 
-# FreeBSD only node_dir:
+# FreeBSD-only:
 #    set node_dir "/tmp/$eid/$node"
 #    nexec rm -fr $node_dir
 }
@@ -656,14 +657,19 @@ proc deployCfg {} {
 #    puts { nexec kldload ng_socket }
 
     foreach node $node_list {
-       # OpenVZ VE name format su brojke (bez tocaka)
-       set node_id "$eid\.$node"
-       set type [nodeType $node]
-       set name [getNodeName $node]
-       if { $type != "pseudo" } {
-           statline "Creating node $name"
-           [typemodel $node].instantiate $eid $node
-       }
+               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]
+               set type [nodeType $node]
+               set name [getNodeName $node]
+               if { $type != "pseudo" } {
+                   statline "Creating node $name"
+                   [typemodel $node].instantiate $eid $node
+               }
     }
 
 ## TODO: Podesavanje l2 parametara
@@ -831,12 +837,12 @@ proc deployCfg {} {
 #    }
 
     foreach node $node_list {
-       upvar 0 ::cf::[set ::curcfg]::$node $node
-       set type [nodeType $node]
-       if { $type == "pseudo" } {
-           continue
-       }
-       statline "Configuring node [getNodeName $node]"
+               upvar 0 ::cf::[set ::curcfg]::[set node] $node
+               set type [nodeType $node]
+               if { $type == "pseudo" } {
+                   continue
+               }
+               statline "Configuring node [getNodeName $node]"
        [typemodel $node].start $eid $node
     }