Ubuntu | c7027f9 | 2013-03-01 00:57:11 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | function Wait { |
| 4 | echo "press ret> " |
| 5 | read |
| 6 | } |
| 7 | |
| 8 | function port_down { |
| 9 | echo "Taking down $2 port $3" |
| 10 | Wait |
| 11 | dsh -w $1 "sudo ifconfig $2-$3 down" |
| 12 | echo "done" |
| 13 | } |
| 14 | function 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 | |
| 21 | function port_change { |
| 22 | port_down $1 $2 $3 |
| 23 | port_up $1 $2 $3 |
| 24 | } |
| 25 | |
| 26 | function 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 | |
| 33 | function 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 | } |
| 40 | function switch_go_back { |
| 41 | switch_remove $1 $2 |
| 42 | switch_back $1 $2 |
| 43 | } |
| 44 | |
| 45 | function 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 | } |
| 57 | function 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 | } |
| 69 | function link_change { |
| 70 | link_down $1 $2 $3 |
| 71 | link_up $1 $2 $3 |
| 72 | } |
| 73 | |
| 74 | function 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 | } |
| 86 | function 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 | } |
| 98 | function 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" |
| 117 | Wait |
| 118 | link_up onos9vpc swa3 eth4 |
| 119 | link_up onos9vpc swa4 eth2 |
| 120 | |
| 121 | echo "link down between swb4 and swb3" |
| 122 | Wait |
| 123 | link_down onos10vpc swb4 eth2 |
| 124 | link_down onos10vpc swb3 eth4 |
| 125 | echo "link down between swb4 and swb3" |
| 126 | Wait |
| 127 | link_up onos10vpc swb3 eth4 |
| 128 | link_up onos10vpc swb4 eth2 |
| 129 | |
| 130 | echo "link down between network 1 and network2" |
| 131 | Wait |
| 132 | ilink_down onos9vpc tapa0 |
| 133 | ilink_down onos10vpc tapb0 |
| 134 | |
| 135 | echo "link up between network 1 and network2" |
| 136 | Wait |
| 137 | ilink_up onos10vpc tapb0 |
| 138 | ilink_up onos9vpc tapa0 |