# puts " nexec vimage $eid ngctl connect $lname: $ngpeer2: lower $nghook2 "
# puts ">>>>>>>>>>kreiranje linkova"
- set host_if_a $ngpeer1
- set host_if_b $ngpeer2
- set bridge $lname
+
- puts "\nCreating bridge $bridge"
- nexec brctl addbr $bridge
- nexec brctl addif $bridge $host_if_a
- nexec brctl addif $bridge $host_if_b
- nexec ifconfig $bridge up
- puts " Bridge $bridge is up, connected interfaces $host_if_a and $host_if_b"
+ if { [[typemodel $lnode1].layer] == "LINK" || [[typemodel $lnode2].layer] == "LINK" } {
+ #slucaj kad se spaja na L2 uredjaj (hub)
+
+ if { [[typemodel $lnode1].layer] == "LINK" } {
+ set port_if $ngpeer2
+ set bridge $lnode1
+ } else {
+ set port_if $ngpeer1
+ set bridge $lnode2
+ }
+
+ puts "\nCreating bridge $bridge (L2 hub emulation)"
+
+ nexec brctl addbr $bridge
+ nexec brctl addif $bridge $port_if
+ nexec ifconfig $bridge up
+ puts " L2 device $bridge is up, connected interface port_if"
+
+ } else {
+ # Slucaj kad se radi link izmedju dva L3 uredjaja (standardno)
+ set host_if_a $ngpeer1
+ set host_if_b $ngpeer2
+ set bridge $lname
+
+ puts "\nCreating bridge $bridge"
+
+ nexec brctl addbr $bridge
+ nexec brctl addif $bridge $host_if_a
+ nexec brctl addif $bridge $host_if_b
+ nexec ifconfig $bridge up
+ puts " Bridge $bridge is up, connected interfaces $host_if_a and $host_if_b"
+ }
# FreeBSD-specific
# # Ethernet frame has a 14-byte header - this is a temp. hack!!!
# OpenVZ - samo nam treba popis nodeova za pogasiti
upvar 0 ::cf::[set ::curcfg]::node_list node_list
+ puts "Stopping VEs and destroying private enviroments..."
foreach node $node_list {
- set stattxt "Stopping VE $node"
- statline $stattxt
- nexec vzctl stop $node
- set stattxt "Destroying VE $node"
- statline $stattxt
- nexec vzctl destroy $node
+ if { [[typemodel $node].layer] != "LINK" } {
+ set stattxt "Stopping VE $node"
+ statline $stattxt
+ nexec vzctl stop $node
+ set stattxt "Destroying VE $node"
+ statline $stattxt
+ nexec vzctl destroy $node
+ } else {
+ # L2 uredjaji kao hub i switch se u OpenVZ varijanti emulirajusa bridge
+ # suceljem a ne sa VEom, stoga nema se sta gasiti
+ puts " Node $node is a L2 device emulated with a bridge. Stopping pending bridge cleanup."
}
-
+ }
+ puts " Done."
#TODO: prebaciti u tcl kod, error handling i modificirati da ne
# brise bridgeove bez diskriminacije nego one koje je imunes
# napravio
puts "\nBridge cleanup in main host"
catch { nexec ./bridge_cleanup.sh }
+ puts " Done."
# FreeBSD metoda:
--- /dev/null
+#
+# Copyright 2005-2008 University of Zagreb, Croatia.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# This work was supported in part by Croatian Ministry of Science
+# and Technology through the research contract #IP-2003-143.
+#
+
+# $Id: hub.tcl,v 1.15 2009/03/17 14:35:19 marko Exp $
+
+
+#****h* imunes/hub.tcl
+# NAME
+# hub.tcl -- defines hub specific procedures
+# FUNCTION
+# This module is used to define all the hub specific procedures.
+# NOTES
+# Procedures in this module start with the keyword hub and
+# end with function specific part that is the same for all the
+# node types that work on the same layer.
+#****
+
+set MODULE hub
+
+#****f* hub.tcl/hub.layer
+# NAME
+# hub.layer
+# SYNOPSIS
+# set layer [hub.layer]
+# FUNCTION
+# Returns the layer on which the hub operates
+# i.e. returns LINK.
+# RESULT
+# * layer -- set to LINK
+#****
+
+proc $MODULE.layer {} {
+ return LINK
+}
+
+#****f* hub.tcl/hub.instantiate
+# NAME
+# hub.instantiate
+# SYNOPSIS
+# hub.instantiate $eid $node_id
+# FUNCTION
+# Procedure hub.instantiate cretaes a new netgraph node
+# of the type hub. The name of the netgraph node is in form
+# of exprimentId_nodeId.
+# INPUTS
+# * eid - experiment id
+# * node_id - id of the node (type of the node is hub)
+#****
+
+proc $MODULE.instantiate { eid node } {
+ upvar 0 ::cf::[set ::curcfg]::ngnodemap ngnodemap
+ puts "\nhub.INSTANTIATE"
+ #puts " catch {exec vimage $eid ngctl mkpeer hub anchor anchor | tail -1} resp"
+ #puts " catch {exec vimage $eid ngctl l | fgrep \" Name: <unnamed>\" | cut -c51-58 | xargs echo } nglist"
+ #set id [lindex $nglist 0]
+
+ #puts " >>> id = $id"
+ #puts " catch {exec vimage $eid ngctl name \[$id\]: $node}"
+ set ngnodemap($eid\.$node) $node
+ puts " >>>$eid\.$node $node"
+}
+
+#****f* hub.tcl/hub.start
+# NAME
+# hub.start
+# SYNOPSIS
+# hub.start $eid $node_id
+# FUNCTION
+# Starts a new hub. Since hub has no starting code,
+# this procedure does nothing.
+# INPUTS
+# * eid - experiment id
+# * node_id - id of the node (type of the node is hub)
+#****
+proc $MODULE.start { eid node } {
+}
+
+#****f* hub.tcl/hub.shutdown
+# NAME
+# hub.shutdown
+# SYNOPSIS
+# hub.shutdown $eid $node_id
+# FUNCTION
+# Shutdowns a hub. Since hub has no shutdown code,
+# this procedure does nothing.
+# INPUTS
+# * eid - experiment id
+# * node_id - id of the node (type of the node is hub)
+#****
+proc $MODULE.shutdown { eid node } {
+}
+
+#****f* hub.tcl/hub.destroy
+# NAME
+# hub.destroy
+# SYNOPSIS
+# hub.destroy $eid $node_id
+# FUNCTION
+# Destroys a hub. Destroys the netgraph node that represents
+# the hub by sending a shutdown message.
+# INPUTS
+# * eid - experiment id
+# * node_id - id of the node (type of the node is hub)
+#****
+proc $MODULE.destroy { eid node } {
+ catch { nexec vimage $eid ngctl msg $node: shutdown }
+}
+
+#****f* hub.tcl/hub.nghook
+# NAME
+# hub.nghook
+# SYNOPSIS
+# hub.nghook $eid $node_id $ifc
+# FUNCTION
+# Returns the id of the netgraph node and the name of the
+# netgraph hook which is used for connecting two netgraph
+# nodes. Netgraph node name is in format experimentId_nodeId
+# and the netgraph hook is in the form of linkN, where N is
+# interface number.
+# INPUTS
+# * eid - experiment id
+# * node_id - node id
+# * ifc - interface name
+# RESULT
+# * nghook - the list containing netgraph node id and the
+# netgraph hook (ngNode ngHook).
+#****
+
+proc $MODULE.nghook { eid node ifc } {
+ set ifunit [string range $ifc 1 end]
+ return [list $eid\.$node link$ifunit]
+}