-
Notifications
You must be signed in to change notification settings - Fork 95
/
build-all.sh
executable file
·214 lines (184 loc) · 6.89 KB
/
build-all.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/bash
set -e
declare -A nodeMap
declare -A variables
declare -A cluster
nodeMap["baremetal"]="east-01 east-02 east-03 east-04 east-05 east-06 east-07"
nodeMap["virt-hosts"]="east-01 east-02 east-03 east-04"
nodeMap["galera"]="rdo7-db1.vmnet rdo7-db2.vmnet rdo7-db3.vmnet"
nodeMap["memcached"]="rdo7-memcache1.vmnet rdo7-memcache2.vmnet rdo7-memcache3.vmnet"
nodeMap["swift-aco"]="rdo7-swift-brick1.vmnet rdo7-swift-brick2.vmnet rdo7-swift-brick3.vmnet"
nodeMap["compute-nodes"]="east-05 east-06 east-07"
nodeMap["controller-managed"]="rdo7-node1.vmnet rdo7-node2.vmnet rdo7-node3.vmnet east-05 east-06 east-07"
nodeMap["vmsnap"]="east-02 east-03 east-04"
cluster["baremetal"]=0
cluster["gateway"]=0
cluster["virt-hosts"]=0
variables["nodes"]=""
variables["network_domain"]="lab.bos.redhat.com"
variables["deployment"]="collapsed"
variables["status"]=0
variables["components"]="lb db rabbitmq memcache mongodb keystone glance cinder swift-brick swift neutron-server neutron-agents ceilometer heat"
variables["scenarios-segregated"]="gateway virt-hosts vmsnap-hacks hacks vmsnap-lb lb vmsnap-galera galera vmsnap-rabbitmq rabbitmq vmsnap-memcached memcached vmsnap-mongodb mongodb vmsnap-keystone keystone vmsnap-glance glance vmsnap-cinder cinder vmsnap-swift-aco swift-aco vmsnap-swift swift vmsnap-neutron-server neutron-server vmsnap-neutron-agents neutron-agents vmsnap-nova nova vmsnap-ceilometer ceilometer vmsnap-heat heat vmsnap-horizon horizon compute-common vmsnap-compute compute-cluster"
variables["scenarios-collapsed"]="gateway virt-hosts vmsnap-hacks hacks vmsnap-basic-cluster basic-cluster vmsnap-lb lb vmsnap-galera galera vmsnap-rabbitmq rabbitmq vmsnap-memcached memcached vmsnap-mongodb mongodb vmsnap-keystone keystone vmsnap-glance glance vmsnap-cinder cinder vmsnap-swift-aco swift-aco vmsnap-swift swift vmsnap-neutron-server neutron-server vmsnap-neutron-agents neutron-agents vmsnap-nova nova vmsnap-ceilometer ceilometer vmsnap-heat heat vmsnap-horizon horizon compute-common vmsnap-compute"
function create_phd_definition() {
scenario=$1
definition=$2
snapshot_name=$3
rm -f ${definition}
nodes=${variables["nodes"]}
if [ "x$nodes" = x ]; then
nodes=${nodeMap[$scenario]}
fi
if [ "x$nodes" = "x" ]; then
for n in `seq 1 3`; do
nodes="$nodes rdo7-${scenario}${n}.vmnet"
done
fi
nodelist="nodes="
for node in $nodes; do
nodelist="${nodelist}${node}.${variables["network_domain"]} "
done
echo "$nodelist" >> ${definition}
if [ -n "${snapshot_name}" ]; then
echo "snapshot_name=${snapshot_name}" >> ${definition}
fi
cat ${definition}
}
generate=0
scenarios=""
while true ; do
case "$1" in
--help|-h|-\?)
echo "$0 "
exit 0;;
-n|--node) variables["nodes"]="${variables["nodes"]} $2"; shift; shift;;
-c|--collapsed) variables["deployment"]="collapsed"; shift;;
-s|--segregated) variables["deployment"]="segregated"; shift;;
-f|--from) fromscenario=$2; shift; shift;;
-t|--to) toscenario=$2; shift; shift;;
-S|--status) variables["status"]=1; shift;;
-g|--generate) generate=1; shift;;
--mrg)
variables["network_domain"]="mpc.lab.eng.bos.redhat.com"
variables["config"]="mrg";
nodeMap["baremetal"]="mrg-01 mrg-02 mrg-03 mrg-04 mrg-07 mrg-08 mrg-09"
nodeMap["virt-hosts"]="mrg-01 mrg-02 mrg-03 mrg-04"
nodeMap["vmsnap"]="mrg-02 mrg-03 mrg-04"
nodeMap["compute-nodes"]="mrg-07 mrg-08 mrg-09"
nodeMap["controller-managed"]="rdo7-node1.vmnet rdo7-node2.vmnet rdo7-node3.vmnet mrg-07 mrg-08 mrg-09"
shift;;
-m|--method) redeploy=$2; shift; shift;;
-i|--instance) instance=$2; shift; shift;;
-x) set -x ; shift;;
--) shift ; break ;;
-*) echo "unknown option: $1"; exit 1;;
"") break;;
*) scenarios="${scenarios} $1"; shift;;
esac
done
if [ -z ${variables["config"]} ]; then
variables["config"]=ha-${variables["deployment"]}
fi
if [ ${variables["status"]} = 1 ]; then
if [ ${variables["deployment"]} != "collapsed" ]; then
scenarios=node
elif [ "x${scenarios}" = x ]; then
scenarios=${variables["components"]}
fi
for scenario in $scenarios; do
ssh rdo7-${scenario}1.vmnet.${variables["network_domain"]} -- crm_mon -1
done
exit 0
fi
if [ "x${scenarios}" = x ]; then
deploy=scenarios-${variables["deployment"]}
scenarios=${variables[${deploy}]}
if [ -z "$redeploy" ]; then
redeploy=full
fi
case $redeploy in
rollback) scenarios="baremetal-rollback $scenarios";;
full) scenarios="beaker baremetal $scenarios";;
*) echo "unknown redeploy method"; exit 1;;
esac
if [ -z "$instance" ]; then
instance=ha
fi
case $instance in
ha) scenarios="$scenarios compute-managed controller-managed";;
single) scenarios="$scenarios compute-cluster";;
*) echo "unknown instance value"; exit 1;;
esac
fi
function run_phd() {
if [ ${generate} = 1 ]; then
scripts=$(phd_exec -s ./pcmk/${1}.scenario -d ${HOME}/phd.${scenario}.conf -V ./pcmk/${variables["config"]}.variables -p | grep PHD_SCPT | sort | awk -F= '{print $2}')
for script in $scripts; do
echo "#### $script"
more "$script"
done
else
phd_exec -s ./pcmk/${1}.scenario -d ${HOME}/phd.${scenario}.conf -V ./pcmk/${variables["config"]}.variables
fi
}
inscenario=0
for scenario in $scenarios; do
if [ -n "$fromscenario" ]; then
if [ "$fromscenario" = "${scenario}" ]; then
inscenario=1
fi
if [ "$inscenario" = 0 ]; then
continue;
fi
fi
snapshot_name=""
if [ ${variables["deployment"]} = "collapsed" ]; then
case $scenario in
vmsnap-rollback-*)
snapshot_name=$(echo $scenario | sed -e 's/vmsnap-rollback-//g')
scenario=vmsnap-rollback
nodeMap[$scenario]=${nodeMap[vmsnap]}
;;
vmsnap-*)
snapshot_name=$(echo $scenario | sed -e 's/vmsnap-//g')
scenario=vmsnap
;;
compute-*)
nodeMap[$scenario]=${nodeMap[compute-nodes]}
;;
beaker|baremetal|gateway)
nodeMap[$scenario]=${nodeMap[baremetal]}
;;
baremetal-rollback)
# stupid hack to avoid spending heaps of time waiting for nfs
# server timeout
list=""
for x in ${nodeMap[baremetal]}; do
list="$x $list"
done
nodeMap[$scenario]="$list"
;;
virt-hosts|controller-managed)
;;
*)
# Overwrite the node list to be the nodes of our collapsed cluster
nodeMap[$scenario]="rdo7-node1.vmnet rdo7-node2.vmnet rdo7-node3.vmnet"
;;
esac
fi
create_phd_definition ${scenario} ${HOME}/phd.${scenario}.conf ${snapshot_name}
if [ x${cluster[${scenario}]} = x0 ]; then
: no need to bootstrap a cluster
elif [ ${variables["deployment"]} != "collapsed" ]; then
: prep a new cluster for ${scenario}
echo "$(date) :: Initializing cluster for scenario $scenario"
run_phd basic-cluster
fi
echo "$(date) :: Beginning scenario $scenario"
run_phd ${scenario}
if [ -n "$toscenario" ] && [ "$toscenario" = ${scenario} ]; then
echo "$(date) :: Reached $scenario. Stop processing"
break;
fi
done