blob: d2c32994514ecdb7c9139420825edabcc625e3cb [file] [log] [blame]
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07001
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 Gaonkerc0566b52016-03-09 11:31:51 -080017#!/usr/bin/env bash
18bridge="$1"
19controller="$2"
20if [ x"$bridge" = "x" ]; then
21 bridge="br0"
22fi
23if [ x"$controller" = "x" ]; then
24 controller="%%CONTROLLER%%"
25fi
26service openvswitch-switch restart
Chetan Gaonkerfa3fb5f2016-03-23 15:03:24 -070027num_ports=200
Chetan Gaonkerc0566b52016-03-09 11:31:51 -080028ports=$(($num_ports-1))
29for vports in $(seq 0 2 $ports); do
30 echo "Deleting veth$vports"
31 ip link del veth$vports
32done
33for vports in $(seq 0 2 $ports); do
34 ip link add type veth
35 ifconfig veth$vports up
36 ifconfig veth$(($vports+1)) up
37done
38echo "Configuring ovs bridge $bridge"
39ovs-vsctl del-br $bridge
40ovs-vsctl add-br $bridge
Chetan Gaonkerfa3fb5f2016-03-23 15:03:24 -070041for i in $(seq 1 2 $ports); do
Chetan Gaonkerc0566b52016-03-09 11:31:51 -080042 ovs-vsctl add-port $bridge veth$i
43done
44my_ip=`ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d":" -f2 |cut -d" " -f1`
45ovs-vsctl set-controller $bridge ptcp:6653:$my_ip tcp:$controller:6633
46ovs-vsctl set controller $bridge max_backoff=1000
47ovs-vsctl set bridge $bridge protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13
48ovs-vsctl show
49ovs-ofctl show $bridge