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