blob: e6f2487549f375fa8e5be2fae25119af5afe77c1 [file] [log] [blame]
Tim Lindbergc50276e2013-04-10 11:32:03 -07001#! /bin/bash
2
Naoki Shiotad5d0e942014-03-27 18:57:32 -07003SCRIPT_DIR=$(cd `dirname $0`; pwd)
4
Tim Lindbergc50276e2013-04-10 11:32:03 -07005#controller=`hostname`
6switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'`
7
8function host2ip (){
9 ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
10 echo $ip
11}
12
13# link.sh 00:00:00:00:ba:5e:ba:11 1 up
14
15if [ $# != 3 ];then
16 echo "usage: $0 <dpid> <port> <up|down>"
17fi
18
19src_dpid="dpid:"`echo $1 | sed s'/://g'`
20src_port=$2
21cmd=$3
22
23if [ "x00:00:00:00:ba:5e:ba:11" == "x$1" ]; then
24 if [ x$cmd == "xup" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070025 ${SCRIPT_DIR}/prontolink.exp 10.128.0.61 $src_port 1
Tim Lindbergc50276e2013-04-10 11:32:03 -070026 elif [ x$cmd == "xdown" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070027 ${SCRIPT_DIR}/prontolink.exp 10.128.0.61 $src_port 0
Tim Lindbergc50276e2013-04-10 11:32:03 -070028 else
29 echo "no cmd"
30 fi
31elif [ "x00:00:00:00:00:00:ba:12" == "x$1" ]; then
32 if [ x$cmd == "xup" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070033 ${SCRIPT_DIR}/prontolink.exp 10.128.0.62 $src_port 1
Tim Lindbergc50276e2013-04-10 11:32:03 -070034 elif [ x$cmd == "xdown" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070035 ${SCRIPT_DIR}/prontolink.exp 10.128.0.62 $src_port 0
Tim Lindbergc50276e2013-04-10 11:32:03 -070036 else
37 echo "no cmd"
38 fi
39elif [ "x00:00:00:00:ba:5e:ba:13" == "x$1" ]; then
40 if [ x$cmd == "xup" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070041 ${SCRIPT_DIR}/prontolink.exp 10.128.0.63 $src_port 1
Tim Lindbergc50276e2013-04-10 11:32:03 -070042 elif [ x$cmd == "xdown" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070043 ${SCRIPT_DIR}/prontolink.exp 10.128.0.63 $src_port 0
Tim Lindbergc50276e2013-04-10 11:32:03 -070044 else
45 echo "no cmd"
46 fi
47elif [ "x00:00:20:4e:7f:51:8a:35" == "x$1" ]; then
48 if [ x$cmd == "xup" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070049 ${SCRIPT_DIR}/prontolink.exp 10.128.0.50 $src_port 1
Tim Lindbergc50276e2013-04-10 11:32:03 -070050 elif [ x$cmd == "xdown" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070051 ${SCRIPT_DIR}/prontolink.exp 10.128.0.50 $src_port 0
Tim Lindbergc50276e2013-04-10 11:32:03 -070052 else
53 echo "no cmd"
54 fi
55
56elif [ "x00:01:00:16:97:08:9a:46" == "x$1" ]; then
57 if [ x$cmd == "xup" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070058 ${SCRIPT_DIR}/neclink.exp $src_port no
Tim Lindbergc50276e2013-04-10 11:32:03 -070059 elif [ x$cmd == "xdown" ]; then
Naoki Shiotad5d0e942014-03-27 18:57:32 -070060 ${SCRIPT_DIR}/neclink.exp $src_port
Tim Lindbergc50276e2013-04-10 11:32:03 -070061 else
62 echo "no cmd"
63 fi
64
65
66fi
67
68
69
70#for s in $switches; do
71# dpid=`sudo ovs-ofctl show $s |grep dpid | awk '{print $4}'`
72# if [ "x$dpid" == "x$src_dpid" ]; then
73#
74## intf=`sudo ovs-ofctl show $s |grep addr | awk -v p=$src_port 'BEGIN {pat="^ "p"\("}
75## $0 ~ pat {w=match ($0, /\(.*\)/); if (w) print substr($0, RSTART+1, RLENGTH-2)}'`
76#
77# sudo ovs-ofctl show $s |grep addr | sed 's/[\(\)]/,/g'>/tmp/baz.out
78# intf=`cat /tmp/baz.out | awk -v p=$src_port 'BEGIN {pat="^ "p","}
79# $0 ~ pat {w=match($0, /,.*,/); if (w) print substr($0, RSTART+1, RLENGTH-2)}'`
80#
81# if [ x$intf != "x" ]; then
82# if [ x$cmd == "xup" ]; then
83# echo "sudo ifconfig ${intf} up"
84# sudo ifconfig ${intf} up
85# elif [ x$cmd == "xdown" ]; then
86# echo "sudo ifconfig ${intf} down"
87# sudo ifconfig ${intf} down
88# else
89# echo "sudo ifconfig ${intf}"
90# sudo ifconfig ${intf}
91# fi
92# break
93# fi
94# fi
95#done