-
Notifications
You must be signed in to change notification settings - Fork 3
/
lf_loop_traffic.sh
executable file
·70 lines (60 loc) · 1.47 KB
/
lf_loop_traffic.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
#!/bin/bash
if [ -z "$1" -o -z "$2" -o -z "$3" ]; then
echo "Usage: $0 <Layer-3 Name> <Run seconds> <Sleep seconds>"
echo " Layer-3 Name: preface with cx: for cross connect"
echo " preface with group: for test group"
exit 1
fi
MANAGER=${MANAGER:-localhost}
RESOURCE=${RESOURCE:-1}
TRAFFIC_NAME="$1"
USING=wrong
if [[ $1 = cx:* ]]; then
USING=cx
TRAFFIC_NAME=${TRAFFIC_NAME#cx:}
elif [[ $1 = group:* ]]; then
USING=tg
TRAFFIC_NAME=${TRAFFIC_NAME#group:}
fi
if [[ $USING = wrong ]]; then
echo "Please specify group using 'group:$TRAFFIC_NAME' or single connection using 'cx:$TRAFFIC_NAME'"
exit 1
fi
case $USING in
cx)
START="op_cx run"
STOP="op_cx stop"
;;
tg)
START="op_group run"
STOP="op_group stop"
;;
esac
RUN_SEC="$2"
SLEEP_SEC="$3"
ACTION="STOPPED"
function op_cx() {
ACTION="STOPPED"
if [[ $1 = run ]]; then
ACTION="RUNNING"
elif [[ $1 = quiesce ]]; then
ACTION="QUIESCE"
fi
./lf_firemod.pl --mgr $MANAGER --resource $RESOURCE --quiet yes --action do_cmd --cmd "set_cx_state default_tm $TRAFFIC_NAME $ACTION"
}
function op_group() {
ACTION="stop_group"
if [[ $1 = run ]]; then
ACTION="start_group"
elif [[ $1 = quiesce ]]; then
ACTION="quiesce_group"
fi
./lf_firemod.pl --mgr $MANAGER --resource $RESOURCE --quiet yes --action do_cmd --cmd "$ACTION $TRAFFIC_NAME"
}
cd /home/lanforge/scripts
while :; do
$START
sleep $RUN_SEC
$STOP
sleep $SLEEP_SEC
done