blob: cd56e6cf6a58350c62f4d81691cd4502db799c98 [file] [log] [blame]
A R Karthick1fa66542017-08-10 14:15:29 -07001#!/usr/bin/env bash
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07002# 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 Gaonker93e302d2016-04-05 10:51:07 -070017bridge="$1"
18controller="$2"
19if [ x"$bridge" = "x" ]; then
Chetan Gaonkerb92e1532016-04-20 10:31:18 -070020 bridge="ovsbr0"
Chetan Gaonker93e302d2016-04-05 10:51:07 -070021fi
22if [ x"$controller" = "x" ]; then
A R Karthick2b93d6a2016-09-06 15:19:09 -070023 controller="$ONOS_CONTROLLER_IP"
Chetan Gaonker93e302d2016-04-05 10:51:07 -070024fi
A R Karthick4b72d4b2016-06-15 11:09:17 -070025pkill -9 ofdatapath
26pkill -9 ofprotocol
Chetan Gaonker93e302d2016-04-05 10:51:07 -070027service openvswitch-switch restart
28num_ports=200
29ports=$(($num_ports-1))
30for vports in $(seq 0 2 $ports); do
31 echo "Deleting veth$vports"
A R Karthick4b72d4b2016-06-15 11:09:17 -070032 ip link del veth$vports 2>/dev/null
Chetan Gaonker93e302d2016-04-05 10:51:07 -070033done
34for vports in $(seq 0 2 $ports); do
35 ip link add type veth
36 ifconfig veth$vports up
37 ifconfig veth$(($vports+1)) up
38done
39echo "Configuring ovs bridge $bridge"
40ovs-vsctl del-br $bridge
41ovs-vsctl add-br $bridge
Chetan Gaonkerb92e1532016-04-20 10:31:18 -070042#ovs-vsctl set bridge $bridge other-config:hwaddr=00:11:22:33:44:55
Chetan Gaonker93e302d2016-04-05 10:51:07 -070043for i in $(seq 1 2 $ports); do
44 ovs-vsctl add-port $bridge veth$i
45done
A R Karthick2b93d6a2016-09-06 15:19:09 -070046ctlr=""
47for ip in `echo $controller | tr ',' '\n'`; do
48 ctlr="$ctlr tcp:$ip:6653"
49done
50ovs-vsctl set-controller $bridge $ctlr
Chetan Gaonker93e302d2016-04-05 10:51:07 -070051ovs-vsctl set controller $bridge max_backoff=1000
52ovs-vsctl set bridge $bridge protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13
53ovs-vsctl show
54ovs-ofctl show $bridge