From 4a40a064745e87fad6c6b16b38b41394ed3ac743 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 11 Sep 2012 15:01:33 +0200 Subject: [PATCH] use sliver-ovs to stop stuff as well --- planetlab/exp-tool/Makefile | 18 +++++++----------- planetlab/scripts/sliver-ovs | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/planetlab/exp-tool/Makefile b/planetlab/exp-tool/Makefile index 5986216b2..c89f197b3 100644 --- a/planetlab/exp-tool/Makefile +++ b/planetlab/exp-tool/Makefile @@ -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 diff --git a/planetlab/scripts/sliver-ovs b/planetlab/scripts/sliver-ovs index 026e6b4b9..6a7319843 100755 --- a/planetlab/scripts/sliver-ovs +++ b/planetlab/scripts/sliver-ovs @@ -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') -- 2.43.0