X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fscripts%2Fsliver-ovs.in;h=edda1961b9a89b6dd19dd25ab821d5db107b1f97;hb=2b13d312fc4d6e5eb1d0e3004fa523bb0c0ba544;hp=1a63bf02e4df8b13ef94e6d8e6b6c98268dfd416;hpb=62b6fe80822a34182cccad23cb62c35434a95dd9;p=sliver-openvswitch.git diff --git a/planetlab/scripts/sliver-ovs.in b/planetlab/scripts/sliver-ovs.in index 1a63bf02e..edda1961b 100755 --- a/planetlab/scripts/sliver-ovs.in +++ b/planetlab/scripts/sliver-ovs.in @@ -67,10 +67,10 @@ function wait_server () { } function wait_device () { - tapname=$1; shift - timeout=$1; shift + local tapname=$1; shift + local timeout=$1; shift - expire=$(($(date +%s) + $timeout)) + local expire=$(($(date +%s) + $timeout)) while ! ip link show up | egrep -q "^[0-9]+: +$tapname:"; do echo "Waiting for $tapname to come UP...$(($expire - $(date +%s)))s left" >&2 @@ -100,10 +100,10 @@ function start_db () { if [ ! -f "$RUN_DIR/ovsdb-server.pid" ]; then ovsdb-server $DB_CONF_FILE \ --remote=punix:$DB_SOCKET \ - --remote=db:Open_vSwitch,manager_options \ - --private-key=db:SSL,private_key \ - --certificate=db:SSL,certificate \ - --bootstrap-ca-cert=db:SSL,ca_cert \ + --remote=db:Open_vSwitch,Open_vSwitch,manager_options \ + --private-key=db:Open_vSwitch,SSL,private_key \ + --certificate=db:Open_vSwitch,SSL,certificate \ + --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \ --pidfile \ --log-file=$DB_LOG \ --detach >& /dev/null @@ -177,6 +177,12 @@ function create_bridge () { -- set bridge "$bridge" datapath_type=planetlab \ -- set interface "$bridge" options:local_ip="$IP" option:local_netmask="$PREFIX" \ -- "$@" + + # check that the bridge has actually been created + if [ -z "$W" ]; then + local tap=$(ovs-appctl netdev-pltap/get-tapname "$bridge") + wait_device $tap 10 + fi } function create_port () { @@ -306,6 +312,15 @@ function get_local_links () { ovs-vsctl --db=unix:$DB_SOCKET list-ifaces "$bridge" } +function get_mac () { + + get_params "bridge" "$@" + + set -e + local tap=$(ovs-appctl netdev-pltap/get-tapname "$bridge") + ifconfig "$tap" | awk '/HWaddr/ { print $5 }' +} + ### for demos - connect to an ndnmap deployment to visualize links bandwidth # this expects 3 arguments # an interface name, L- based on your ids in conf.mk @@ -353,32 +368,13 @@ function gmap_probe () { echo $! > $pid_file } -#################### -# xxx tmp for a demo -# there *must* be a better way to do that -# the thing is the slice sees several tap devices at this point, which is odd... -# for now I'm searching the tapname based on some hint - the vnet ip range -VNET=10.0.16 -function show_mac () { - ifnames=$(grep : /proc/net/dev | cut -d: -f1 | awk '{print $1;}') - tapname="" - for ifname in $ifnames; do - ifconfig $ifname | grep -q "$VNET" && tapname=$ifname - done - if [ -z "$tapname" ] ; then - echo "no-tap-found-for$VNET" - exit 1 - fi - ifconfig $tapname | grep -i hwaddr | awk '{print $5;}' -} - #################### 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 -get_local_ip get_local_links show_mac" +get_local_ip get_local_links get_mac" function main () { message="Usage: $COMMAND ...