Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | bridge="$1" |
| 3 | controller="$2" |
A R Karthick | e8bd80e | 2017-08-01 12:36:24 -0700 | [diff] [blame] | 4 | voltha_loc="$3" |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 5 | if [ x"$bridge" = "x" ]; then |
Chetan Gaonker | b92e153 | 2016-04-20 10:31:18 -0700 | [diff] [blame] | 6 | bridge="ovsbr0" |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 7 | fi |
| 8 | if [ x"$controller" = "x" ]; then |
A R Karthick | 2b93d6a | 2016-09-06 15:19:09 -0700 | [diff] [blame] | 9 | controller="$ONOS_CONTROLLER_IP" |
Chetan Gaonker | 4ca5cca | 2016-04-11 13:59:35 -0700 | [diff] [blame] | 10 | fi |
A R Karthick | b7e8090 | 2016-05-17 09:38:31 -0700 | [diff] [blame] | 11 | pkill -9 ofdatapath |
| 12 | pkill -9 ofprotocol |
A R Karthick | a013a27 | 2016-08-16 16:40:19 -0700 | [diff] [blame] | 13 | service openvswitch-switch restart |
A.R Karthick | 88e80b9 | 2016-12-05 20:23:45 -0800 | [diff] [blame] | 14 | bridges=() |
| 15 | num_bridges=1 |
| 16 | if [[ $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 |
| 30 | else |
| 31 | bridges[0]=$bridge |
| 32 | fi |
| 33 | |
A.R Karthick | 88e80b9 | 2016-12-05 20:23:45 -0800 | [diff] [blame] | 34 | #Delete existing bridges if any |
| 35 | for br in "${bridges[@]}"; do |
| 36 | ovs-vsctl del-br $br |
| 37 | done |
| 38 | |
A R Karthick | e8bd80e | 2017-08-01 12:36:24 -0700 | [diff] [blame] | 39 | proto=tcp |
| 40 | if [ 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 |
| 52 | fi |
| 53 | |
| 54 | ctlr="" |
| 55 | for ip in `echo $controller | tr ',' '\n'`; do |
| 56 | ctlr="$ctlr $proto:$ip:6653" |
| 57 | done |
| 58 | |
A.R Karthick | 88e80b9 | 2016-12-05 20:23:45 -0800 | [diff] [blame] | 59 | for 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 |
| 65 | done |
| 66 | |
| 67 | for br in "${bridges[@]}"; do |
| 68 | ovs-vsctl show |
| 69 | ovs-ofctl show $br |
| 70 | done |