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 | c0566b5 | 2016-03-09 11:31:51 -0800 | [diff] [blame] | 17 | bridge="$1" |
| 18 | controller="$2" |
| 19 | if [ x"$bridge" = "x" ]; then |
| 20 | bridge="br0" |
| 21 | fi |
| 22 | if [ x"$controller" = "x" ]; then |
| 23 | controller="%%CONTROLLER%%" |
| 24 | fi |
| 25 | service openvswitch-switch restart |
Chetan Gaonker | fa3fb5f | 2016-03-23 15:03:24 -0700 | [diff] [blame] | 26 | num_ports=200 |
Chetan Gaonker | c0566b5 | 2016-03-09 11:31:51 -0800 | [diff] [blame] | 27 | ports=$(($num_ports-1)) |
| 28 | for vports in $(seq 0 2 $ports); do |
| 29 | echo "Deleting veth$vports" |
| 30 | ip link del veth$vports |
| 31 | done |
| 32 | for vports in $(seq 0 2 $ports); do |
| 33 | ip link add type veth |
| 34 | ifconfig veth$vports up |
| 35 | ifconfig veth$(($vports+1)) up |
| 36 | done |
| 37 | echo "Configuring ovs bridge $bridge" |
| 38 | ovs-vsctl del-br $bridge |
| 39 | ovs-vsctl add-br $bridge |
Chetan Gaonker | fa3fb5f | 2016-03-23 15:03:24 -0700 | [diff] [blame] | 40 | for i in $(seq 1 2 $ports); do |
Chetan Gaonker | c0566b5 | 2016-03-09 11:31:51 -0800 | [diff] [blame] | 41 | ovs-vsctl add-port $bridge veth$i |
| 42 | done |
| 43 | my_ip=`ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d":" -f2 |cut -d" " -f1` |
| 44 | ovs-vsctl set-controller $bridge ptcp:6653:$my_ip tcp:$controller:6633 |
| 45 | ovs-vsctl set controller $bridge max_backoff=1000 |
| 46 | ovs-vsctl set bridge $bridge protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13 |
| 47 | ovs-vsctl show |
| 48 | ovs-ofctl show $bridge |