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 |
| 11 | switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'` |
| 12 | |
| 13 | function host2ip (){ |
| 14 | ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'` |
| 15 | echo $ip |
| 16 | } |
| 17 | |
| 18 | url="" |
| 19 | for c in $controller; do |
| 20 | url="$url tcp:`host2ip $c`:6633" |
| 21 | done |
| 22 | echo $url |
| 23 | for s in $switches; do |
| 24 | echo "set switch $s controller $url" |
| 25 | sudo ovs-vsctl set-controller $s $url |
| 26 | done |