From 09324e370e2852708d9b82a7949e9f98cb38108d Mon Sep 17 00:00:00 2001 From: Giuseppe Lettieri Date: Mon, 8 Oct 2012 17:22:37 +0200 Subject: [PATCH] autogenerate *.json files for gmap --- planetlab/exp-tool/Makefile | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/planetlab/exp-tool/Makefile b/planetlab/exp-tool/Makefile index da50326da..7919aa5d4 100644 --- a/planetlab/exp-tool/Makefile +++ b/planetlab/exp-tool/Makefile @@ -408,6 +408,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 -- 2.43.0