blob: d41e18a9f7134f0d246c9e93a32ea69b74b55494 [file] [log] [blame]
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -07001#!/usr/bin/env bash
2bridge="$1"
3controller="$2"
A R Karthicke8bd80e2017-08-01 12:36:24 -07004voltha_loc="$3"
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -07005if [ x"$bridge" = "x" ]; then
Chetan Gaonkerb92e1532016-04-20 10:31:18 -07006 bridge="ovsbr0"
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -07007fi
8if [ x"$controller" = "x" ]; then
A R Karthick2b93d6a2016-09-06 15:19:09 -07009 controller="$ONOS_CONTROLLER_IP"
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070010fi
A R Karthickb7e80902016-05-17 09:38:31 -070011pkill -9 ofdatapath
12pkill -9 ofprotocol
A R Karthicka013a272016-08-16 16:40:19 -070013service openvswitch-switch restart
A.R Karthick88e80b92016-12-05 20:23:45 -080014bridges=()
15num_bridges=1
16if [[ $bridge =~ ^[0-9]+$ ]]; then
17 num_bridges=$bridge
18 if [ $num_bridges -eq 0 ]; then
19 num_bridges=1
20 fi
21 for num in $(seq $num_bridges); do
22 if [ $num -eq 1 ]; then
23 br=br-int
24 else
25 br=br-int$num
26 fi
27 n=$(($num-1))
28 bridges[$n]=$br
29 done
30else
31 bridges[0]=$bridge
32fi
33
A.R Karthick88e80b92016-12-05 20:23:45 -080034#Delete existing bridges if any
35for br in "${bridges[@]}"; do
36 ovs-vsctl del-br $br
37done
38
A R Karthicke8bd80e2017-08-01 12:36:24 -070039proto=tcp
40if [ x"$voltha_loc" != "x" ]; then
41 onos_jks="$voltha_loc/docker/onos_cfg/onos.jks"
42 client_cert="$voltha_loc/pki/voltha.crt"
43 if [ -f $onos_jks ]; then
44 #extract server certificate
45 keytool -export -alias onos -file /tmp/onos.der -keystore $onos_jks -storepass 222222
46 openssl x509 -inform der -in /tmp/onos.der -out /tmp/onos-cert.pem
47 cat /tmp/onos-cert.pem $client_cert > /tmp/voltha-CA.pem
48 echo "Enabling OVS SSL connection to controller"
49 ovs-vsctl set-ssl $voltha_loc/pki/voltha.key $client_cert /tmp/voltha-CA.pem
50 proto=ssl
51 fi
52fi
53
54ctlr=""
55for ip in `echo $controller | tr ',' '\n'`; do
56 ctlr="$ctlr $proto:$ip:6653"
57done
58
A.R Karthick88e80b92016-12-05 20:23:45 -080059for br in "${bridges[@]}"; do
60 echo "Configuring OVS bridge:$br"
61 ovs-vsctl add-br $br
62 ovs-vsctl set-controller $br $ctlr
63 ovs-vsctl set controller $br max_backoff=1000
64 ovs-vsctl set bridge $br protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13
65done
66
67for br in "${bridges[@]}"; do
68 ovs-vsctl show
69 ovs-ofctl show $br
70done