Merge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Tue, 11 Sep 2012 07:49:04 +0000 (09:49 +0200)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Tue, 11 Sep 2012 07:49:04 +0000 (09:49 +0200)
Conflicts:
planetlab/scripts/sliver-ovs

planetlab/exp-tool/Makefile
planetlab/scripts/sliver-ovs

index a9af02d..d25a440 100644 (file)
@@ -36,7 +36,8 @@ else
 SSH_KEY_OPTION ?= -i $(SSH_KEY)
 endif
 
-SSH_OPTIONS ?= $(SSH_KEY_OPTION) -l $(SLICE) -t
+#SSH_OPTIONS ?= $(SSH_KEY_OPTION) -l $(SLICE) -t
+SSH_OPTIONS ?= $(SSH_KEY_OPTION) -l $(SLICE)
 SSH = ssh $(SSH_OPTIONS)
 
 SUDO ?= sudo -S
@@ -63,7 +64,9 @@ showslice: ++SLICE FORCE
 
 shownodes:
        @$(foreach id,$(ALL_NODE_IDS),echo $(id)=$(call display,$(id));)
-.PHONY: shownodes
+showips:
+       @$(foreach id,$(ALL_NODE_IDS),echo $(id)=$(call display,$(id)) has ip/network set to $(IP_$(id));)
+.PHONY: shownodes showips
 
 sshchecks: $(foreach id,$(ALL_NODE_IDS),cache/sshcheck.$(id))
 .PHONY: sshchecks
@@ -108,7 +111,7 @@ cache/switch.%: cache/db.%
 
 cache/bridge.%: cache/switch.%
        @echo "Creating bridge on $(call display,$*) - logs in $@.log"
-       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs create-bridge $(IP_$*) > $@.log && touch $@
+       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs create-bridge $(IP_$*) > $@ 2> $@.log || { rm $@; exit 1; }
 
 # xxx this probably needs a more thorough cleanup in cache/
 cache/stop.%: del-bridge.%
@@ -195,6 +198,26 @@ cache/link.%: cache/host.$$(call rget,$$*) cache/iface.% cache/iface.$$(call opp
                        options:remote_port=$$(cat cache/iface.$(call opp,$*)) \
         && touch $@
 
+####################
+# 'virtual' targets in that there's no real file attached
+define node_shortcuts
+sshcheck.$(1): cache/sshcheck.$(1) FORCE
+db.$(1): cache/db.$(1) FORCE
+switch.$(1): cache/switch.$(1) FORCE
+start.$(1): cache/start.$(1) FORCE
+stop.$(1): cache/stop.$(1) FORCE
+status.$(1): cache/status.$(1) FORCE
+bridge.$(1): cache/bridge.$(1) FORCE
+# switch already depends on db, but well
+cache/start.$(1): cache/db.$(1) cache/switch.$(1) FORCE
+endef
+
+$(foreach id,$(ALL_NODE_IDS), $(eval $(call node_shortcuts,$(id))))
+
+#define link_shortcuts
+#
+#endef
+
 #################### convenience, for debugging only
 # make +foo : prints the value of $(foo)
 # make ++foo : idem but verbose, i.e. foo=$(foo)
index 0f6c402..44ad3f9 100755 (executable)
@@ -181,7 +181,7 @@ function create_bridge () {
        $PREFIX
 EOF
     wait_device $TAPNAME 60 && \
-       ovs-vsctl --db=$DB_SOCKET add-br $TAPNAME -- set bridge $TAPNAME datapath_type=planetlab
+       ovs-vsctl --db=unix:$DB_SOCKET add-br $TAPNAME -- set bridge $TAPNAME datapath_type=planetlab
     echo $TAPNAME
     return 0
 }
@@ -197,8 +197,8 @@ function create_port () {
     is_switch_running || { echo "ovs-vswitchd not running" >&2 ; exit 1 ; }
 
     set -e
-    if ! ovs-vsctl --db=$DB_SOCKET list-ports "$bridge" | grep -q "^$port\$"; then
-       ovs-vsctl --db=$DB_SOCKET add-port "$bridge" "$port" -- set interface "$port" type=tunnel
+    if ! ovs-vsctl --db=unix:$DB_SOCKET list-ports "$bridge" | grep -q "^$port\$"; then
+       ovs-vsctl --db=unix:$DB_SOCKET add-port "$bridge" "$port" -- set interface "$port" type=tunnel
     fi
     ovs-appctl --target=$SWITCH_SOCKET netdev-tunnel/get-port "$port"
     return 0
@@ -219,9 +219,8 @@ function del_bridge () {
        W="--no-wait"
     fi
 
-    set -e
-    if ovs-vsctl --db=$DB_SOCKET $W br-exists "$bridge_name"; then
-       ovs-vsctl --db=$DB_SOCKET $W del-br $bridge_name
+    if ovs-vsctl --db=unix:$DB_SOCKET br-exists "$bridge_name"; then
+       ovs-vsctl --db=unix:$DB_SOCKET $W del-br $bridge_name
     fi
     return 0
 }
@@ -240,8 +239,8 @@ function del_port () {
     fi
 
     set -e
-    if ovs-vsctl --db=$DB_SOCKET $W port-to-br "$1" >/dev/null 2>&1; then
-       ovs-vsctl --db=$DB_SOCKET $W del-port "$1"
+    if ovs-vsctl --db=unix:$DB_SOCKET port-to-br "$1" >/dev/null 2>&1; then
+       ovs-vsctl --db=unix:$DB_SOCKET $W del-port "$1"
     fi
     return 0
 }