ache/bridge.% needs to contain the ifname
[sliver-openvswitch.git] / planetlab / exp-tool / Makefile
index d880cd6..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
@@ -74,29 +77,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_$*) > $@ 2> $@.log || { rm $@; exit 1; }
 
-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
@@ -178,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)