-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdosarray_config.sh
145 lines (130 loc) · 6.77 KB
/
dosarray_config.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#/bin/sh -e
# Configuration for DoSarray
# Nik Sultana, February 2018, UPenn
#
# Use of this source code is governed by the Apache 2.0 license; see LICENSE
export DOSARRAY_VERSION="0.5"
export DOSARRAY_IMAGE="dosarray_image_v0.2a"
# NOTE we only include cluster machines that participate in the experiment in
# one form or another. We exclude machines that are not to be touched
# by DoSarray. We do include machines running "targets" however -- DoSarray
# won't start containers on these machines, but it will poll their load.
export DOSARRAY_PHYSICAL_HOSTS_PRIV=( 192.168.0.2 192.168.0.3 192.168.0.4 192.168.0.5 192.168.0.6 192.168.0.7 192.168.0.8 192.168.0.9 )
export DOSARRAY_VIRT_NET_SUFFIX=( 2 3 4 5 6 7 8 9 )
# NOTE names in DOSARRAY_PHYSICAL_HOSTS_PUB are "public" only as far as the
# access node is concerned. If there's no access node then they're
# expected to be public (i.e., directly accessible from the monitor),
# otherwise we need to hop through the access node. There may a sequence
# of access nodes we need to use, in general.
export DOSARRAY_PHYSICAL_HOSTS_PUB=( dedos01 dedos02 dedos03 dedos04 dedos05 dedos06 dedos07 dedos08 )
export DOSARRAY_HOST_INTERFACE_MAP=( em1 em1 em1 em1 em1 em1 em1 em1 )
export DOSARRAY_VIRT_NET_PREFIX="192.168."
export DOSARRAY_VIRT_NETS=( "${DOSARRAY_VIRT_NET_PREFIX}${DOSARRAY_VIRT_NET_SUFFIX[0]}." "${DOSARRAY_VIRT_NET_PREFIX}${DOSARRAY_VIRT_NET_SUFFIX[1]}." "${DOSARRAY_VIRT_NET_PREFIX}${DOSARRAY_VIRT_NET_SUFFIX[2]}." "${DOSARRAY_VIRT_NET_PREFIX}${DOSARRAY_VIRT_NET_SUFFIX[3]}." "${DOSARRAY_VIRT_NET_PREFIX}${DOSARRAY_VIRT_NET_SUFFIX[4]}." "${DOSARRAY_VIRT_NET_PREFIX}${DOSARRAY_VIRT_NET_SUFFIX[5]}." "${DOSARRAY_VIRT_NET_PREFIX}${DOSARRAY_VIRT_NET_SUFFIX[6]}." "${DOSARRAY_VIRT_NET_PREFIX}${DOSARRAY_VIRT_NET_SUFFIX[7]}." )
export DOSARRAY_TARGET_SERVER_INDEX=0
export DOSARRAY_HOST_COLORS=( '#555555' '#777777' '#999999' '#BBBBBB' '#DDDDDD' '#FFFFFF' '#EEEEEE' '#AAAAAA' )
USERNAME=
SSH_PARAMS=
SCP_PARAMS=
DOMAIN=
# Check that DOSARRAY_PHYSICAL_HOSTS_PRIV, DOSARRAY_VIRT_NET_SUFFIX, etc all have the same number of elements.
if [ ${#DOSARRAY_PHYSICAL_HOSTS_PRIV[@]} -ne ${#DOSARRAY_VIRT_NET_SUFFIX[@]} ]
then
printf "Check dosarray_config.sh for errors \nDOSARRAY_PHYSICAL_HOSTS_PRIV=${#DOSARRAY_PHYSICAL_HOSTS_PRIV[@]} elements \nDOSARRAY_VIRT_NET_SUFFIX=${#DOSARRAY_VIRT_NET_SUFFIX[@]} elements\n" >&2
exit 1
elif [ ${#DOSARRAY_VIRT_NET_SUFFIX[@]} -ne ${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} ]
then
printf "Check dosarray_config.sh for errors \nDOSARRAY_VIRT_NET_SUFFIX=${#DOSARRAY_VIRT_NET_SUFFIX[@]} elements \nDOSARRAY_PHYSICAL_HOSTS_PUB=${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} elements\n" >&2
exit 1
elif [ ${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} -ne ${#DOSARRAY_HOST_INTERFACE_MAP[@]} ]
then
printf "Check dosarray_config.sh for errors \nDOSARRAY_PHYSICAL_HOSTS_PUB=${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} elements \nDOSARRAY_HOST_INTERFACE_MAP=${#DOSARRAY_HOST_INTERFACE_MAP[@]} elements\n" >&2
exit 1
elif [ ${#DOSARRAY_HOST_INTERFACE_MAP[@]} -ne ${#DOSARRAY_VIRT_NETS[@]} ]
then
printf "Check dosarray_config.sh for errors \nDOSARRAY_HOST_INTERFACE_MAP=${#DOSARRAY_HOST_INTERFACE_MAP[@]} elements \nDOSARRAY_VIRT_NETS=${#DOSARRAY_VIRT_NETS[@]} elements\n" >&2
exit 1
elif [ ${#DOSARRAY_VIRT_NETS[@]} -ne ${#DOSARRAY_HOST_COLORS[@]} ]
then
printf "Check dosarray_config.sh for errors \nDOSARRAY_VIRT_NETS=${#DOSARRAY_VIRT_NETS[@]} elements \nDOSARRAY_HOST_COLORS=${#DOSARRAY_HOST_COLORS[@]} elements\n" >&2
exit 1
fi
# Check if target index is within allowed range
if [ ${DOSARRAY_TARGET_SERVER_INDEX} -ge $(( ${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} - 1 )) ]
then
printf "Check dosarray_config.sh for errors \nDOSARRAY_TARGET_SERVER_INDEX cannot exceed $(( ${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} - 1 ))" >&2
exit 1
fi
function dosarray_physical_hosts_skip () {
if [ ${DOSARRAY_TARGET_SERVER_INDEX} -eq 0 ]
then
echo `seq $(( ${DOSARRAY_TARGET_SERVER_INDEX} + 1)) $(( ${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} - 1 ))`
elif [ ${DOSARRAY_TARGET_SERVER_INDEX} -eq $(( ${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} - 1 )) ]
then
echo `seq 0 $(( ${DOSARRAY_TARGET_SERVER_INDEX} - 1))`
else
index=(`seq 0 $(( ${DOSARRAY_TARGET_SERVER_INDEX} - 1))` `seq $(( ${DOSARRAY_TARGET_SERVER_INDEX} + 1)) $(( ${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} - 1 ))`)
echo ${index[@]}
fi
}
export -f dosarray_physical_hosts_skip
export DOSARRAY_PHYSICAL_HOST_IDXS=("`seq 0 $(( ${#DOSARRAY_PHYSICAL_HOSTS_PUB[@]} - 1))`")
export DOSARRAY_CONTAINER_HOST_IDXS=`dosarray_physical_hosts_skip`
export DOSARRAY_VIRT_INSTANCES=10
export DOSARRAY_MIN_VIP=2
export DOSARRAY_MAX_VIP=$((DOSARRAY_VIRT_INSTANCES + (DOSARRAY_MIN_VIP - 1)))
function dosarray_execute_on () {
local HOST_NAME="$1"
local CMD="$2"
local SSH_PARAM="$3"
local CAPTURE_REMOTE_RESULT="$4"
local POST_COMMAND="$5"
if [ "${CAPTURE_REMOTE_RESULT}" == "" ] || [ -z "${CAPTURE_REMOTE_RESULT}" ]
then
ssh -t ${SSH_PARAMS} ${USERNAME}@${HOST_NAME}.${DOMAIN} ${SSH_PARAM} "${CMD}" ${POST_COMMAND}
else
# NOTE using "tr" to strip the carriage return we get from using ssh, otherwise it'll confuse downstream consumers of REMOTE_RESULT
REMOTE_RESULT=$(ssh -t ${SSH_PARAMS} ${USERNAME}@${HOST_NAME}.${DOMAIN} ${SSH_PARAM} "${CMD}" | tr -d '')
fi
}
export -f dosarray_execute_on
# NOTE the "from" and "to" parameters must mention specific files -- they cannot
# simply be paths, and cannot include wildcards, otherwise the behaviour
# breaks across access hops (where temporary files are created as the
# files are copied between FROM and TO).
function dosarray_scp_from () {
local HOST_NAME="$1"
local FROM="$2"
local TO="$3"
scp ${SCP_PARAMS} -r ${USERNAME}@${HOST_NAME}.${DOMAIN}:${FROM} ${TO}
}
export -f dosarray_scp_from
# NOTE the "file" and "to" parameters must mention specific files -- they cannot
# simply be paths, and cannot include wildcards, otherwise the behaviour
# breaks across access hops (where temporary files are created as the
# files are copied between FILE and TO).
function dosarray_scp_to () {
local HOST_NAME="$1"
local FILE="$2"
local TO="$3"
scp ${SCP_PARAMS} ${FILE} ${USERNAME}@${HOST_NAME}.${DOMAIN}:${TO}
}
export -f dosarray_scp_to
function dosarray_cp_and_execute_on () {
local HOST_NAME="$1"
local CMD="$2"
local SSH_PARAM="$3"
local CAPTURE_REMOTE_RESULT="$4"
local POST_COMMAND="$5"
dosarray_execute_on "${HOST_NAME}" "${CMD}" "${SSH_PARAM}" "${CAPTURE_REMOTE_RESULT}" "${POST_COMMAND}"
}
export -f dosarray_cp_and_execute_on
export DOSARRAY_CONTAINER_PREFIX="c"
export DOSARRAY_LOG_NAME_PREFIX="${DOSARRAY_CONTAINER_PREFIX}"
export DOSARRAY_LOG_PATH_PREFIX="/home/${USERNAME}"
# Set for dosrray_run_http_experiment.sh
# FIXME prefix with DOSARRAY_
# DESTINATION_DIR
# ATTACK_STARTS_AT
# ATTACK_LASTS_FOR
# EXPERIMENT_DURATION