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 |
Chetan Gaonker | b92e153 | 2016-04-20 10:31:18 -0700 | [diff] [blame] | 5 | bridge="ovsbr0" |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -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 | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 9 | fi |
A R Karthick | 4b72d4b | 2016-06-15 11:09:17 -0700 | [diff] [blame] | 10 | pkill -9 ofdatapath |
| 11 | pkill -9 ofprotocol |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 12 | service openvswitch-switch restart |
| 13 | num_ports=200 |
| 14 | ports=$(($num_ports-1)) |
| 15 | for vports in $(seq 0 2 $ports); do |
| 16 | echo "Deleting veth$vports" |
A R Karthick | 4b72d4b | 2016-06-15 11:09:17 -0700 | [diff] [blame] | 17 | ip link del veth$vports 2>/dev/null |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 18 | done |
| 19 | for vports in $(seq 0 2 $ports); do |
| 20 | ip link add type veth |
| 21 | ifconfig veth$vports up |
| 22 | ifconfig veth$(($vports+1)) up |
| 23 | done |
| 24 | echo "Configuring ovs bridge $bridge" |
| 25 | ovs-vsctl del-br $bridge |
| 26 | ovs-vsctl add-br $bridge |
Chetan Gaonker | b92e153 | 2016-04-20 10:31:18 -0700 | [diff] [blame] | 27 | #ovs-vsctl set bridge $bridge other-config:hwaddr=00:11:22:33:44:55 |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 28 | for i in $(seq 1 2 $ports); do |
| 29 | ovs-vsctl add-port $bridge veth$i |
| 30 | done |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 31 | ctlr="" |
| 32 | for ip in `echo $controller | tr ',' '\n'`; do |
| 33 | ctlr="$ctlr tcp:$ip:6653" |
| 34 | done |
| 35 | ovs-vsctl set-controller $bridge $ctlr |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 36 | ovs-vsctl set controller $bridge max_backoff=1000 |
| 37 | ovs-vsctl set bridge $bridge protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13 |
| 38 | ovs-vsctl show |
| 39 | ovs-ofctl show $bridge |