Matteo Scandolo | 48d3d2d | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 1 | |
| 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 | #!/usr/bin/env bash |
| 18 | bridge="$1" |
| 19 | controller="$2" |
| 20 | if [ x"$bridge" = "x" ]; then |
Chetan Gaonker | b92e153 | 2016-04-20 10:31:18 -0700 | [diff] [blame] | 21 | bridge="ovsbr0" |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 22 | fi |
| 23 | if [ x"$controller" = "x" ]; then |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 24 | controller="$ONOS_CONTROLLER_IP" |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 25 | fi |
A R Karthick | 4b72d4b | 2016-06-15 11:09:17 -0700 | [diff] [blame] | 26 | pkill -9 ofdatapath |
| 27 | pkill -9 ofprotocol |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 28 | service openvswitch-switch restart |
| 29 | num_ports=200 |
| 30 | ports=$(($num_ports-1)) |
| 31 | for vports in $(seq 0 2 $ports); do |
| 32 | echo "Deleting veth$vports" |
A R Karthick | 4b72d4b | 2016-06-15 11:09:17 -0700 | [diff] [blame] | 33 | ip link del veth$vports 2>/dev/null |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 34 | done |
| 35 | for vports in $(seq 0 2 $ports); do |
| 36 | ip link add type veth |
| 37 | ifconfig veth$vports up |
| 38 | ifconfig veth$(($vports+1)) up |
| 39 | done |
| 40 | echo "Configuring ovs bridge $bridge" |
| 41 | ovs-vsctl del-br $bridge |
| 42 | ovs-vsctl add-br $bridge |
Chetan Gaonker | b92e153 | 2016-04-20 10:31:18 -0700 | [diff] [blame] | 43 | #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] | 44 | for i in $(seq 1 2 $ports); do |
| 45 | ovs-vsctl add-port $bridge veth$i |
| 46 | done |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 47 | ctlr="" |
| 48 | for ip in `echo $controller | tr ',' '\n'`; do |
| 49 | ctlr="$ctlr tcp:$ip:6653" |
| 50 | done |
| 51 | ovs-vsctl set-controller $bridge $ctlr |
Chetan Gaonker | 93e302d | 2016-04-05 10:51:07 -0700 | [diff] [blame] | 52 | ovs-vsctl set controller $bridge max_backoff=1000 |
| 53 | ovs-vsctl set bridge $bridge protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13 |
| 54 | ovs-vsctl show |
| 55 | ovs-ofctl show $bridge |