From c93d4b51c2808656a0e88f2679b2103903a6ab4f Mon Sep 17 00:00:00 2001 From: Giuseppe Lettieri Date: Sat, 6 Oct 2012 13:30:17 +0200 Subject: [PATCH] reduce dependency on a running switch daemon --- planetlab/exp-tool/Makefile | 3 ++- planetlab/scripts/sliver-ovs.in | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/planetlab/exp-tool/Makefile b/planetlab/exp-tool/Makefile index e54d35b61..f8ed90d06 100644 --- a/planetlab/exp-tool/Makefile +++ b/planetlab/exp-tool/Makefile @@ -260,6 +260,7 @@ cache/rsnap.links.%: .SECONDEXPANSION: del-iface.%: +del-iface.%: | cache/db.$$(call get,%) @echo "Removing interface for link $(call linkpart,$*) from $(call get,$*)" @$(SSH) $(HOST_$(call get,$*)) \ $(SUDO) sliver-ovs del-port L$(call linkpart,$*) @@ -271,7 +272,7 @@ del-iface.%: #linkid=$(call linkpart,%) #nodeid=$(call get,%) #bridgefile=cache/bridge.$(nodeid) -cache/iface.%: cache/bridge.$$(call get,%) | cache/switch.$$(call get,%) +cache/iface.%: cache/bridge.$$(call get,%) | cache/db.$$(call get,%) @echo "Creating interface for link $(call linkpart,$(*F)) on $(call display,$(call get,$(*F))) - logs in $(call log,$@)" @$(SSH) $(call solve,$(call get,$(*F))) $(SUDO) sliver-ovs create-port $(BRIDGE) \ L$(call linkpart,$(*F)) &> $(call log,$@) \ diff --git a/planetlab/scripts/sliver-ovs.in b/planetlab/scripts/sliver-ovs.in index dfcba3bbe..3e060d15c 100755 --- a/planetlab/scripts/sliver-ovs.in +++ b/planetlab/scripts/sliver-ovs.in @@ -182,24 +182,34 @@ function create_bridge () { function create_port () { get_params "bridge port" "$@" - - # ensure ovs-vswitchd is running - is_switch_running || { echo "ovs-vswitchd not running" >&2 ; exit 1 ; } + + W= + if ! is_switch_running; then + # we can create the port even if ovs-vswitchd is not running, + # but we need a running ovsdb-server + is_db_running || { echo "ovsdb-server not running" >&2; exit 1; } + W="--no-wait" + fi set -e - ovs-vsctl --db=unix:$DB_SOCKET -- --may-exist add-port "$bridge" "$port" -- set interface "$port" type=tunnel - ovs-appctl --target=ovs-vswitchd netdev-tunnel/get-port "$port" + ovs-vsctl --db=unix:$DB_SOCKET $W -- --may-exist add-port "$bridge" "$port" \ + -- set interface "$port" type=tunnel } function set_remote_endpoint () { get_params "local_port remote_ip remote_UDP_port" "$@" - # ensure ovs-vswitchd is running - is_switch_running || { echo "ovs-vswitchd not running" >&2 ; exit 1 ; } + W= + if ! is_switch_running; then + # we can store the info even if ovs-vswitchd is not running, + # but we need a running ovsdb-server + is_db_running || { echo "ovsdb-server not running" >&2; exit 1; } + W="--no-wait" + fi set -e - ovs-vsctl --db=unix:$DB_SOCKET set interface $local_port \ + ovs-vsctl --db=unix:$DB_SOCKET $W set interface $local_port \ options:remote_ip=$remote_ip \ options:remote_port=$remote_UDP_port } -- 2.43.0