blob: 1be9a4c4b98873164cd48ad1ec82af05fb7d410e [file] [log] [blame]
Chetan Gaonkerc0566b52016-03-09 11:31:51 -08001#!/usr/bin/env bash
2bridge="$1"
3controller="$2"
4if [ x"$bridge" = "x" ]; then
5 bridge="br0"
6fi
7if [ x"$controller" = "x" ]; then
8 controller="%%CONTROLLER%%"
9fi
10service openvswitch-switch restart
Chetan Gaonkerfa3fb5f2016-03-23 15:03:24 -070011num_ports=200
Chetan Gaonkerc0566b52016-03-09 11:31:51 -080012ports=$(($num_ports-1))
13for vports in $(seq 0 2 $ports); do
14 echo "Deleting veth$vports"
15 ip link del veth$vports
16done
17for vports in $(seq 0 2 $ports); do
18 ip link add type veth
19 ifconfig veth$vports up
20 ifconfig veth$(($vports+1)) up
21done
22echo "Configuring ovs bridge $bridge"
23ovs-vsctl del-br $bridge
24ovs-vsctl add-br $bridge
Chetan Gaonkerfa3fb5f2016-03-23 15:03:24 -070025for i in $(seq 1 2 $ports); do
Chetan Gaonkerc0566b52016-03-09 11:31:51 -080026 ovs-vsctl add-port $bridge veth$i
27done
28my_ip=`ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d":" -f2 |cut -d" " -f1`
29ovs-vsctl set-controller $bridge ptcp:6653:$my_ip tcp:$controller:6633
30ovs-vsctl set controller $bridge max_backoff=1000
31ovs-vsctl set bridge $bridge protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13
32ovs-vsctl show
33ovs-ofctl show $bridge