forked from opencomputeproject/SAI-Challenger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_client_server.sh
executable file
·58 lines (52 loc) · 1.26 KB
/
run_client_server.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
#!/bin/bash
SAIC_HOME=.
TG=ptf
TARGET=saivs
ASIC_TYPE=trident2
while getopts "hat" OPT; do
case ${OPT} in
h)
echo "Setup docker based testbed: 1) start client docker; 2) start server docker; 3) create links."
echo "Usage: tb_ctl.sh [-a ASIC] [-t TARGET] COMMAND"
echo -e "-h\tShow help"
echo -e "-a\tSet ASIC. Default $ASIC_TYPE."
echo -e "-t\tSet target. Default $TARGET."
echo -e "COMMAND\tstart|stop"
exit 0
;;
a)
ASIC_TYPE=$OPTARG
echo "ASIC type: ${ASIC_TYPE}"
;;
t)
TARGET=$OPTARG
echo "Target: ${TARGET}"
;;
*)
echo "Invalid options"
exit 1
;;
esac
done
COMMAND=${@: -1}
[[ ! ${COMMAND} =~ start|stop ]] && {
echo "Incorrect COMMAND provided. Allowed: start|stop"
exit 1
}
start_all() {
$SAIC_HOME/run.sh -i client -c start -r
$SAIC_HOME/run.sh -i server -c start -a $ASIC_TYPE -t $TARGET -r -p
sudo $SAIC_HOME/veth-create-host.sh sc-server-${ASIC_TYPE}-${TARGET}-run sc-client-run
}
stop_all() {
$SAIC_HOME/run.sh -i server -c stop -a $ASIC_TYPE -t $TARGET
$SAIC_HOME/run.sh -i client -c stop
}
case $COMMAND in
start)
start_all
;;
stop)
stop_all
;;
esac