improved planetlab scripts
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Tue, 26 Jun 2012 11:25:45 +0000 (13:25 +0200)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Tue, 26 Jun 2012 11:25:45 +0000 (13:25 +0200)
planetlab/automake.mk
planetlab/scripts/Makefile
planetlab/scripts/del_bridge
planetlab/scripts/showgraph [new file with mode: 0755]

index 70c59d1..39fc465 100644 (file)
@@ -9,7 +9,8 @@ dist_sbin_SCRIPTS += \
        planetlab/scripts/create_port \
        planetlab/scripts/del_bridge \
        planetlab/scripts/del_port \
-       planetlab/scripts/Makefile
+       planetlab/scripts/Makefile \
+       planetlab/scripts/showgraph
 
 planetlab_pltap_ovs_pltap_ovs_SOURCES = \
        planetlab/pltap-ovs/pltap-ovs.c \
index ea71624..fd69127 100644 (file)
@@ -55,17 +55,11 @@ L/%: cache/link.%@1 cache/link.%@2
        @touch $@
        @echo "Created link $*"
 
-del.%: del-iface.%@1 del-iface.%@2
+U/%: del-iface.%@1 del-iface.%@2
        @rm -f L/$*
        @echo "Deleted link $*"
 
-del-iface.%:
-       @echo "Removing interface for link $(call proj1,$*) from host $(call get,$*)"
-       @ssh -l $(SLICE) $(HOST_$(call get,$*)) \
-               sudo ovs-vsctl del-port L$(call proj1,$*)
-       @rm -f cache/iface.$* cache/link.$* cache/link.$(call opp,$*)
-
-del-bridge.%:
+del-bridge.%: cache/db.%
        @echo "Deleting bridge on host $*"
        @if [ -f cache/bridge.$* ]; then \
                ssh -l $(SLICE) $(HOST_$*) \
@@ -76,23 +70,57 @@ del-bridge.%:
              cache/link.$*-*@?  cache/link.*-$*@?  \
              L/$*-*             L/*-$*
 
+del-switchd.%: del-bridge.%
+       @echo "Shutting down switchd on host $*"
+       @if [ -f cache/switchd.$* ]; then \
+               ssh -l $(SLICE) $(HOST_$*) \
+                       sudo ovs-appctl exit;\
+        fi
+       @rm -f cache/switchd.$*
+
+del-db.%:
+       @echo "Shutting down db on host $*"
+       @if [ -f cache/db.$* ]; then \
+               ssh -l $(SLICE) $(HOST_$*) \
+                       sudo ovs-appctl --target=$(VARRUN)/ovsdb-server.$$(cat cache/db.$*).ctl exit;\
+        fi
+       @rm -f cache/db.$*
+
+shutdown: del-switches del-dbs
+
 graph.dot:
        ( echo "digraph $(SLICE) {"; ls L | sed 's/-/->/;s/$$/;/'; echo "}" ) > $@
 
 graph.ps: graph.dot
        dot -Tps < $^ > $@      
 
-.PHONY: clean del-links graph.dot
+.PHONY: clean del-links graph.dot servers
 
 
 clean: $(addprefix del-,$(notdir $(wildcard cache/bridge.*)))
 
-del-links: $(addprefix del.,$(notdir $(wildcard L/*)))
+del-links: $(addprefix U/,$(notdir $(wildcard L/*)))
+
+switchds: $(wildcard cache/switchd.*)
+
+dbs: $(wildcard cache/db.*)
+
+del-switchds: $(addprefix del-,$(notdir $(wildcard cache/switchd.*)))
+
+del-dbs: $(addprefix del-,$(notdir $(wildcard cache/db.*)))
 
 .SECONDEXPANSION:
 
+del-iface.%: cache/db.$$(call get,%)
+       @echo "Removing interface for link $(call proj1,$*) from host $(call get,$*)"
+       @ssh -l $(SLICE) $(HOST_$(call get,$*)) \
+               sudo del_port L$(call proj1,$*)
+       @rm -f cache/iface.$* cache/link.$* cache/link.$(call opp,$*)
+
+
+
 cache/iface.%: cache/bridge.$$(call get,%)
-       @echo "Creating iterface for link $(call proj1,$*) on host $(call get,$*)"
+       @echo "Creating interface for link $(call proj1,$*) on host $(call get,$*)"
        @ssh -l $(SLICE) $(HOST_$(call get,$*)) \
                sudo create_port $$(cat $^) L$(call proj1,$*) > $@ \
         || { rm $@; exit 1; }
index e25ff92..d19049a 100755 (executable)
@@ -15,12 +15,11 @@ if [ -z "$1" ]; then
        error "Usage: ${0##*/} <bridge name>" 
 fi
 
-# ensure ovs-vswitchd is running
+W=
 if ! is_switch_running; then
-       echo "ovs-vswitchd not runnig" >&2
-       exit 1
+       W="--no-wait"
 fi
 
-if ovs-vsctl bridge-exists "$1"; then
-       ovs-vsctl del-br $1
+if ovs-vsctl br-exists "$1"; then
+       ovs-vsctl $W del-br $1
 fi
diff --git a/planetlab/scripts/showgraph b/planetlab/scripts/showgraph
new file mode 100755 (executable)
index 0000000..85421cb
--- /dev/null
@@ -0,0 +1,7 @@
+make graph.ps
+gv -watch -spartan graph.ps >/dev/null 2>&1 &
+while :
+do
+       inotifywait -e CREATE -e DELETE L
+       make graph.ps 
+done >/dev/null 2>&1