Matteo Scandolo | 48d3d2d | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 1 | |
| 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 Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 17 | #!/usr/bin/env bash |
| 18 | bridge="$1" |
| 19 | controller="$2" |
A R Karthick | e8bd80e | 2017-08-01 12:36:24 -0700 | [diff] [blame] | 20 | voltha_loc="$3" |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 21 | if [ x"$bridge" = "x" ]; then |
Chetan Gaonker | b92e153 | 2016-04-20 10:31:18 -0700 | [diff] [blame] | 22 | bridge="ovsbr0" |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 23 | fi |
| 24 | if [ x"$controller" = "x" ]; then |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 25 | controller="$ONOS_CONTROLLER_IP" |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 26 | fi |
A R Karthick | b7e8090 | 2016-05-17 09:38:31 -0700 | [diff] [blame] | 27 | pkill -9 ofdatapath |
| 28 | pkill -9 ofprotocol |
A R Karthick | a013a27 | 2016-08-16 16:40:19 -0700 | [diff] [blame] | 29 | service openvswitch-switch restart |
A.R Karthick | 88e80b9 | 2016-12-05 20:23:45 -0800 | [diff] [blame] | 30 | bridges=() |
| 31 | num_bridges=1 |
| 32 | if [[ $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 |
| 46 | else |
| 47 | bridges[0]=$bridge |
| 48 | fi |
| 49 | |
A.R Karthick | 88e80b9 | 2016-12-05 20:23:45 -0800 | [diff] [blame] | 50 | #Delete existing bridges if any |
| 51 | for br in "${bridges[@]}"; do |
| 52 | ovs-vsctl del-br $br |
| 53 | done |
| 54 | |
A R Karthick | e8bd80e | 2017-08-01 12:36:24 -0700 | [diff] [blame] | 55 | proto=tcp |
| 56 | if [ 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 |
| 68 | fi |
| 69 | |
| 70 | ctlr="" |
| 71 | for ip in `echo $controller | tr ',' '\n'`; do |
| 72 | ctlr="$ctlr $proto:$ip:6653" |
| 73 | done |
| 74 | |
A.R Karthick | 88e80b9 | 2016-12-05 20:23:45 -0800 | [diff] [blame] | 75 | for 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 |
| 81 | done |
| 82 | |
| 83 | for br in "${bridges[@]}"; do |
| 84 | ovs-vsctl show |
| 85 | ovs-ofctl show $br |
| 86 | done |