From: numa Date: Thu, 3 Sep 2009 13:00:30 +0000 (+0200) Subject: zakomentiran niz FreeBSD-specific i/ili neimplementiranih stvari; OpenVZ interface... X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=5180da437d28079b20efb878ca04baf57a408cc2;p=imunes.git zakomentiran niz FreeBSD-specific i/ili neimplementiranih stvari; OpenVZ interface configuration; bootcfg execution prebacen u vzctl exec --- diff --git a/exec.tcl b/exec.tcl index 4d7442f..2812c62 100755 --- a/exec.tcl +++ b/exec.tcl @@ -232,11 +232,13 @@ proc statline {line} { #**** proc createIfc { eid type hook } { puts "usli u createIfc $eid $type $hook" - puts " izvrsili bismo exec printf mkpeer $type $hook $hook \n show .$hook | vimage $eid ngctl -f -" - puts " izvadili bi drugi element iz toga" - return fake_if_id - catch { exec printf "mkpeer $type $hook $hook \n show .$hook" | vimage $eid ngctl -f - } nglist - return [lindex $nglist 1] + +# FreeBSD-specific: +# puts " izvrsili bismo exec printf mkpeer $type $hook $hook \n show .$hook | vimage $eid ngctl -f -" +# puts " izvadili bi drugi element iz toga" +# return fake_if_id +# catch { exec printf "mkpeer $type $hook $hook \n show .$hook" | vimage $eid ngctl -f - } nglist +# return [lindex $nglist 1] } @@ -271,7 +273,7 @@ proc l3node.instantiate { eid 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 " +# puts " nexec vimage -c $node_id " nexec vzctl create $openvz_node_id --ostemplate imunes-openvz # Dodjela naseg kratkog node ida njegovom numerickom VE ID-u opcijom --name @@ -279,7 +281,7 @@ proc l3node.instantiate { eid node } { # trebat ce VE name podesiti s prefiksom $eid (i analogno u vimageCleanup) nexec vzctl set $openvz_node_id --name $node --save - puts " nexec vimage $node_id hostname [getNodeName $node] " +# puts " nexec vimage $node_id hostname [getNodeName $node] " nexec vzctl set $node --hostname [getNodeName $node] --save # feature FreeBSD-a only (expandanje @ u symlinkovima kao node id) @@ -290,50 +292,64 @@ proc l3node.instantiate { eid node } { foreach ifc [ifcList $node] { switch -exact [string range $ifc 0 2] { eth { - set ifid [createIfc $eid eiface ether] - puts " nexec vimage $eid vimage -i $node $ifid $ifc " +# FreeBSD-specific: +# set ifid [createIfc $eid eiface ether] +# puts " nexec vimage $eid vimage -i $node $ifid $ifc " + +# na Linuxu ne moramo pokrenuti createIfc, samo postaviti ovaj standardni format +# koji ide u vzctl --netif_add + set ifid "to_${node}_${ifc}" set peer [peerByIfc $node $ifc] + + puts "vidimo node: $node ifclist: $ifc peer: $peer" + if { [nodeType $peer] == "rj45" } { - set peerifc [getNodeName $peer] - set ether [nexec ifconfig $peerifc | fgrep "ether " | cut -c8-] +# TODO: RJ-45 nodes zasad ne podrzavamo +# set peerifc [getNodeName $peer] +# set ether [nexec ifconfig $peerifc | fgrep "ether " | cut -c8-] } else { - set ether 40:00:aa:aa:$mac_byte4:$mac_byte5 + # vzctl ne prima ako nije properly padded + set ether 40:00:aa:aa:[format %02x $mac_byte4]:[format %02x $mac_byte5] + set host_ether 40:00:aa:ff:[format %02x $mac_byte4]:[format %02x $mac_byte5] incr mac_byte5 if { $mac_byte5 >= 100 } { set mac_byte5 0 incr mac_byte4 } } - puts " nexec vimage $node_id ifconfig $ifc link $ether " +# puts " nexec vimage $node_id ifconfig $ifc link $ether " + nexec vzctl {set} $node --netif_add $ifc,$ether,$ifid,$host_ether set ngnodemap($ifc@$node_id) $ifid } ser { - set ifnum [string range $ifc 3 end] - set ifid [createIfc $eid iface inet] - nexec vimage $eid ngctl mkpeer $ifid: cisco inet inet - nexec vimage $eid ngctl connect $ifid: $ifid:inet inet6 inet6 - nexec vimage $eid ngctl msg $ifid: broadcast - nexec vimage $eid ngctl name $ifid:inet hdlc$ifnum\@$node - nexec vimage $eid vimage -i $node $ifid $ifc - set ngnodemap(hdlc$ifnum@$node_id) hdlc$ifnum\@$node +# TODO: serial interfaceove zasad ne podrzavamo +# set ifnum [string range $ifc 3 end] +# set ifid [createIfc $eid iface inet] +# nexec vimage $eid ngctl mkpeer $ifid: cisco inet inet +# nexec vimage $eid ngctl connect $ifid: $ifid:inet inet6 inet6 +# nexec vimage $eid ngctl msg $ifid: broadcast +# nexec vimage $eid ngctl name $ifid:inet hdlc$ifnum\@$node +# nexec vimage $eid vimage -i $node $ifid $ifc +# set ngnodemap(hdlc$ifnum@$node_id) hdlc$ifnum\@$node } } } - set cpuconf [getNodeCPUConf $node] - set cpumin [lindex [lsearch -inline $cpuconf {min *}] 1] - set cpumax [lindex [lsearch -inline $cpuconf {max *}] 1] - set cpuweight [lindex [lsearch -inline $cpuconf {weight *}] 1] - if { $cpumin != "" } { - puts { nexec vimage -m $node_id cpumin $cpumin } - } - if { $cpumax != "" } { - puts { nexec vimage -m $node_id cpumax $cpumax } - } - if { $cpuweight != "" } { - puts { nexec vimage -m $node_id cpuweight $cpuweight } - } +# TODO: OpenVZ CPU tuning +# set cpuconf [getNodeCPUConf $node] +# set cpumin [lindex [lsearch -inline $cpuconf {min *}] 1] +# set cpumax [lindex [lsearch -inline $cpuconf {max *}] 1] +# set cpuweight [lindex [lsearch -inline $cpuconf {weight *}] 1] +# if { $cpumin != "" } { +# puts " nexec vimage -m $node_id cpumin $cpumin " +# } +# if { $cpumax != "" } { +# puts " nexec vimage -m $node_id cpumax $cpumax " +# } +# if { $cpuweight != "" } { +# puts " nexec vimage -m $node_id cpuweight $cpuweight " +# } # FreeBSD-only # puts " @@ -399,14 +415,16 @@ proc l3node.start { eid node } { # na Linuxu VEovi to nemaju # set node_dir "/tmp/$eid/$node" - puts " would recreate 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 - foreach ifc [ifcList $node] { - set mtu [getIfcMTU $node $ifc] - puts " nexec vimage $node_id ifconfig $ifc mtu $mtu " - } + +# TODO: konfiguriranje MTU-a zasad ne podrzavamo (kao ni ostale L2 parametre) +# foreach ifc [ifcList $node] { +# set mtu [getIfcMTU $node $ifc] +# puts " nexec vimage $node_id ifconfig $ifc mtu $mtu " +# } set check [info exists viewcustomid] if { $check == 0 } { @@ -435,6 +453,7 @@ proc l3node.start { eid node } { set ipsecCfg "" if { [getIpsecEnabled $node] == true } { +# TODO: ipsec zasad ne podrzavamo puts " would do the ipsecenabled stuff" # # set setkeycfg [ipsecCfggen $node] @@ -456,9 +475,10 @@ proc l3node.start { eid node } { set bootcfg [[typemodel $node].cfggen $node] set bootcmd [[typemodel $node].bootcmd $node] } - puts " imamo typemodel=[typemodel $node] bootcfg=$bootcfg i bootcmd=$bootcmd" + puts " imamo typemodel=[typemodel $node]" +# puts "bootcfg=$bootcfg i bootcmd=$bootcmd" if { ! $remote_exec } { - 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 @@ -472,8 +492,21 @@ proc l3node.start { eid node } { nexec close_conf_file } - puts " would execute bootcmd boot.conf in $node_id" +# puts " would execute bootcmd boot.conf in $node_id" # catch nexec vimage $node_id $bootcmd $node_dir/boot.conf >& $node_dir/out.log &" + + foreach line $bootcfg { + puts " executing on $node: $line" + set command $line + if { "$command" != "" } { + catch { nexec vzctl exec $node $command } ret + if { $ret != "TCL_OK" } { + puts " $ret" + # TODO: proper GUI message box, plus batch mode handling + } + } + } + } #****f* exec.tcl/l3node.shutdown @@ -595,86 +628,89 @@ proc deployCfg {} { } } - for { set pending_links $link_list } { $pending_links != "" } {} { - set link [lindex $pending_links 0] - set i [lsearch -exact $pending_links $link] - set pending_links [lreplace $pending_links $i $i] +## TODO: podesavanje L2 parametara linka ne podrzavamo - set lnode1 [lindex [linkPeers $link] 0] - set lnode2 [lindex [linkPeers $link] 1] - set ifname1 [ifcByPeer $lnode1 $lnode2] - set ifname2 [ifcByPeer $lnode2 $lnode1] +# for { set pending_links $link_list } { $pending_links != "" } {} { +# set link [lindex $pending_links 0] +# set i [lsearch -exact $pending_links $link] +# set pending_links [lreplace $pending_links $i $i] - if { [getLinkMirror $link] != "" } { - set mirror_link [getLinkMirror $link] - set i [lsearch -exact $pending_links $mirror_link] - set pending_links [lreplace $pending_links $i $i] +# set lnode1 [lindex [linkPeers $link] 0] +# set lnode2 [lindex [linkPeers $link] 1] +# set ifname1 [ifcByPeer $lnode1 $lnode2] +# set ifname2 [ifcByPeer $lnode2 $lnode1] - statline "Creating link $link/$mirror_link" +# if { [getLinkMirror $link] != "" } { +# set mirror_link [getLinkMirror $link] +# set i [lsearch -exact $pending_links $mirror_link] +# set pending_links [lreplace $pending_links $i $i] - set p_lnode2 $lnode2 - set lnode2 [lindex [linkPeers $mirror_link] 0] - set ifname2 [ifcByPeer $lnode2 [getNodeMirror $p_lnode2]] - } else { - statline "Creating link $link" - } +# statline "Creating link $link/$mirror_link" - set lname $lnode1-$lnode2 - set bandwidth [expr [getLinkBandwidth $link] + 0] - set delay [expr [getLinkDelay $link] + 0] - set ber [expr [getLinkBER $link] + 0] - set dup [expr [getLinkDup $link] + 0] - - set peer1 \ - [lindex [[typemodel $lnode1].nghook $eid $lnode1 $ifname1] 0] - set peer2 \ - [lindex [[typemodel $lnode2].nghook $eid $lnode2 $ifname2] 0] - set ngpeer1 $ngnodemap($peer1) - set ngpeer2 $ngnodemap($peer2) - set nghook1 \ - [lindex [[typemodel $lnode1].nghook $eid $lnode1 $ifname1] 1] - set nghook2 \ - [lindex [[typemodel $lnode2].nghook $eid $lnode2 $ifname2] 1] - - puts " nexec vimage $eid ngctl mkpeer $ngpeer1: pipe $nghook1 upper " - puts " nexec vimage $eid ngctl name $ngpeer1:$nghook1 $lname " - puts " nexec vimage $eid ngctl connect $lname: $ngpeer2: lower $nghook2 " - - # Ethernet frame has a 14-byte header - this is a temp. hack!!! - puts " nexec vimage $eid ngctl msg $lname: setcfg { header_offset=14 } " - - # Link parameters - puts " nexec vimage $eid ngctl msg $lname: setcfg - { bandwidth=$bandwidth delay=$delay - upstream={ BER=$ber duplicate=$dup } - downstream={ BER=$ber duplicate=$dup } } " - - # Queues - foreach node [list $lnode1 $lnode2] { - if { $node == $lnode1 } { - set ifc $ifname1 - } else { - set ifc $ifname2 - } +# set p_lnode2 $lnode2 +# set lnode2 [lindex [linkPeers $mirror_link] 0] +# set ifname2 [ifcByPeer $lnode2 [getNodeMirror $p_lnode2]] +# } else { +# statline "Creating link $link" +# } - if { [nodeType $lnode1] != "rj45" && \ - [nodeType $lnode2] != "rj45" } { - execSetIfcQDisc $eid $node $ifc [getIfcQDisc $node $ifc] - execSetIfcQDrop $eid $node $ifc [getIfcQDrop $node $ifc] - execSetIfcQLen $eid $node $ifc [getIfcQLen $node $ifc] - } - } - } +# set lname $lnode1-$lnode2 +# set bandwidth [expr [getLinkBandwidth $link] + 0] +# set delay [expr [getLinkDelay $link] + 0] +# set ber [expr [getLinkBER $link] + 0] +# set dup [expr [getLinkDup $link] + 0] + +# set peer1 \ +# [lindex [[typemodel $lnode1].nghook $eid $lnode1 $ifname1] 0] +# set peer2 \ +# [lindex [[typemodel $lnode2].nghook $eid $lnode2 $ifname2] 0] +# set ngpeer1 $ngnodemap($peer1) +# set ngpeer2 $ngnodemap($peer2) +# set nghook1 \ +# [lindex [[typemodel $lnode1].nghook $eid $lnode1 $ifname1] 1] +# set nghook2 \ +# [lindex [[typemodel $lnode2].nghook $eid $lnode2 $ifname2] 1] + +# puts " nexec vimage $eid ngctl mkpeer $ngpeer1: pipe $nghook1 upper " +# puts " nexec vimage $eid ngctl name $ngpeer1:$nghook1 $lname " +# puts " nexec vimage $eid ngctl connect $lname: $ngpeer2: lower $nghook2 " + +# FreeBSD-specific +# # Ethernet frame has a 14-byte header - this is a temp. hack!!! +# puts " nexec vimage $eid ngctl msg $lname: setcfg { header_offset=14 } " + +# # Link parameters +# puts " nexec vimage $eid ngctl msg $lname: setcfg +# { bandwidth=$bandwidth delay=$delay +# upstream={ BER=$ber duplicate=$dup } +# downstream={ BER=$ber duplicate=$dup } } " + +# # Queues +# foreach node [list $lnode1 $lnode2] { +# if { $node == $lnode1 } { +# set ifc $ifname1 +# } else { +# set ifc $ifname2 +# } + +# if { [nodeType $lnode1] != "rj45" && \ +# [nodeType $lnode2] != "rj45" } { +# execSetIfcQDisc $eid $node $ifc [getIfcQDisc $node $ifc] +# execSetIfcQDrop $eid $node $ifc [getIfcQDrop $node $ifc] +# execSetIfcQLen $eid $node $ifc [getIfcQLen $node $ifc] +# } +# } +# } - # XXX move those to some quagga specific script - # XXX race if starting two imunes instances simultaneously - nexec rm -fr /var/run/quagga - nexec rm -f /usr/local/etc/quagga/Quagga.conf - puts { nexec ln -s /tmp/$eid/@ /var/run/quagga } - puts { nexec ln -s /tmp/$eid/@/boot.conf /usr/local/etc/quagga/Quagga.conf } - foreach file { bgpd ospfd ospf6d ripd ripngd vtysh zebra } { - puts { nexec cp /dev/null /usr/local/etc/quagga/$file.conf } - } +# # XXX move those to some quagga specific script +# # XXX race if starting two imunes instances simultaneously +# nexec rm -fr /var/run/quagga +# nexec rm -f /usr/local/etc/quagga/Quagga.conf +# puts { nexec ln -s /tmp/$eid/@ /var/run/quagga } +# puts { nexec ln -s /tmp/$eid/@/boot.conf /usr/local/etc/quagga/Quagga.conf } +# foreach file { bgpd ospfd ospf6d ripd ripngd vtysh zebra } { +# puts { nexec cp /dev/null /usr/local/etc/quagga/$file.conf } +# } foreach node $node_list { upvar 0 ::cf::[set ::curcfg]::$node $node