forked from perftool-incubator/bench-trafficgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trafficgen-import-files
executable file
·102 lines (85 loc) · 3.21 KB
/
trafficgen-import-files
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# -*- mode: sh; indent-tabs-mode: nil; sh-basic-offset: 4 -*-
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=bash
SCRIPT_DIR=$(dirname $0)
trex_config=""
dest_trex_config_path="trex_cfg.yaml"
traffic_profile=""
traffic_generator=""
dest_traffic_profile_path="trafficgen.profile"
while [ ! -z ${1} ]; do
arg=$(echo ${1} | awk -F= '{ print $1 }')
if [ "${arg}" == "--trex-config" ]; then
trex_config=$(echo "${1}" | awk -F= '{ print $2 }')
echo "Found trex config = ${trex_config}"
elif [ "${arg}" == "--traffic-profile" ]; then
traffic_profile=$(echo "${1}" | awk -F= '{ print $2 }')
echo "Found traffic profile = ${traffic_profile}"
elif [ "${arg}" == "--traffic-generator" ]; then
traffic_generator=$(echo "${1}" | awk -F= '{ print $2 }')
echo "Found traffic generator = ${traffic_generator}"
else
echo "Ignoring this argument: ${arg}"
fi
shift
done
if [ -z "${trex_config}" ]; then
echo "No trex config to import detected"
fi
if [ -z "${traffic_profile}" ]; then
if [ "${traffic_generator}" == "trex-txrx-profile" ]; then
echo "ERROR: You must supply --traffic-profile=<profile> when --traffic-generator=trex-txrx-profile"
exit 3
fi
echo "No traffic profile to import detected"
else
if [ "${traffic_generator}" == "trex-txrx" ]; then
echo "ERROR: You supplied a traffic profile (--traffic-profile=${traffic_profile}) while using --traffic-generator=trex-txrx. This does not make sense."
exit 4
fi
fi
trex_config_path=""
traffic_profile_path=""
if [ -n "${CRUCIBLE_HOSTFS_PWD}" ]; then
echo "Using CRUCIBLE_HOSTFS_PWD=${CRUCIBLE_HOSTFS_PWD}"
trex_config_path+="/hostfs/"
traffic_profile_path+="/hostfs/"
traffic_profile_path+=${CRUCIBLE_HOSTFS_PWD}
trex_config_path+=${CRUCIBLE_HOSTFS_PWD}
traffic_profile_path+="/"
trex_config_path+="/"
fi
traffic_profile_path+=${traffic_profile}
trex_config_path+=${trex_config}
if [ ! -z "${trex_config}" ]; then
if [ ! -e "${trex_config_path}" ]; then
echo "ERROR: Could not find trex config [${trex_config_path}]"
exit 1
else
echo "Copying trex config ${trex_config_path} to ${dest_trex_config_path}"
cp "${trex_config_path}" "${dest_trex_config_path}"
echo "Contents of ${dest_trex_config_path}":
cat ${dest_trex_config_path}
fi
fi
if [ ! -z "${traffic_profile}" ]; then
if [ ! -e "${traffic_profile_path}" ]; then
echo "ERROR: Could not find traffic profile [${traffic_profile_path}]"
exit 1
else
echo "Copying traffic profile ${traffic_profile_path} to ${dest_traffic_profile_path}"
/bin/cp "${traffic_profile_path}" "${dest_traffic_profile_path}"
echo "Contents of ${dest_traffic_profile_path}:"
cat ${dest_traffic_profile_path}
echo "Validating JSON traffic profile:"
${SCRIPT_DIR}/trafficgen/validate-traffic-profile.py --json ${dest_traffic_profile_path}
RC=$?
if [ ${RC} == 0 ]; then
echo "JSON traffic profile passed validation"
else
echo "ERROR: JSON traffic profile failed validation"
exit 2
fi
fi
fi
exit 0