blob: 3a549623504d1919b10a42ff8056cc19a18caa89 [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 Gaonker4ca5cca2016-04-11 13:59:35 -070017bridge="$1"
18controller="$2"
A R Karthicke8bd80e2017-08-01 12:36:24 -070019voltha_loc="$3"
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070020if [ x"$bridge" = "x" ]; then
Chetan Gaonkerb92e1532016-04-20 10:31:18 -070021 bridge="ovsbr0"
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070022fi
23if [ x"$controller" = "x" ]; then
A R Karthick2b93d6a2016-09-06 15:19:09 -070024 controller="$ONOS_CONTROLLER_IP"
Chetan Gaonker4ca5cca2016-04-11 13:59:35 -070025fi
A R Karthickb7e80902016-05-17 09:38:31 -070026pkill -9 ofdatapath
27pkill -9 ofprotocol
A R Karthicka013a272016-08-16 16:40:19 -070028service openvswitch-switch restart
A.R Karthick88e80b92016-12-05 20:23:45 -080029bridges=()
30num_bridges=1
31if [[ $bridge =~ ^[0-9]+$ ]]; then
32 num_bridges=$bridge
33 if [ $num_bridges -eq 0 ]; then
34 num_bridges=1
35 fi
36 for num in $(seq $num_bridges); do
37 if [ $num -eq 1 ]; then
38 br=br-int
39 else
40 br=br-int$num
41 fi
42 n=$(($num-1))
43 bridges[$n]=$br
44 done
45else
46 bridges[0]=$bridge
47fi
48
A.R Karthick88e80b92016-12-05 20:23:45 -080049#Delete existing bridges if any
50for br in "${bridges[@]}"; do
51 ovs-vsctl del-br $br
52done
53
A R Karthicke8bd80e2017-08-01 12:36:24 -070054proto=tcp
55if [ x"$voltha_loc" != "x" ]; then
56 onos_jks="$voltha_loc/docker/onos_cfg/onos.jks"
57 client_cert="$voltha_loc/pki/voltha.crt"
58 if [ -f $onos_jks ]; then
59 #extract server certificate
60 keytool -export -alias onos -file /tmp/onos.der -keystore $onos_jks -storepass 222222
61 openssl x509 -inform der -in /tmp/onos.der -out /tmp/onos-cert.pem
62 cat /tmp/onos-cert.pem $client_cert > /tmp/voltha-CA.pem
63 echo "Enabling OVS SSL connection to controller"
64 ovs-vsctl set-ssl $voltha_loc/pki/voltha.key $client_cert /tmp/voltha-CA.pem
65 proto=ssl
66 fi
67fi
68
69ctlr=""
70for ip in `echo $controller | tr ',' '\n'`; do
71 ctlr="$ctlr $proto:$ip:6653"
72done
73
A.R Karthick88e80b92016-12-05 20:23:45 -080074for br in "${bridges[@]}"; do
75 echo "Configuring OVS bridge:$br"
76 ovs-vsctl add-br $br
77 ovs-vsctl set-controller $br $ctlr
78 ovs-vsctl set controller $br max_backoff=1000
79 ovs-vsctl set bridge $br protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13
80done
81
82for br in "${bridges[@]}"; do
83 ovs-vsctl show
84 ovs-ofctl show $br
85done