blob: 4fd49f9b269f12c15436a4fee95b5d9a46f7a1b2 [file] [log] [blame]
Ubuntuc7027f92013-03-01 00:57:11 +00001#! /bin/sh
2
3function Wait {
4 echo "press ret> "
5 read
6}
7
8function port_down {
9 echo "Taking down $2 port $3"
10 Wait
11 dsh -w $1 "sudo ifconfig $2-$3 down"
12 echo "done"
13}
14function port_up {
15 echo "bring up $2 port $3"
16 Wait
17 dsh -w $1 "sudo ifconfig $2-$3 up"
18 echo "done"
19}
20
21function port_change {
22 port_down $1 $2 $3
23 port_up $1 $2 $3
24}
25
26function switch_remove {
27 echo "taking switch $2 out"
28 Wait
29 dsh -w $1 "sudo ovs-vsctl set-controller $2 tcp:127.0.0.1:6639"
30 echo "done"
31}
32
33function switch_back {
34 echo "taking switch $2 back"
35 Wait
36 ctrl="tcp:127.0.0.1:6633"
37 dsh -w $1 "sudo ovs-vsctl set-controller $2 $ctrl"
38 echo "done"
39}
40function switch_go_back {
41 switch_remove $1 $2
42 switch_back $1 $2
43}
44
45function link_down {
46 echo "remove link from sw $2 port $3"
47 n=`dsh -w $1 "sudo tc qdisc show dev $2-$3" | grep netem | wc -l`
48 if [ $n -eq 1 ]; then
49 echo "dsh -w $1 sudo tc qdisc change dev $2-$3 root netem loss 100%"
50 dsh -w $1 "sudo tc qdisc change dev $2-$3 root netem loss 100%"
51 else
52 echo "dsh -w $1 sudo tc qdisc add dev $2-$3 root netem 100%"
53 dsh -w $1 "sudo tc qdisc add dev $2-$3 root netem loss 100%"
54 fi
55 echo "done"
56}
57function link_up {
58 echo "add link from sw $2 port $3"
59 n=`dsh -w $1 "sudo tc qdisc show dev $2-$3" | grep netem | wc -l`
60 if [ $n -eq 1 ]; then
61 echo "dsh -w $1 sudo tc qdisc change dev $2-$3 root netem loss 0%"
62 dsh -w $1 "sudo tc qdisc change dev $2-$3 root netem loss 0%"
63 else
64 echo "dsh -w $1 sudo tc qdisc add dev $2-$3 root netem loss 0%"
65 dsh -w $1 "sudo tc qdisc add dev $2-$3 root netem loss 0%"
66 fi
67 echo "done"
68}
69function link_change {
70 link_down $1 $2 $3
71 link_up $1 $2 $3
72}
73
74function ilink_down {
75 echo "remove link from $2"
76 n=`dsh -w $1 "sudo tc qdisc show dev $2" | grep netem | wc -l`
77 if [ $n -eq 1 ]; then
78 echo "dsh -w $1 sudo tc qdisc change dev $2 root netem loss 100%"
79 dsh -w $1 "sudo tc qdisc change dev $2 root netem loss 100%"
80 else
81 echo "dsh -w $1 sudo tc qdisc add dev $2 root netem 100%"
82 dsh -w $1 "sudo tc qdisc add dev $2 root netem loss 100%"
83 fi
84 echo "done"
85}
86function ilink_up {
87 echo "add link at $2"
88 n=`dsh -w $1 "sudo tc qdisc show dev $2" | grep netem | wc -l`
89 if [ $n -eq 1 ]; then
90 echo "dsh -w $1 sudo tc qdisc change dev $2 root netem loss 0%"
91 dsh -w $1 "sudo tc qdisc change dev $2 root netem loss 0%"
92 else
93 echo "dsh -w $1 sudo tc qdisc add dev $2 root netem loss 0%"
94 dsh -w $1 "sudo tc qdisc add dev $2 root netem loss 0%"
95 fi
96 echo "done"
97}
98function ilink_change {
99 ilink_down $1 $2
100 ilink_up $1 $2
101}
102
103
104#port_change onos9vpc swa1 eth2
105#port_change onos10vpc swb3 eth4
106#port_change onos11vpc swc5 eth2
107
108#switch_go_back onos9vpc swa1
109#switch_go_back onos10vpc swb3
110#switch_go_back onos11vpc swc3
111
112#echo "link down between swa4 and swa3"
113#Wait
114#link_down onos9vpc swa4 eth2
115#link_down onos9vpc swa3 eth4
116#echo "link up between swa4 and swa3"
117Wait
118link_up onos9vpc swa3 eth4
119link_up onos9vpc swa4 eth2
120
121echo "link down between swb4 and swb3"
122Wait
123link_down onos10vpc swb4 eth2
124link_down onos10vpc swb3 eth4
125echo "link down between swb4 and swb3"
126Wait
127link_up onos10vpc swb3 eth4
128link_up onos10vpc swb4 eth2
129
130echo "link down between network 1 and network2"
131Wait
132ilink_down onos9vpc tapa0
133ilink_down onos10vpc tapb0
134
135echo "link up between network 1 and network2"
136Wait
137ilink_up onos10vpc tapb0
138ilink_up onos9vpc tapa0