use sliver-ovs to stop stuff as well
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 11 Sep 2012 13:01:33 +0000 (15:01 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 11 Sep 2012 13:01:33 +0000 (15:01 +0200)
planetlab/exp-tool/Makefile
planetlab/scripts/sliver-ovs

index 5986216..c89f197 100644 (file)
@@ -161,25 +161,21 @@ del-bridge.%: cache/db.%
 
 del-switch.%: del-bridge.%
        @echo "Shutting down switch on $(call display,$*)"
-       @if [ -f cache/switch.$* ]; then \
-               $(SSH) $(HOST_$*) $(SUDO) ovs-appctl exit;\
-        fi
+       @[ -f cache/switch.$* ] && $(SSH) $(HOST_$*) $(SUDO) sliver-ovs stop-switch
        @rm -f cache/switch.$*
 
 del-db.%:
        @echo "Shutting down db on $(call display,$*)"
-       @if [ -f cache/db.$* ]; then \
-               $(SSH) $(HOST_$*) $(SUDO) ovs-appctl --target=$(VARRUN)/ovsdb-server.$$(cat cache/db.$*).ctl exit;\
-        fi
+       @[ -f cache/db.$* ] && $(SSH) $(HOST_$*) $(SUDO) sliver-ovs stop-db
        @rm -f cache/db.$*
 
-del-links: $(addprefix U/,$(notdir $(wildcard L/*)))
+del-links: $(addprefix U/,$(notdir $(filter-out %.log,$(wildcard L/*))))
 
-del-switchs: $(addprefix del-,$(notdir $(wildcard cache/switch.*)))
+del-switchs: $(addprefix del-,$(notdir $(filter-out %.log,$(wildcard cache/switch.*))))
 
-del-dbs: $(addprefix del-,$(notdir $(wildcard cache/db.*)))
+del-dbs: $(addprefix del-,$(notdir $(filter-out %.log,$(wildcard cache/db.*))))
 
-shutdown: del-switches del-dbs
+shutdown: del-switchs del-dbs
 
 .PHONY: del-links del-switchs del-dbs shutdown
 
@@ -216,7 +212,7 @@ cache/link.%: cache/host.$$(call get,%) cache/iface.% cache/iface.$$(call opp,%)
         && touch $@
 
 ####################
-CLEANTARGETS=$(addprefix del-,$(notdir $(wildcard cache/bridge.*)))
+CLEANTARGETS=$(addprefix del-,$(notdir $(filter-out %.log,$(wildcard cache/bridge.*))))
 clean: $(CLEANTARGETS)
 distclean:
        rm -rf L U cache
index 026e6b4..6a73198 100755 (executable)
@@ -11,6 +11,7 @@ DB_CONF_FILE=/etc/openvswitch/conf.db
 DB_SCHEMA=/usr/share/openvswitch/vswitch.ovsschema
 DB_PID_FILE=/var/run/openvswitch/db.pid
 DB_LOG=/var/log/ovs-db.log
+DB_CTL_PATTERN='ovsdb-server.*.ctl'
 ##
 DB_SOCKET=/var/run/openvswitch/db.sock
 ##
@@ -99,11 +100,9 @@ function start_db () {
        echo 'ovsdb-server appears to be running already, *not* starting'
     fi
     wait_server $DB_PID_FILE ovsdb-server 30
+    echo $DB_PID_FILE
 }
 
-function stop_db () { pkill ovsdb-server; }
-
-
 function start_switch () {
 
     [[ -n "$@" ]] && error "Usage: $COMMAND start-switch"
@@ -121,7 +120,17 @@ function start_switch () {
     wait_server $SWITCH_PID_FILE ovs-vswitchd 30
 }
 
-function stop_switch () { pkill ovs-vswitchd ; }
+# first dumb stab just read "pkill ovsdb-server" and "pkill ovs-vswitchd"
+# quick and dirty : we locate the control file through a search in /var/run
+# caller should be requested to remember and provide this pid instead
+function stop_db () { 
+    controlfile=$(ls $RUN_DIR/$DB_CTL_PATTERN)
+    [ -f $controlfile ] && ovs-appctl --target=$controlfile exit 
+}
+
+function stop_switch () { 
+    ovs-appctl --target=$SWITCH_SOCKET exit || :
+}
 
 function status () {
     pids=$(pgrep '^ovs')