-
Notifications
You must be signed in to change notification settings - Fork 21
/
suse_openstack_cloud
executable file
·578 lines (471 loc) · 18.8 KB
/
suse_openstack_cloud
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
#!/bin/bash
#############################################################
# Name: Supportconfig Plugin for SUSE OpenStack Cloud
# Description: Gathers important troubleshooting information
# about SUSE OpenStack Cloud
# License: GPLv2
# Author: Matt Barringer <[email protected]>
# Modified: 2012 August 29
#############################################################
SVER=1.0.0
RCFILE="/usr/lib/supportconfig/resources/scplugin.rc"
LOG_LINES=10000 # 0 means include the entire file
if [ -s $RCFILE ]; then
if ! source $RCFILE; then
echo "ERROR: Initializing resource file: $RCFILE" >&2
exit 1
fi
fi
validate_rpm_if_installed() {
thisrpm="$1"
echo "#==[ Validating RPM ]=================================#"
if rpm -q "$thisrpm" >/dev/null 2>&1; then
echo "# rpm -V $thisrpm"
if rpm -V "$thisrpm"; then
echo "Status: Passed"
else
echo "Status: WARNING"
fi
else
echo "package $thisrpm is not installed"
echo "Status: Skipped"
fi
echo
}
pconf_files() {
_log_files 0 "Configuration File" "$@"
}
plog_files() {
loglines="$1"
shift
_log_files "$loglines" "Log File" "$@"
}
_log_files() {
loglines="$1" title="$2"
shift 2
for file in "$@"; do
_log_file "$loglines" "$title" "$file"
done
}
_log_file() {
loglines="$1" title="$2" file="$3"
case "$file" in
*.tbz|*.bz2|*.gz|*.zip|*.xz)
continue
;;
esac
if ! [ -f "$file" ]; then
plugin_tag "$title" "$file - File not found"
continue
fi
if [ "$loglines" -eq 0 ]; then
plugin_tag "$title" "$file"
else
plugin_tag "$title" "$file - Last $loglines Lines"
fi
_capture "$loglines" "$file" | _capture_filter
echo
}
_capture() {
loglines="$1" file="$2"
if [ "$loglines" -eq 0 ]; then
cat "$file"
else
tail -"$loglines" "$file"
fi
}
# test via: SUSECLOUD_PLUGIN_TEST=y ./suse_openstack_cloud
_filter_test_cases() {
cat <<EOF
"password": "s3kr1t",
'password': 's3kr1t',
"token": "999888777666",
"bmc_password": "s3kr1t",
"machine-install": { "password": "s3kr1t" },
web_ui_admin_default_password "s3kr1t"
.... "bmc_user"=>"root", "bmc_password"=>"cr0wBar!"}, {"token"=>"l33t", ...
neutron_admin_password=s3kr1t
rabbit_password=s3kr1t
ilo-password: s3kr1t
connection=mysql+pymysql://nova_api:[email protected]/nova
connection = mysql+pymysql://nova_api:[email protected]/nova
sql_connection = postgresql://nova_api:[email protected]/nova
password: p4ssw0rt
service_password: service_p4ssw0rt
stack_domain_admin_password: 4dm1n_p4ssw0rt
auth_encryption_key: 4u7h_ke7
admin_password = secretpass
password = secretpass
password=secret\$pass
password_type=password
stack_domain_password=secret
EOF
}
CENSORED='<<CENSORED BY SUPPORTCONFIG PLUGIN>>'
_expected_test_results=$( cat <<EOF
"password": "$CENSORED",
'password': '$CENSORED',
"token": "$CENSORED",
"bmc_password": "$CENSORED",
"machine-install": { "password": "$CENSORED" },
web_ui_admin_default_password "$CENSORED"
.... "bmc_user"=>"root", "bmc_password"=>"$CENSORED"}, {"token"=>"$CENSORED", ...
neutron_admin_password=$CENSORED
rabbit_password=$CENSORED
ilo-password: $CENSORED
connection=mysql+pymysql://nova_api:[email protected]/nova
connection = mysql+pymysql://nova_api:[email protected]/nova
sql_connection = postgresql://nova_api:[email protected]/nova
password: $CENSORED
service_password: $CENSORED
stack_domain_admin_password: $CENSORED
auth_encryption_key: $CENSORED
admin_password = $CENSORED
password = $CENSORED
password=$CENSORED
password_type=password
stack_domain_password=$CENSORED
EOF
)
_capture_filter() {
sed_args=(
# "password": "s3kr1t",
# "token": "999888777666",
# "bmc_password": "s3kr1t",
# "machine-install": { "password": "s3kr1t" },
-e 's/\("\([a-z_]\+\)\?\(passw\(or\)\?d\|token\)":\? \+"\+\)[^"]\+"/\1'"$CENSORED"'"/gi'
# 'password': 's3kr1t',
-e "s/\('\([a-z_]\+\)\?\(passw\(or\)\?d\|token\)':\? \+'\+\)[^']\+'/\1$CENSORED'/gi"
# web_ui_admin_default_password "s3kr1t"
-e 's/^\( *\([a-z_]\+\)\?passw\(or\)\?d \+"\+\)[^"]\+"/\1'"$CENSORED"'"/i'
# .... "bmc_user"=>"root", "bmc_password"=>"cr0wBar!"}, {"token"=>"l33t", ...
-e 's/\("\([a-z_]\+\)\?\(passw\(or\)\?d\|token\)" *=> *"\+\)[^"]\+"/\1'"$CENSORED"'"/gi'
# neutron_admin_password=s3kr1t
# rabbit_password=s3kr1t
-e 's/^\( *\([a-z_]\+_\)\?password *= *\).\+/\1'"$CENSORED"'/'
# ilo-password: s3kr1t
-e 's/^\( *ilo-password: \).\+/\1'"$CENSORED"'/'
# connection = mysql+pymysql:/://nova_api:[email protected]/nova
-e 's!^\( *\([a-z_]\+_\)\?connection[a-z_]* *= *[a-z+]\+://[a-z_]\+:\)[^@]\+@!\1'"$CENSORED"'@!'
# Filter passwords from crowbar batch export output
# [ ] password: p4ssw0rt
# [ ] service_password: service_p4ssw0rt
# [ ] stack_domain_admin_password: 4dm1n_p4ssw0rt
-e 's/\(^ *\(stack_domain_admin_\|service_\)\?password:\).*/\1 '"$CENSORED"'/'
# [ ] auth_encryption_key: 4u7h_ke7
-e 's/\(^ *auth_encryption_key:\).*/\1 '"$CENSORED"'/'
)
if (( ADD_OPTION_LOGS )); then
sed_args+=( -e 's/^M//g' )
else
sed_args+=(
-e '/^[[:space:]]*#/d'
-e '/^[[:space:]]*;/d'
-e '/^[[:space:]]*\/\//d'
-e 's/^M//g'
-e '/^$/d'
)
fi
sed "${sed_args[@]}"
}
if [ -n "$SUSECLOUD_PLUGIN_TEST" ]; then
tmpdir=$( mktemp -d )
_filter_test_cases | _capture_filter > $tmpdir/got
echo "$_expected_test_results" > $tmpdir/expected
if cmp $tmpdir/{got,expected}; then
rm $tmpdir/{got,expected}
rmdir $tmpdir
exit 0
else
echo "Got unexpected test results:"
diff -u $tmpdir/{got,expected}
echo "Look in $tmpdir"
exit 1
fi
fi
#############################################################
section_header "Supportconfig Plugin for SUSE OpenStack Cloud, v${SVER}"
# The plugin already hardcodes a reference to this directory above, so we're
# not introducing a new coupling with .spec files by using this absolute path here.
rpm_list=/usr/lib/supportconfig/resources/suse-openstack-cloud-rpm-list
for thisrpm in $(cat "$rpm_list"); do
validate_rpm_if_installed "$thisrpm"
done
_find_uncompressed () {
find "$@" ! -name \*.gz ! -name \*.bz2 ! -name \*.xz
}
find_and_pconf_files () {
[ -d "$1" ] || return 0
files=$( _find_uncompressed "$@" )
if [ -n "$files" ]; then
pconf_files $files
fi
}
find_and_plog_files () {
[ -d "$1" ] || return 0
files=$( _find_uncompressed "$@" )
if [ -n "$files" ]; then
plog_files "$LOG_LINES" $files
fi
}
find_and_plog_files_0 () {
[ -d "$1" ] || return 0
files=$( _find_uncompressed "$@" )
if [ -n "$files" ]; then
plog_files 0 $files
fi
}
#############################################################
section_header "Crowbar"
pconf_files \
/etc/crowbar.install.key \
/opt/dell/chef/data_bags/crowbar/template-*.json
find_and_pconf_files /etc/crowbar -type f
find_and_plog_files /opt/dell/crowbar_framework/log -type f
find_and_pconf_files /var/lib/crowbar/config -type f
find_and_pconf_files /var/lib/chef/solr/conf -type f
find_and_plog_files /var/log/nodes -type f
find_and_plog_files /var/log -path /var/log/crowbar\* -type f
find_and_plog_files /var/log/apache2 -type f
plog_files 0 /var/log/monasca-installer.log
plugin_tag "admin node PXE / TFTP configuration"
echo; echo
find /srv/tftpboot -maxdepth 1 -ls
echo; echo
find /srv/tftpboot/suse-* -maxdepth 2 -ls
echo; echo
find /srv/tftpboot/suse-11.3/repos/Cloud-PTF -ls
echo; echo
find /srv/tftpboot/suse-12.0/repos/SLE12-Cloud-Compute-PTF -ls
echo; echo
find /srv/tftpboot/windows-* -maxdepth 2 -ls
echo; echo
find /srv/tftpboot/hyperv-* -maxdepth 2 -ls
echo; echo
find /srv/tftpboot/discovery/pxelinux.cfg -ls
echo; echo
find_and_pconf_files /srv/tftpboot/discovery/pxelinux.cfg -type f
find_and_pconf_files /srv/tftpboot/nodes -type f
echo; echo
find /var/lib/crowbar/upgrade -ls
if ls /var/lib/crowbar/upgrade/*progress.yml >/dev/null 2>&1 ; then
pconf_files /var/lib/crowbar/upgrade/*progress.yml
fi
#############################################################
section_header "Crowbar database"
crowbar_db_dump_file=/opt/dell/crowbar_framework/db/data.yml
su -s /bin/sh - crowbar sh -c "cd /opt/dell/crowbar_framework && RAILS_ENV=production ./bin/rake db:data:dump"
plog_files 0 $crowbar_db_dump_file
rm -f $crowbar_db_dump_file
#############################################################
section_header "MariaDB"
if rpm -q mariadb; then
find_and_plog_files /var/log/mysql -type f
mariadb_variables_file=/tmp/mariadb_variables
mariadb_status_file=/tmp/mariadb_status
mysql -e 'SHOW VARIABLES;' > $mariadb_variables_file
mysql -e 'SHOW STATUS;' > $mariadb_status_file
plog_files 0 $mariadb_variables_file
plog_files 0 $mariadb_status_file
rm -f $mariadb_variables_file
rm -f $mariadb_status_file
fi
#############################################################
section_header "Chef"
# Don't capture private keys/certificates, just show the inode info
[ -d /etc/chef ] && find /etc/chef -type f -name \*.pem -ls
echo; echo
find_and_pconf_files /etc/chef -type f ! -name \*.pem
find_and_plog_files /var/log/chef -type f
find_and_plog_files /var/log/couchdb -type f
plog_files 0 \
/var/chef/cache/chef-stacktrace.out \
/var/chef/cache/failed-run-data.json
find_and_plog_files /root -name screenlog.\*
find_and_plog_files /var/chef/cache -type f -path */pause-file.lock\*
# old files changed by chef; might give a hint about some changes
find_and_pconf_files /var/chef/backup -type f
#############################################################
section_header "Ceph config"
if [ -d /etc/ceph ]; then
if files=$(find /etc/ceph -type f | egrep -v '(/monmap|\.keyring)$'); then
if [ -n "$files" ]; then
pconf_files $files
fi
fi
fi
#############################################################
section_header "Ceph monmap"
if [ -e /etc/ceph/monmap ]; then
monmaptool --print /etc/ceph/monmap
else
echo "/etc/ceph/monmap did not exist"
fi
#############################################################
section_header "Ceph log files"
find_and_plog_files /var/log/ceph -type f
#############################################################
section_header "OpenStack config files"
for svc in keystone rabbitmq glance swift nova cinder neutron heat ceilometer \
manila barbican magnum monasca monasca-log-agent monasca-log-persister \
monasca-log-metrics monasca-log-transformer monasca-notification \
monasca-persister monasca-thresh trove designate sahara ironic ec2api freezer; do
find_and_pconf_files /etc/$svc /opt/stack/service/$svc -type f -regex \
'.*\.\(co?nf\(ig\)?\|ini\|json\|filters\|y\(a\)?ml\)'
# Keep this grouped with other rabbitmq config files
case $svc in
rabbitmq)
pconf_files /etc/rabbitmq/enabled_plugins
;;
neutron)
find_and_pconf_files /var/lib/neutron/ha_confs/
;;
esac
done
for svc in barbican-api barbican-worker ceilometer-agent-notification ceilometer-api ceilometer-common \
ceilometer-polling cinder-api cinder-backup cinder-common cinder-scheduler cinder-volume \
designate-api designate-central designate-mdns designate-pool-manager designate-producer \
designate-worker designate-zone-manager freezer-api glance-api glance-registry \
heat-api heat-api-cfn heat-api-cloudwatch heat-engine horizon ironic-api ironic-conductor \
keystone magnum-api magnum-conductor monasca monasca-api monasca-notification monasca-transform \
neutron nova-api nova-conductor nova-consoleauth nova-novncproxy nova-scheduler octavia \
spark swift-account-auditor swift-account-reaper swift-account-replicator swift-account-server \
swift-common swift-container-auditor swift-container-reconciler swift-container-replicator \
swift-container-server swift-container-sync swift-container-updater swift-object-auditor \
swift-object-expirer swift-object-reconstructor swift-object-replicator swift-object-server \
swift-object-updater swift-proxy-server; do
find_and_pconf_files /opt/stack/service/$svc/etc -type f -regex \
'.*\.\(co?nf\(ig\)?\|ini\|json\|filters\|y\(a\)?ml\)'
done
pconf_files /srv/www/openstack-dashboard/openstack_dashboard/local/local_settings.py
find_and_pconf_files /srv/www/openstack-dashboard/openstack_dashboard/local/local_settings.d -type f -regex '.*\.py'
#############################################################
section_header "OpenStack log files"
for svc in keystone rabbitmq qpidd glance swift nova cinder neutron heat ceilometer \
manila barbican magnum monasca monasca-api monasca-log-metrics \
monasca-log-transformer monasca-persister monasca-agent monasca-log-agent \
monasca-log-persister monasca-notification trove designate sahara ironic ec2-api freezer; do
find_and_plog_files /var/log/$svc -type f
done
#############################################################
section_header "Open vSwitch config files"
find_and_pconf_files /etc/openvswitch -type f
#############################################################
section_header "Open vSwitch log files"
find_and_plog_files /var/log/openvswitch -type f
#############################################################
section_header "MongoDB log files"
find_and_plog_files /var/log/mongodb -type f
#############################################################
section_header "Kafka config files"
find_and_pconf_files /etc/kafka -type f
#############################################################
section_header "Kafka log files"
find_and_plog_files /var/log/kafka -type f
#############################################################
section_header "Storm config files"
find_and_pconf_files /etc/storm -type f
#############################################################
section_header "Storm log files"
find_and_plog_files /var/log/storm -type f
#############################################################
section_header "elasticsearch config files"
find_and_pconf_files /etc/elasticsearch -type f
#############################################################
section_header "elasticsearch log files"
find_and_plog_files /var/log/elasticsearch -type f
#############################################################
section_header "kibana config files"
find_and_pconf_files /etc/kibana -type f
#############################################################
section_header "kibana log files"
find_and_plog_files /var/log/kibana -type f
#############################################################
section_header "zookeeper config files"
find_and_pconf_files /etc/zookeeper -type f
#############################################################
section_header "zookeeper log files"
find_and_plog_files /var/log/zookeeper -type f
#############################################################
section_header "ansible config files"
find_and_pconf_files /etc/ansible -type f
#############################################################
section_header "Corosync config"
if [ -d /etc/corosync ]; then
if files=$(find /etc/corosync/ -type f | egrep -v 'authkey$'); then
if [ -n "$files" ]; then
pconf_files $files
fi
fi
fi
#############################################################
section_header "Cluster log files"
if [ -d /var/log/cluster/ ]; then
find_and_plog_files /var/log/cluster -type f
fi
#############################################################
section_header "Backup and Restore log files"
if [ -e /var/log/crowbar/backup-restore.log ]; then
plog_files 0 /var/log/crowbar/backup-restore.log
fi
#############################################################
section_header "Barclamp configuration details collected with crowbar batch export"
if [ -e /opt/dell/bin/crowbar_batch ]; then
crowbar batch export > /var/log/crowbar/batch-export.log
plog_files 0 /var/log/crowbar/batch-export.log
rm /var/log/crowbar/batch-export.log
fi
#############################################################
section_header "Chef data"
if [ -e /var/lib/crowbar/install/crowbar-installed-ok ]; then
chef_export_dir=/var/log/crowbar/chef-export
mkdir -p ${chef_export_dir}/{node,role,databag}
for node in $(knife node list); do
knife node show -F json -l $node > ${chef_export_dir}/node/${node}.json
done
for role in $(knife role list); do
knife role show -F json $role > ${chef_export_dir}/role/${role}.json
done
for databag in $(knife data bag list); do
mkdir -p ${chef_export_dir}/databag/${databag}
for item in $(knife data bag show $databag); do
knife data bag show -F json $databag $item > ${chef_export_dir}/databag/${databag}/${item}.json
done
done
find_and_plog_files_0 $chef_export_dir -type f
rm -rf $chef_export_dir
fi
###############################################################
section_header "RabbitMQ broker"
if [ -e /usr/sbin/rabbitmqctl ]; then
rabbitmqctl_report=/var/log/rabbitmq/rabbitmq_report
timeout 3 /usr/sbin/rabbitmqctl report &> ${rabbitmqctl_report}
plog_files 0 ${rabbitmqctl_report}
rm ${rabbitmqctl_report}
fi
###############################################################
section_header "mkcloud"
# This will not always collect files from customer clouds, but will
# help with internal development.
plog_files 0 /etc/motd
plog_files 0 /root/mkcloud.config
find_and_plog_files_0 /root -name \*.proposal
###############################################################
section_header "ardana"
plog_files 0 /var/lib/ardana/.ansible/ansible.log
find_and_plog_files_0 \
/var/lib/ardana/openstack/my_cloud \
/var/lib/ardana/scratch/ansible/next/ardana/ansible \
/var/log/ardana-service/logs '( -type f -o -type l )'
find_and_plog_files_0 \
/var/lib/ardana/openstack/my_cloud/config -type l
find_and_pconf_files 0 /etc/ardana-service -type f
pconf_files \
/var/lib/ardana/.ansible.cfg \
/opt/ardana_packager/ardana-*/sles_venv/*packages
###############################################################
section_header "ops-console"
# Ops Console only on Ardana based deployments
if [ -d /var/log/ops-console/ ]; then
find_and_plog_files /var/log/ops-console -type f
fi