A R Karthick | 1fa6654 | 2017-08-10 14:15:29 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Matteo Scandolo | 48d3d2d | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 17 | bridge="$1" |
| 18 | controller="$2" |
| 19 | if [ x"$bridge" = "x" ]; then |
Chetan Gaonker | b92e153 | 2016-04-20 10:31:18 -0700 | [diff] [blame] | 20 | bridge="ovsbr0" |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 21 | fi |
| 22 | if [ x"$controller" = "x" ]; then |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 23 | controller="$ONOS_CONTROLLER_IP" |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 24 | fi |
A R Karthick | 4b72d4b | 2016-06-15 11:09:17 -0700 | [diff] [blame] | 25 | pkill -9 ofdatapath |
| 26 | pkill -9 ofprotocol |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 27 | service openvswitch-switch restart |
| 28 | num_ports=200 |
| 29 | ports=$(($num_ports-1)) |
| 30 | for vports in $(seq 0 2 $ports); do |
| 31 | echo "Deleting veth$vports" |
A R Karthick | 4b72d4b | 2016-06-15 11:09:17 -0700 | [diff] [blame] | 32 | ip link del veth$vports 2>/dev/null |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 33 | done |
| 34 | for vports in $(seq 0 2 $ports); do |
| 35 | ip link add type veth |
| 36 | ifconfig veth$vports up |
| 37 | ifconfig veth$(($vports+1)) up |
| 38 | done |
| 39 | echo "Configuring ovs bridge $bridge" |
| 40 | ovs-vsctl del-br $bridge |
| 41 | ovs-vsctl add-br $bridge |
Chetan Gaonker | b92e153 | 2016-04-20 10:31:18 -0700 | [diff] [blame] | 42 | #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] | 43 | for i in $(seq 1 2 $ports); do |
| 44 | ovs-vsctl add-port $bridge veth$i |
| 45 | done |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 46 | ctlr="" |
| 47 | for ip in `echo $controller | tr ',' '\n'`; do |
| 48 | ctlr="$ctlr tcp:$ip:6653" |
| 49 | done |
| 50 | ovs-vsctl set-controller $bridge $ctlr |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 51 | ovs-vsctl set controller $bridge max_backoff=1000 |
| 52 | ovs-vsctl set bridge $bridge protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13 |
| 53 | ovs-vsctl show |
| 54 | ovs-ofctl show $bridge |