Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | bridge="$1" |
| 3 | controller="$2" |
| 4 | if [ x"$bridge" = "x" ]; then |
| 5 | bridge="br0" |
| 6 | fi |
| 7 | if [ x"$controller" = "x" ]; then |
| 8 | controller=$ONOS_CONTROLLER_IP |
| 9 | fi |
| 10 | service openvswitch-switch restart |
| 11 | num_ports=200 |
| 12 | ports=$(($num_ports-1)) |
| 13 | for vports in $(seq 0 2 $ports); do |
| 14 | echo "Deleting veth$vports" |
| 15 | ip link del veth$vports |
| 16 | done |
| 17 | for vports in $(seq 0 2 $ports); do |
| 18 | ip link add type veth |
| 19 | ifconfig veth$vports up |
| 20 | ifconfig veth$(($vports+1)) up |
| 21 | done |
| 22 | echo "Configuring ovs bridge $bridge" |
| 23 | ovs-vsctl del-br $bridge |
| 24 | ovs-vsctl add-br $bridge |
| 25 | for i in $(seq 1 2 $ports); do |
| 26 | ovs-vsctl add-port $bridge veth$i |
| 27 | done |
| 28 | my_ip=`ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d":" -f2 |cut -d" " -f1` |
| 29 | ovs-vsctl set-controller $bridge ptcp:6653:$my_ip tcp:$controller:6633 |
| 30 | ovs-vsctl set controller $bridge max_backoff=1000 |
| 31 | ovs-vsctl set bridge $bridge protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13 |
| 32 | ovs-vsctl show |
| 33 | ovs-ofctl show $bridge |