From: Giuseppe Lettieri Date: Tue, 11 Sep 2012 07:49:04 +0000 (+0200) Subject: Merge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch X-Git-Tag: sliver-openvswitch-1.8.90-0~23 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=a175924ab2c8eaf52ab5ed8a64a3eff7f569758c;p=sliver-openvswitch.git Merge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch Conflicts: planetlab/scripts/sliver-ovs --- a175924ab2c8eaf52ab5ed8a64a3eff7f569758c diff --cc planetlab/scripts/sliver-ovs index 0f6c402fc,e25959b24..44ad3f969 --- a/planetlab/scripts/sliver-ovs +++ b/planetlab/scripts/sliver-ovs @@@ -193,12 -184,9 +193,12 @@@ function create_port () port=$1; shift [[ -n "$@" ]] || error "$COMMAND create-port " + # ensure ovs-vswitchd is running + is_switch_running || { echo "ovs-vswitchd not running" >&2 ; exit 1 ; } + set -e - if ! ovs-vsctl --db=$DB_SOCKET list-ports "$bridge" | grep -q "^$port\$"; then - ovs-vsctl --db=$DB_SOCKET add-port "$bridge" "$port" -- set interface "$port" type=tunnel + if ! ovs-vsctl --db=unix:$DB_SOCKET list-ports "$bridge" | grep -q "^$port\$"; then + ovs-vsctl --db=unix:$DB_SOCKET add-port "$bridge" "$port" -- set interface "$port" type=tunnel fi ovs-appctl --target=$SWITCH_SOCKET netdev-tunnel/get-port "$port" return 0 @@@ -212,16 -200,10 +212,15 @@@ function del_bridge () [[ -n "$@" ]] && error "Usage: ${COMMAND} del-bridge " W= - is_switch_running || W="--no-wait" + if ! is_switch_running; then + # we can delete the bridge 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 - if ovs-vsctl --db=$DB_SOCKET $W br-exists "$bridge_name"; then - ovs-vsctl --db=$DB_SOCKET $W del-br $bridge_name + if ovs-vsctl --db=unix:$DB_SOCKET br-exists "$bridge_name"; then + ovs-vsctl --db=unix:$DB_SOCKET $W del-br $bridge_name fi return 0 } @@@ -231,17 -213,9 +230,17 @@@ function del_port () bridge_name=$1; shift [[ -n "$@" ]] && error "Usage: ${COMMAND} del-port " + W= + if ! is_switch_running; then + # we can delete 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 - if ovs-vsctl --db=$DB_SOCKET $W port-to-br "$1" >/dev/null 2>&1; then - ovs-vsctl --db=$DB_SOCKET $W del-port "$1" + if ovs-vsctl --db=unix:$DB_SOCKET port-to-br "$1" >/dev/null 2>&1; then - ovs-vsctl --db=unix:$DB_SOCKET del-port "$1" ++ ovs-vsctl --db=unix:$DB_SOCKET $W del-port "$1" fi return 0 }