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