blob: d87464bf46c0bab3d12d01e022352f715e9f4e08 [file] [log] [blame]
Masayoshi Kobayashi809880d2013-03-27 04:16:01 +00001#! /bin/bash
2controller=`hostname`
3switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'`
4
5function host2ip (){
6 ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
7 echo $ip
8}
9
10# link.sh 00:00:00:00:ba:5e:ba:11 1 up
11
12if [ $# != 3 ];then
13 echo "usage: $0 <dpid> <port> <up|down>"
14fi
15
16src_dpid="dpid:"`echo $1 | sed s'/://g'`
17src_port=$2
18cmd=$3
19
20for s in $switches; do
21 dpid=`sudo ovs-ofctl show $s |grep dpid | awk '{print $4}'`
22 if [ "x$dpid" == "x$src_dpid" ]; then
23 intfs=`sudo ovs-ofctl show $s |grep addr | awk '{print $1}' | sed 's/.*(//g' | sed 's/):$//g'`
24 intf_list=()
25 for i in $intfs; do
26 intf_list+=($i)
27 done
28 intf=${intf_list[$src_port]}
29 if [ x$cmd == "xup" ]; then
30 echo "sudo ifconfig ${intf} up"
31 sudo ifconfig ${intf} up
32 elif [ x$cmd == "xdown" ]; then
33 echo "sudo ifconfig ${intf} down"
34 sudo ifconfig ${intf} down
35 else
36 echo "sudo ifconfig ${intf}"
37 sudo ifconfig ${intf}
38 fi
39 fi
40done