Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | bridge="$1" |
| 3 | controller="$2" |
| 4 | if [ x"$bridge" = "x" ]; then |
Chetan Gaonker | b92e153 | 2016-04-20 10:31:18 -0700 | [diff] [blame] | 5 | bridge="ovsbr0" |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 6 | fi |
| 7 | if [ x"$controller" = "x" ]; then |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 8 | controller="$ONOS_CONTROLLER_IP" |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 9 | fi |
A R Karthick | b7e8090 | 2016-05-17 09:38:31 -0700 | [diff] [blame] | 10 | pkill -9 ofdatapath |
| 11 | pkill -9 ofprotocol |
A R Karthick | a013a27 | 2016-08-16 16:40:19 -0700 | [diff] [blame] | 12 | service openvswitch-switch restart |
A.R Karthick | 88e80b9 | 2016-12-05 20:23:45 -0800 | [diff] [blame] | 13 | bridges=() |
| 14 | num_bridges=1 |
| 15 | if [[ $bridge =~ ^[0-9]+$ ]]; then |
| 16 | num_bridges=$bridge |
| 17 | if [ $num_bridges -eq 0 ]; then |
| 18 | num_bridges=1 |
| 19 | fi |
| 20 | for num in $(seq $num_bridges); do |
| 21 | if [ $num -eq 1 ]; then |
| 22 | br=br-int |
| 23 | else |
| 24 | br=br-int$num |
| 25 | fi |
| 26 | n=$(($num-1)) |
| 27 | bridges[$n]=$br |
| 28 | done |
| 29 | else |
| 30 | bridges[0]=$bridge |
| 31 | fi |
| 32 | |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 33 | ctlr="" |
| 34 | for ip in `echo $controller | tr ',' '\n'`; do |
| 35 | ctlr="$ctlr tcp:$ip:6653" |
| 36 | done |
A.R Karthick | 88e80b9 | 2016-12-05 20:23:45 -0800 | [diff] [blame] | 37 | |
| 38 | #Delete existing bridges if any |
| 39 | for br in "${bridges[@]}"; do |
| 40 | ovs-vsctl del-br $br |
| 41 | done |
| 42 | |
| 43 | for br in "${bridges[@]}"; do |
| 44 | echo "Configuring OVS bridge:$br" |
| 45 | ovs-vsctl add-br $br |
| 46 | ovs-vsctl set-controller $br $ctlr |
| 47 | ovs-vsctl set controller $br max_backoff=1000 |
| 48 | ovs-vsctl set bridge $br protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13 |
| 49 | done |
| 50 | |
| 51 | for br in "${bridges[@]}"; do |
| 52 | ovs-vsctl show |
| 53 | ovs-ofctl show $br |
| 54 | done |