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