blob: 129da36872b269c1e19865f991e9c5374bf04664 [file] [log] [blame]
Tim Lindbergc50276e2013-04-10 11:32:03 -07001#! /bin/bash
2
3#controller=`hostname`
4switches=`ifconfig -a | grep sw |grep -v eth | awk '{print $1}'`
5
6function host2ip (){
7 ip=`grep $1 /etc/hosts |grep -v "ip6"| awk '{print $1}'`
8 echo $ip
9}
10
11# link.sh 00:00:00:00:ba:5e:ba:11 1 up
12
13if [ $# != 3 ];then
14 echo "usage: $0 <dpid> <port> <up|down>"
15fi
16
17src_dpid="dpid:"`echo $1 | sed s'/://g'`
18src_port=$2
19cmd=$3
20
21if [ "x00:00:00:00:ba:5e:ba:11" == "x$1" ]; then
22 if [ x$cmd == "xup" ]; then
23 ~/ONOS/scripts/prontolink.exp 10.128.0.61 $src_port 1
24 elif [ x$cmd == "xdown" ]; then
25 ~/ONOS/scripts/prontolink.exp 10.128.0.61 $src_port 0
26 else
27 echo "no cmd"
28 fi
29elif [ "x00:00:00:00:00:00:ba:12" == "x$1" ]; then
30 if [ x$cmd == "xup" ]; then
31 ~/ONOS/scripts/prontolink.exp 10.128.0.62 $src_port 1
32 elif [ x$cmd == "xdown" ]; then
33 ~/ONOS/scripts/prontolink.exp 10.128.0.62 $src_port 0
34 else
35 echo "no cmd"
36 fi
37elif [ "x00:00:00:00:ba:5e:ba:13" == "x$1" ]; then
38 if [ x$cmd == "xup" ]; then
39 ~/ONOS/scripts/prontolink.exp 10.128.0.63 $src_port 1
40 elif [ x$cmd == "xdown" ]; then
41 ~/ONOS/scripts/prontolink.exp 10.128.0.63 $src_port 0
42 else
43 echo "no cmd"
44 fi
45elif [ "x00:00:20:4e:7f:51:8a:35" == "x$1" ]; then
46 if [ x$cmd == "xup" ]; then
47 ~/ONOS/scripts/prontolink.exp 10.128.0.50 $src_port 1
48 elif [ x$cmd == "xdown" ]; then
49 ~/ONOS/scripts/prontolink.exp 10.128.0.50 $src_port 0
50 else
51 echo "no cmd"
52 fi
53
54elif [ "x00:01:00:16:97:08:9a:46" == "x$1" ]; then
55 if [ x$cmd == "xup" ]; then
56 ~/ONOS/scripts/neclink.exp $src_port no
57 elif [ x$cmd == "xdown" ]; then
58 ~/ONOS/scripts/neclink.exp $src_port
59 else
60 echo "no cmd"
61 fi
62
63
64fi
65
66
67
68#for s in $switches; do
69# dpid=`sudo ovs-ofctl show $s |grep dpid | awk '{print $4}'`
70# if [ "x$dpid" == "x$src_dpid" ]; then
71#
72## intf=`sudo ovs-ofctl show $s |grep addr | awk -v p=$src_port 'BEGIN {pat="^ "p"\("}
73## $0 ~ pat {w=match ($0, /\(.*\)/); if (w) print substr($0, RSTART+1, RLENGTH-2)}'`
74#
75# sudo ovs-ofctl show $s |grep addr | sed 's/[\(\)]/,/g'>/tmp/baz.out
76# intf=`cat /tmp/baz.out | awk -v p=$src_port 'BEGIN {pat="^ "p","}
77# $0 ~ pat {w=match($0, /,.*,/); if (w) print substr($0, RSTART+1, RLENGTH-2)}'`
78#
79# if [ x$intf != "x" ]; then
80# if [ x$cmd == "xup" ]; then
81# echo "sudo ifconfig ${intf} up"
82# sudo ifconfig ${intf} up
83# elif [ x$cmd == "xdown" ]; then
84# echo "sudo ifconfig ${intf} down"
85# sudo ifconfig ${intf} down
86# else
87# echo "sudo ifconfig ${intf}"
88# sudo ifconfig ${intf}
89# fi
90# break
91# fi
92# fi
93#done