move remote-snapshot recipes to sliver-ovs
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Mon, 8 Oct 2012 11:38:04 +0000 (13:38 +0200)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Mon, 8 Oct 2012 11:38:04 +0000 (13:38 +0200)
planetlab/exp-tool/Makefile
planetlab/scripts/sliver-ovs.in

index eac14e2..2f251df 100644 (file)
@@ -274,6 +274,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 +298,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.<node_id>-<node_id>@<endpoint>:
index 2c9b062..50ecab8 100755 (executable)
@@ -286,6 +286,26 @@ function show () {
     ovs-vsctl --db=unix:$DB_SOCKET show
 }
 
+function get_local_ip () {
+
+    get_params "bridge" "$@"
+
+    set -e
+    ovs-vsctl --db=unix:$DB_SOCKET br-exists "$bridge" || return
+    local ip=$(ovs-vsctl get interface "$bridge" options:local_ip)
+    local netmask=$(ovs-vsctl get interface "$bridge" options:local_netmask)
+    eval echo $ip/$netmask
+}
+
+function get_local_links () {
+
+    get_params "bridge" "$@"
+
+    set -e
+    ovs-vsctl --db=unix:$DB_SOCKET br-exists "$bridge" || return
+    ovs-vsctl --db=unix:$DB_SOCKET list-ifaces "$bridge"
+}
+
 ### for demos - connect to an ndnmap deployment to visualize links bandwidth
 # this expects 3 arguments
 # an interface name, L<id1>-<id2> based on your ids in conf.mk
@@ -338,7 +358,8 @@ SUPPORTED_SUBCOMMANDS="start stop status
 start_db stop_db start_switch stop_switch
 create_bridge create_port del_bridge del_port
 show get_local_endpoint set_remote_endpoint
-set_controller del_controller gmap_probe"
+set_controller del_controller gmap_probe
+get_local_ip get_local_links"
 
 function main () {
        message="Usage: $COMMAND <subcommand> ...