X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fexp-tool%2FMakefile;h=dc5446664efaf23c77c1eb8d63ac4c25fcdbdd8a;hb=e11741625af584cbc4eba13eea0a2ad1495fb4e0;hp=c2b0d77095e7128e176c936d84d47eca8d11cae0;hpb=71ae087e8c5d196e27a583ba73dae383c37d1795;p=sliver-openvswitch.git diff --git a/planetlab/exp-tool/Makefile b/planetlab/exp-tool/Makefile index c2b0d7709..dc5446664 100644 --- a/planetlab/exp-tool/Makefile +++ b/planetlab/exp-tool/Makefile @@ -104,6 +104,9 @@ sshs: $(foreach id,$(ALL_NODE_IDS),ssh-$(id)) showdpids: $(foreach id,$(ALL_NODE_IDS),showdpid-$(id)) .PHONY: showdpids +showports: $(foreach id,$(ALL_NODE_IDS),showports-$(id)) +.PHONY: showports + DBS=$(foreach id,$(ALL_NODE_IDS),cache/db.$(id)) dbs: $(DBS) .PHONY: dbs @@ -147,6 +150,11 @@ ssh-%: FORCE showdpid-%: FORCE @echo $*_DPID=0x$$( $(SSH) $(HOST_$*) $(SUDO) ovs-vsctl get bridge $(BRIDGE) datapath_id | sed -e 's,",,g') +showports-%: FORCE + @$(SSH) $(HOST_$*) $(SUDO) ovs-ofctl show $(BRIDGE) \ + | perl -nle '/(\d+)\(L(.*?)\Q$(SEP)\E(.*?)\):/ && \ + print "PORT_".("$$2" eq "$*" ? "$$2_$$3" : "$$3_$$2")."=$$1"' + # should probably replace sshcheck cache/status.%: FORCE @echo "=== DB and SWITCH processes on $(call display,$*)" @@ -168,12 +176,12 @@ cache/bridge.%: | cache/db.% @echo "Creating bridge on $(call display,$*) - logs in $(call log,$@)" @$(SSH) $(HOST_$*) $(SUDO) \ sliver-ovs create-bridge $(BRIDGE) $(IP_$*) $(call default,BROPTIONS,$*) &> $(call log,$@) \ - && touch $@ + && { echo "IP_$*=$(IP_$*)"; echo "BROPTIONS_$*=$(call default,BROPTIONS,$*)"; } > $@ cache/controller.%: cache/bridge.% @echo "Setting controller $(call default,CONTROLLER,$*) on $(call display,$*) - logs in $(call log,$@)" @$(SSH) $(HOST_$*) $(SUDO) ovs-vsctl set-controller $(BRIDGE) $(call default,CONTROLLER,$*) &> $(call log,$@) \ - && touch $@ + && echo "CONTROLLER_$*=$(call default,CONTROLLER,$*)" > $@ # xxx this probably needs a more thorough cleanup in cache/ cache/stop.%: del-bridge.% @@ -265,6 +273,12 @@ shutdown: del-switchs del-dbs ### snapshots +snapshot: + @echo BRIDGE=$(BRIDGE) + @cat cache/bridge.* 2>/dev/null || : + @cat cache/controller.* 2>/dev/null || : + @ls L | sed 's/^/LINKS += /' + remote-snapshot: remote-snapshot-ips remote-snapshot-links @true @@ -274,6 +288,19 @@ remote-snapshot-ips: $(addprefix cache/rsnap.ip.,$(CONF_NODE_IDS)) remote-snapshot-links: $(addprefix cache/rsnap.links.,$(CONF_NODE_IDS)) @sort -u /dev/null $^ +.PHONY: remote-snapshot remote-snapshot-ips remote-snapshot-links + + +cache/rsnap.ip.%: FORCE + @$(SSH) $(HOST_$*) $(SUDO) \ + sliver-ovs get-local-ip $(BRIDGE) | sed 's/^/IP_$*=/' > $@ \ + || { rm $@; exit 1; } + +cache/rsnap.links.%: FORCE + @$(SSH) $(HOST_$*) $(SUDO) \ + sliver-ovs get-local-links $(BRIDGE) | sed -n 's/^L/LINKS += /p' > $@ \ + || { rm $@; exit 1; } + ### update sliver-ovs update: $(addprefix update-,$(CONF_NODE_IDS)) @true @@ -285,19 +312,6 @@ update-%: FORCE @scp -q $(SLIVER_OVS) $(SLICE)@$(call solve,$*): @$(SSH) $(call solve,$*) $(SUDO) mv $(notdir $(SLIVER_OVS)) /usr/sbin/sliver-ovs -.PHONY: remote-snapshot remote-snapshot-ips remote-snapshot-links - -cache/rsnap.ip.%: - @$(SSH) $(HOST_$*) $(SUDO) ovs-vsctl -- \ - get interface $(BRIDGE) options:local_ip options:local_netmask |\ - sed -n 's|"||g;1h;2{G;s|\(.*\)\n\(.*\)|IP_$* = \2/\1|p}' > $@ || \ - { rm $@; exit 1; } - -cache/rsnap.links.%: - @$(SSH) $(HOST_$*) $(SUDO) ovs-vsctl list-ifaces $(BRIDGE) | \ - sed -n 's/^L/LINKS += /p' > $@ || \ - { rm $@; exit 1; } - .SECONDEXPANSION: # del-iface.-@: @@ -349,7 +363,7 @@ cache/iface.%: cache/bridge.$$(call get,%) | cache/db.$$(call get,%) cache/port.%: cache/iface.% cache/switch.$$(call get,%) @echo "Getting port number for link $(call linkpart,$(*F)) on $(call display,$(call get,$(*F))) - logs in $(call log,$@)" @$(SSH) $(call solve,$(call get,$(*F))) $(SUDO) \ - ovs-appctl netdev-tunnel/get-port L$(call linkpart,$(*F)) > $@ 2> $(call log,$@) \ + sliver-ovs get-local-endpoint L$(call linkpart,$(*F)) > $@ 2> $(call log,$@) \ || { rm $@; exit 1; } @@ -402,6 +416,53 @@ gprobe-%: FORCE $(SSH) -n $(call solve,$(word 2,$(subst @, ,$(*F)))) $(SUDO) \ sliver-ovs gmap-probe L$(word 1,$(subst @, ,$(*F))) $(GMAP_SERVER) $(word 3,$(subst @, ,$(*F))) $(word 4,$(subst @, ,$(*F))) +jsons: routers.json links.json geocode.json +.PHONE: jsons + +routers.json: $(CONF) + @{ echo "["; \ + sep=" "; \ + for n in $(CONF_NODE_IDS); do \ + echo " $$sep\"$$n\""; \ + sep=", "; \ + done; \ + echo "]"; \ + } > $@ + +links.json: $(foreach l,$(LINKS),cache/json.$(l)) + @{ echo "["; \ + cat $^ | sed '2,$$s/^/, /'; \ + echo "]"; \ + } > $@ + +cache/json.%: $(CONF) + @echo "{\"id\": $($*_linkid), \"start\": \"$(call get,$*@1)\", \"end\": \"$(call get,$*@2)\"}" > $@ + +geocode.json: $(foreach n,$(CONF_NODE_IDS),cache/geocode.$(n)) + @{ echo "{"; \ + sep=" "; \ + for f in $^; do \ + echo -n "$$sep"; \ + cat $$f; \ + sep=", "; \ + done; \ + echo "}"; \ + } > $@ + +cache/geocode.%: cache/loc.% $(CONF) + @{ echo "\"$*\": {"; \ + echo " \"name\": \"$(HOST_$*)\","; \ + echo " \"shortname\": \"$*\","; \ + echo " \"site\": \"\","; \ + echo " \"backbone\": false,"; \ + echo " \"position\": [ $(shell cat cache/loc.$*) ]"; \ + echo " }"; \ + } > $@ + +cache/loc.%: $(CONF) + @wget -O - 'http://freegeoip.net/csv/$(HOST_$*)' | \ + awk -F, '{ printf "%s, %s\n", $$8, $$9 }' > $@ + #################### # 'virtual' targets in that there's no real file attached define node_shortcuts