add global start stop status targets for handling db+switch
[sliver-openvswitch.git] / planetlab / exp-tool / Makefile
index d880cd6..a9af02d 100644 (file)
@@ -74,29 +74,46 @@ dbs: $(foreach id,$(ALL_NODE_IDS),cache/db.$(id))
 switchs: $(foreach id,$(ALL_NODE_IDS),cache/switch.$(id))
 .PHONY: switchs
 
+start: dbs switchs
+.PHONY: start
+
+stop:$(foreach id,$(ALL_NODE_IDS),cache/stop.$(id))
+.PHONY: stop
+
+status:$(foreach id,$(ALL_NODE_IDS),cache/status.$(id))
+.PHONY: status
+
 ### node-oriented targets
+# check ssh connectivity
+cache/sshcheck.%: FORCE
+       @if $(SSH) $(HOST_$*) hostname 2> /dev/null; then echo "ssh on" $(call display,$*) "OK" ; \
+        else echo "ssh on" $(call display,$*) "KO !!!"; fi
+
+# should probably replace sshcheck
+cache/status.%: FORCE
+       @echo "=== DB and SWITCH processes on $(call display,$*)"
+       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs status
+
 cache/host.%:
        @echo "IP lookup for $(call display,$*)"
        @host $(HOST_$*) | sed -n 's/^.*has address *//p' > $@
 
 cache/db.%:
-       @echo "Starting db server on $(call display,$*)"
-       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs start-db > $@ \
-        || { rm $@; exit 1; }
+       @echo "Starting db server on $(call display,$*) - logs in $@.log"
+       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs start-db &> $@.log && touch $@
 
 cache/switch.%: cache/db.%
-       @echo "Starting vswitchd on $(call display,$*)"
-       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs start-switch > $@ \
-        || { rm $@; exit 1; }
+       @echo "Starting vswitchd on $(call display,$*) - logs in $@.log"
+       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs start-switch &> $@.log && touch $@
 
 cache/bridge.%: cache/switch.%
-       @echo "Creating bridge on $(call display,$*)"
-       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs create-bridge $(IP_$*) > $@ \
-        || { rm $@; exit 1; }
+       @echo "Creating bridge on $(call display,$*) - logs in $@.log"
+       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs create-bridge $(IP_$*) > $@.log && touch $@
 
-cache/sshcheck.%: FORCE
-       @if $(SSH) $(HOST_$*) hostname 2> /dev/null; then echo "ssh on" $(call display,$*) "OK" ; \
-        else echo "ssh on" $(call display,$*) "KO !!!"; fi
+# xxx this probably needs a more thorough cleanup in cache/
+cache/stop.%: del-bridge.%
+       @echo "Stopping switch & db on $(call display,$*)"
+       @$(SSH) $(HOST_$*) $(SUDO) sliver-ovs stop && rm cache/switch.% cache/db.%
 
 ### link-oriented targets
 L/%: cache/link.%@1 cache/link.%@2