-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathecmper-config-adddel.sh
executable file
·88 lines (73 loc) · 1.97 KB
/
ecmper-config-adddel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
# install route entries to ECMP-ER Router (bmv2)
rip_base="10.0.0"
vip="10.0.10.0"
run () {
echo "$@"
"$@" || exit 1
}
silent () {
"$@" 2> /dev/null || true
}
usage() {
echo
echo "add/del routes to ECMP-ER Router via HTTP API"
echo "Virtual IP: $vip, Real IP: $rip_base.X"
echo
# echo " -n NUM number of servers"
echo " -s NUM server id (start)"
echo " -e NUM server id (end)"
echo " -i SEC interval between adding/deleting server"
echo " -d debug log (e.g. show tables each time"
echo " -h help"
echo
}
while getopts n:i:s:e:hd OPT
do
case $OPT in
# n) num=$OPTARG ;;
s) sid=$OPTARG ;;
e) eid=$OPTARG ;;
i) interval=$OPTARG ;;
d) debug="yes" ;;
h) usage ; exit 1 ;;
\?) usage ; exit 1 ;;
esac
done
echo "DEBUG: num=$num, interval=$interval"
#for n in `seq 1 $num`; do
for ((i=$sid; i<=$eid; i++))
do
# VIP
# @app.route("/add/<prefix>/<int:preflen>/<nexthop>", methods = ["PUT"])
run http PUT localhost:5000/add/$vip/32/$rip_base.$i
http PUT localhost:5000/install
if [[ $debug == "yes" ]]; then
http localhost:5000/tables
fi
sleep $interval
done
#for n in `seq 0 $(($num - 1))`; do
for ((i=$eid; i>=$sid; i--))
do
run http PUT localhost:5000/del/$vip/32/$rip_base.$i
http PUT localhost:5000/install
if [[ $debug == "yes" ]]; then
http localhost:5000/tables
fi
sleep $interval
done
exit 1
# VIP
# @app.route("/add/<prefix>/<int:preflen>/<nexthop>", methods = ["PUT"])
http PUT localhost:5000/add/10.0.10.0/32/10.0.0.1
http PUT localhost:5000/add/10.0.10.0/32/10.0.0.2
http PUT localhost:5000/add/10.0.10.0/32/10.0.0.3
http PUT localhost:5000/add/10.0.10.0/32/10.0.0.4
# Client
# http PUT localhost:5000/add/10.0.1.0/24/connected
# http PUT localhost:5000/del/10.0.1.0/24/connected
# Install Route Entries
http PUT localhost:5000/install
# Show table entries
http localhost:5000/tables