forked from rcbops/jenkins-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins-dell-crowbar-admin-node
executable file
·266 lines (235 loc) · 7.4 KB
/
jenkins-dell-crowbar-admin-node
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/bin/bash
#
# $1 = test repo number
#
env
# JENKINS COMMON
[ -e $(dirname $0)/jenkins-deb-common ] || exit 1
. $(dirname $0)/jenkins-deb-common
jenkins_init
jenkins_set_vars
# IPMI VARIABLES
[ -e ~jenkins/.ipmirc ] || exit 1
. ~jenkins/.ipmirc
# Setup global variables
SSH_OPTS='-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
PROPOSAL_NAME="jenkins"
function ipmi_restart() {
set +x
# $1 - IP
ip=$1
log "Running ipmi_restart using:"
log " ip: ${ip}"
# First check the status
# This will return "Chassis Power is off|on"
status=$(ssh openstack@${IPMIHOST} "ipmitool -I lanplus -H ${ip} -U ${DRACUSER} -P ${DRACPASS} chassis power status | cut -d ' ' -f4")
if [ $status == "on" ]; then
# Power is on, we can powercycle
# Gonna wilk it up here
for i in $(seq 1 4); do
ssh openstack@${IPMIHOST} "ipmitool -I lanplus -H ${ip} -U ${DRACUSER} -P ${DRACPASS} chassis power cycle"
done
else
# Power is off, we can poweron
# Gonna wilk it up here
for i in $(seq 1 4); do
ssh openstack@${IPMIHOST} "ipmitool -I lanplus -H ${ip} -U ${DRACUSER} -P ${DRACPASS} chassis power on"
done
fi
# we need to sleep for 5 seconds and make sure the box came back online
sleep 15s
status=$(ssh openstack@${IPMIHOST} "ipmitool -I lanplus -H ${ip} -U ${DRACUSER} -P ${DRACPASS} chassis power status | cut -d ' ' -f4")
if [ $status == "off" ]; then
# Server did not come back online
log "Unable to powercycle server successfully"
exit 1
fi
set -x
}
function ipmi_set_pxe() {
set +x
# $1 - IP
ip=$1
log "Running ipmi_set_pxe using:"
log " ip: ${ip}"
# Gonna wilk it up here
for i in $(seq 1 4); do
ssh openstack@${IPMIHOST} "ipmitool -I lanplus -H ${ip} -U ${DRACUSER} -P ${DRACPASS} chassis bootdev pxe"
done
set -x
}
function ipmi_pxe_reboot() {
# $1 - IP
ip=$1
log "Running ipmi_pxe_reboot using:"
log " ip: ${ip}"
ipmi_set_pxe ${ip}
ipmi_restart ${ip}
}
function ipmi_poweroff() {
set +x
# $1 - IP
ip=$1
log "Running ipmi_poweroff using:"
log " ip: ${ip}"
# Gonna wilk it up here
for i in $(seq 1 4); do
ssh openstack@${IPMIHOST} "ipmitool -I lanplus -H ${ip} -U ${DRACUSER} -P ${DRACPASS} chassis power off"
done
set -x
}
function ipmi_poweron() {
set +x
# $1 - IP
ip=$1
log "Running ipmi_poweron using:"
log " ip: ${ip}"
# Gonna wilk it up here
for i in $(seq 1 4); do
ssh openstack@${IPMIHOST} "ipmitool -I lanplus -H ${ip} -U ${DRACUSER} -P ${DRACPASS} chassis power on"
done
set -x
}
function crowbar_proposal() {
# $1 - Service Name
# $2 - Action (create|commit)
service=$1
action=$2
cmd="/opt/dell/bin/crowbar_${service} -U ${CROWBAR_USER} -P ${CROWBAR_PASS}"
log "Executing crowbar_proposal using:"
log " Service: ${service}"
log " Action: ${action}"
if ! ( ssh ${SSH_OPTS} crowbar@${HEADNODE} "${cmd} proposal ${action} ${PROPOSAL_NAME}" ); then
log "Unable to ${action} the ${service} Proposal"
exit 1
fi
}
function crowbar_proposal_status() {
# $1 - Service Name
# $2 - Wait Time
service=$1
wait_timer=${2:-15} # Default to 15 minutes if no wait_time provided
cmd="/opt/dell/bin/crowbar_${service} -U ${CROWBAR_USER} -P ${CROWBAR_PASS}"
log "Executing crowbar_proposal using:"
log " Service: ${service}"
log " Wait Time: ${wait_timer}"
count=1
while [ $count -lt $wait_timer ]; do
count=$(( count + 1 ))
sleep 60s
if ( ssh ${SSH_OPTS} crowbar@${HEADNODE} "${cmd} proposal show ${PROPOSAL_NAME} | grep crowbar-status | grep success" ); then
log "${service} proposal sucessfully applied"
break
fi
if [ $count == $wait_timer ]; then
log "${service} proposal not applied"
exit 1
fi
done
}
# SETUP ISO NAME
if [ -z "$NOVA_RELEASE" ] || [ -z "$MILESTONE" ] || [ -z "$DISTRELEASE" ]; then
ISONAME="crowbar.iso"
else
BINARY_BUILD_RELEASE=`echo $DISTRELEASE | cut -d'-' -f2`
ISONAME="crowbar-rcb-${NOVA_RELEASE}-${MILESTONE}-${BINARY_BUILD_RELEASE}.iso"
fi
# EXEC CROWBAR BUILD
set +x
ssh openstack@${ISODEST} "sudo /home/openstack/incoming/fixup_crowbar.sh ${ISONAME}"
set -x
# PXE REBOOT HEADNODE
ipmi_pxe_reboot ${HEADNODE_DRAC_IP}
# POWER OFF CONTROLLER NODE / COMPUTE NODE
ipmi_poweroff ${CONTROLLER_DRAC_IP}
ipmi_poweroff ${COMPUTE_DRAC_IP}
# WAIT TO ENSURE TARGET GOES DOWN FOR REBOOT
sleep 60s
# WAIT FOR ADMIN NODE TO HAVE SSH
# This takes ~20 mins
count=1
while [ $count -lt 25 ]; do
count=$(( count + 1 ))
sleep 60s
if ( nc ${HEADNODE} 22 -w 1 -q 0 < /dev/null ); then
break
fi
if [ $count -eq 25 ]; then
log "Server is not network accessible"
exit 1
fi
done
# Give crowbar 10 minutes to install once SSH is available
count=1
while [ $count -lt 10 ]; do
count=$(( count + 1 ))
sleep 60s
if ( ssh ${SSH_OPTS} crowbar@${HEADNODE} 'sudo -i /opt/dell/bin/crowbar_node_state status | grep -e crowbar | grep -e Ready' ); then
break
fi
if [ $count == 10 ]; then
log "Installation of Crowbar Headnode failed"
exit 1
fi
done
sleep 120s
# POWER ON CONTROLLER NODE
ipmi_set_pxe ${CONTROLLER_DRAC_IP}
ipmi_poweron ${CONTROLLER_DRAC_IP}
# Bring up the dedicated Compute Node
ipmi_set_pxe ${COMPUTE_DRAC_IP}
ipmi_poweron ${COMPUTE_DRAC_IP}
# WAIT TO ENSURE TARGET GOES DOWN FOR REBOOT
sleep 60s
## Loop and wait for the Controller node to get discovered
NODECOUNT=2
count=1
while [ $count -lt 20 ]; do
count=$(( count + 1 ))
sleep 60s
ELEMENTS=$(ssh ${SSH_OPTS} crowbar@${HEADNODE} 'sudo -i /opt/dell/bin/crowbar_node_state status --no-ready | grep "^d" | wc -l')
if [ ${ELEMENTS} == ${NODECOUNT} ]; then
log "All nodes discovered"
break
fi
if [ $count -eq 20 ]; then
log "ALL NODES NOT DISCOVERED!!"
ssh ${SSH_OPTS} crowbar@${HEADNODE} 'sudo -i /opt/dell/bin/crowbar_node_state status --no-ready'
exit 1
fi
done
sleep 5
## Ghetto Hack since we are disabling IPMI Barclamp
## SET PXE BOOT on BOTH NODES
ipmi_set_pxe ${CONTROLLER_DRAC_IP}
ipmi_set_pxe ${COMPUTE_DRAC_IP}
##################################################
# Push MYSQL Proposal
crowbar_proposal "mysql" "create"
crowbar_proposal "mysql" "commit"
crowbar_proposal_status "mysql" 30
##################################################
##################################################
# Push the Keystone Proposal
crowbar_proposal "keystone" "create"
crowbar_proposal "keystone" "commit"
crowbar_proposal_status "keystone"
##################################################
##################################################
# Push the Glance Proposal
crowbar_proposal "glance" "create"
crowbar_proposal "glance" "commit"
crowbar_proposal_status "glance"
##################################################
##################################################
# Push the Nova Proposal
crowbar_proposal "nova" "create"
crowbar_proposal "nova" "commit"
crowbar_proposal_status "nova" 30
##################################################
##################################################
# Push the Dash Proposal
crowbar_proposal "nova_dashboard" "create"
crowbar_proposal "nova_dashboard" "commit"
crowbar_proposal_status "nova_dashboard"
##################################################