Jonathan Hart | 1790a09 | 2013-03-28 14:11:45 -0700 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | |
| 3 | if [ "x$1" == "x" ]; |
| 4 | then |
| 5 | echo "No controller specified" |
| 6 | exit 1 |
| 7 | fi |
| 8 | |
| 9 | #controller=`hostname` |
| 10 | controller=$1 |
Masayoshi Kobayashi | 640ad69 | 2014-01-22 23:37:59 -0800 | [diff] [blame] | 11 | switches=`sudo ovs-vsctl list-br` |
Jonathan Hart | 1790a09 | 2013-03-28 14:11:45 -0700 | [diff] [blame] | 12 | function host2ip (){ |
Masayoshi Kobayashi | 640ad69 | 2014-01-22 23:37:59 -0800 | [diff] [blame] | 13 | ip=`getent hosts $1 | awk '{print $1}' | tail -n 1` |
Jonathan Hart | 1790a09 | 2013-03-28 14:11:45 -0700 | [diff] [blame] | 14 | echo $ip |
| 15 | } |
| 16 | |
| 17 | url="" |
| 18 | for c in $controller; do |
| 19 | url="$url tcp:`host2ip $c`:6633" |
| 20 | done |
| 21 | echo $url |
| 22 | for s in $switches; do |
| 23 | echo "set switch $s controller $url" |
| 24 | sudo ovs-vsctl set-controller $s $url |
| 25 | done |