blob: 9fe83412fa94f1c3d83ae40dc7334ecac8bf4359 [file] [log] [blame]
Jonathan Hart1790a092013-03-28 14:11:45 -07001#! /bin/bash
2
3if [ "x$1" == "x" ];
4then
5 echo "No controller specified"
6 exit 1
7fi
8
9#controller=`hostname`
10controller=$1
Masayoshi Kobayashi640ad692014-01-22 23:37:59 -080011switches=`sudo ovs-vsctl list-br`
Jonathan Hart1790a092013-03-28 14:11:45 -070012function host2ip (){
Masayoshi Kobayashi640ad692014-01-22 23:37:59 -080013 ip=`getent hosts $1 | awk '{print $1}' | tail -n 1`
Jonathan Hart1790a092013-03-28 14:11:45 -070014 echo $ip
15}
16
17url=""
18for c in $controller; do
19 url="$url tcp:`host2ip $c`:6633"
20done
21echo $url
22for s in $switches; do
23 echo "set switch $s controller $url"
24 sudo ovs-vsctl set-controller $s $url
25done