/
tripleo.sh
executable file
·1672 lines (1454 loc) · 64.6 KB
/
tripleo.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
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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Copyright 2015 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
##############################################################################
# tripleo.sh is a script to automate a TripleO setup. It's goals are to be
# used in aiding:
#
# - developer setups
# - CI
# - documentation generation (hopefully)
#
# It's not a new CLI, or end user facing wrapper around existing TripleO
# CLI's.
#
# tripleo.sh should never contain any "business" logic in it that is
# necessary for a successful deployment. It should instead just mirror the
# steps that we document for TripleO end users.
#
##############################################################################
set -eu
set -o pipefail
SCRIPT_NAME=${SCRIPT_NAME:-$(basename $0)}
function show_options {
echo "Usage: $SCRIPT_NAME [options]"
echo
echo "Automates TripleO setup steps."
echo
echo "$SCRIPT_NAME is also configurable via environment variables, most of"
echo "which are not exposed via cli args for simplicity. See the source"
echo "for the set of environment variables that can be overridden."
echo
echo "Note that cli args always take precedence over environment"
echo "variables."
echo
echo "Options:"
echo " --repo-setup -- Perform repository setup."
echo " --delorean-setup -- Install local delorean build environment."
echo " --delorean-build -- Build a delorean package locally"
echo " --multinode-setup -- Perform multinode setup."
echo " --bootstrap-subnodes -- Perform bootstrap setup on subnodes."
echo " --setup-nodepool-files -- Setup nodepool files on subnodes."
echo " --undercloud -- Install the undercloud."
echo " --overcloud-images -- Build and load overcloud images."
echo " --register-nodes -- Register and configure nodes."
echo " --introspect-nodes -- Introspect nodes."
echo " --undercloud-upgrade -- Upgrade a deployed undercloud."
echo " --overcloud-deploy -- Deploy an overcloud."
echo " --overcloud-update -- Update a deployed overcloud."
echo " --overcloud-upgrade -- Upgrade a deployed overcloud."
echo " --overcloud-upgrade-converge -- Finish (converge) upgrade of a deployed overcloud."
echo " --overcloud-delete -- Delete the overcloud."
echo " --use-containers -- Use a containerized compute node."
echo " --enable-check -- Enable checks on update."
echo " --overcloud-pingtest -- Run a tenant vm, attach and ping floating IP."
echo " --overcloud-sanitytest -- Run some basic crud checks for each service."
echo " --skip-sanitytest-create -- Do not create resources when performing a sanitytest (assume they exist)."
echo " --skip-sanitytest-cleanup -- Do not delete the created resources when performing a sanitytest."
echo " --skip-pingtest-cleanup -- For debuging purposes, do not delete the created resources when performing a pingtest."
echo " --run-tempest -- Run tempest tests."
echo " --all, -a -- Run all of the above commands."
echo " -x -- enable tracing"
echo " --help, -h -- Print this help message."
echo
exit 1
}
if [ ${#@} = 0 ]; then
show_options
exit 1
fi
TEMP=$(getopt -o ,h \
-l,help,repo-setup,delorean-setup,delorean-build,multinode-setup,bootstrap-subnodes,undercloud,overcloud-images,register-nodes,introspect-nodes,overcloud-deploy,overcloud-update,overcloud-upgrade,overcloud-upgrade-converge,overcloud-delete,use-containers,overcloud-pingtest,undercloud-upgrade,skip-pingtest-cleanup,all,enable-check,run-tempest,setup-nodepool-files,overcloud-sanitytest,skip-sanitytest-create,skip-sanitytest-cleanup \
-o,x,h,a \
-n $SCRIPT_NAME -- "$@")
if [ $? != 0 ]; then
show_options
exit 1
fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
TRIPLEO_ROOT=${TRIPLEO_ROOT:-$HOME/tripleo}
# Source deploy.env if it exists. It should exist if we are running under
# tripleo-ci
if [ -f "$TRIPLEO_ROOT/tripleo-ci/deploy.env" ]; then
source $TRIPLEO_ROOT/tripleo-ci/deploy.env
fi
ALL=${ALL:-""}
TRIPLEO_HEAT_TEMPLATES_ROOT=${TRIPLEO_HEAT_TEMPLATES_ROOT:-"/usr/share/openstack-tripleo-heat-templates"}
CONTAINER_ARGS=${CONTAINER_ARGS:-"-e ${TRIPLEO_HEAT_TEMPLATES_ROOT}/environments/docker.yaml --libvirt-type=qemu"}
STABLE_RELEASE=${STABLE_RELEASE:-}
REVIEW_RELEASE=${REVIEW_RELEASE:-}
UPGRADE_RELEASE=${UPGRADE_RELEASE:-""}
DELOREAN_REPO_FILE=${DELOREAN_REPO_FILE:-"delorean.repo"}
DELOREAN_REPO_URL=${DELOREAN_REPO_URL:-"\
https://trunk.rdoproject.org/centos7/current-tripleo/"}
DELOREAN_STABLE_REPO_URL=${DELOREAN_STABLE_REPO_URL:-"\
https://trunk.rdoproject.org/centos7-$STABLE_RELEASE/current/"}
ATOMIC_URL=${ATOMIC_URL:-"https://download.fedoraproject.org/pub/alt/atomic/stable/Cloud-Images/x86_64/Images/Fedora-Cloud-Atomic-23-20160308.x86_64.qcow2"}
INSTACKENV_JSON_PATH=${INSTACKENV_JSON_PATH:-"$HOME/instackenv.json"}
INTROSPECT_NODES=${INTROSPECT_NODES:-""}
REGISTER_NODES=${REGISTER_NODES:-""}
OVERCLOUD_DEPLOY=${OVERCLOUD_DEPLOY:-""}
OVERCLOUD_DELETE=${OVERCLOUD_DELETE:-""}
OVERCLOUD_DELETE_TIMEOUT=${OVERCLOUD_DELETE_TIMEOUT:-"300"}
OVERCLOUD_DEPLOY_ARGS=${OVERCLOUD_DEPLOY_ARGS:-""}
# --validation-errors-fatal was deprecated in newton and removed in ocata
if [[ "${STABLE_RELEASE}" = "mitaka" ]]; then
OVERCLOUD_VALIDATE_ARGS=${OVERCLOUD_VALIDATE_ARGS-"--validation-errors-fatal --validation-warnings-fatal"}
else
OVERCLOUD_VALIDATE_ARGS=${OVERCLOUD_VALIDATE_ARGS-"--validation-warnings-fatal"}
fi
OVERCLOUD_UPDATE=${OVERCLOUD_UPDATE:-""}
OVERCLOUD_UPGRADE=${OVERCLOUD_UPGRADE:-""}
OVERCLOUD_UPGRADE_CONVERGE=${OVERCLOUD_UPGRADE_CONVERGE:-""}
OVERCLOUD_UPDATE_RM_FILES=${OVERCLOUD_UPDATE_RM_FILES:-"1"}
OVERCLOUD_UPDATE_ARGS=${OVERCLOUD_UPDATE_ARGS:-"$OVERCLOUD_DEPLOY_ARGS $OVERCLOUD_VALIDATE_ARGS"}
OVERCLOUD_UPDATE_CHECK=${OVERCLOUD_UPDATE_CHECK:-}
OVERCLOUD_IMAGES_PATH=${OVERCLOUD_IMAGES_PATH:-"$HOME"}
OVERCLOUD_IMAGES_YAML_PATH=${OVERCLOUD_IMAGES_YAML_PATH:-"/usr/share/openstack-tripleo-common/image-yaml"}
OVERCLOUD_IMAGES=${OVERCLOUD_IMAGES:-""}
OVERCLOUD_IMAGES_LEGACY_ARGS=${OVERCLOUD_IMAGES_LEGACY_ARGS:-"--all"}
OVERCLOUD_IMAGES_ARGS=${OVERCLOUD_IMAGES_ARGS:-"--output-directory $OVERCLOUD_IMAGES_PATH --config-file $OVERCLOUD_IMAGES_YAML_PATH/overcloud-images.yaml --config-file $OVERCLOUD_IMAGES_YAML_PATH/overcloud-images-centos7.yaml"}
OVERCLOUD_NAME=${OVERCLOUD_NAME:-"overcloud"}
OVERCLOUD_UPGRADE_THT_PATH=${OVERCLOUD_UPGRADE_THT_PATH:-"/usr/share/openstack-tripleo-heat-templates"}
OVERCLOUD_UPGRADE_ARGS=${OVERCLOUD_UPGRADE_ARGS:-"-e $OVERCLOUD_UPGRADE_THT_PATH/overcloud-resource-registry-puppet.yaml $OVERCLOUD_DEPLOY_ARGS -e $OVERCLOUD_UPGRADE_THT_PATH/environments/major-upgrade-composable-steps.yaml -e $HOME/init-repo.yaml --templates $OVERCLOUD_UPGRADE_THT_PATH"}
OVERCLOUD_UPGRADE_CONVERGE_ARGS=${OVERCLOUD_UPGRADE_CONVERGE_ARGS:-"-e $OVERCLOUD_UPGRADE_THT_PATH/overcloud-resource-registry-puppet.yaml $OVERCLOUD_DEPLOY_ARGS -e $OVERCLOUD_UPGRADE_THT_PATH/environments/major-upgrade-converge.yaml --templates $OVERCLOUD_UPGRADE_THT_PATH"}
UNDERCLOUD_UPGRADE=${UNDERCLOUD_UPGRADE:-""}
OVERCLOUD_SANITYTEST_SKIP_CREATE=${OVERCLOUD_SANITYTEST_SKIP_CREATE:-""}
OVERCLOUD_SANITYTEST_SKIP_CLEANUP=${OVERCLOUD_SANITYTEST_SKIP_CLEANUP:-""}
OVERCLOUD_SANITYTEST=${OVERCLOUD_SANITYTEST:-""}
SANITYTEST_CONTENT_NAME=${SANITYTEST_CONTENT_NAME:-"sanity_test"}
SKIP_PINGTEST_CLEANUP=${SKIP_PINGTEST_CLEANUP:-""}
OVERCLOUD_PINGTEST=${OVERCLOUD_PINGTEST:-""}
UNDERCLOUD_SANITY_CHECK=${UNDERCLOUD_SANITY_CHECK:-""}
REPO_SETUP=${REPO_SETUP:-""}
REPO_PREFIX=${REPO_PREFIX:-"/etc/yum.repos.d/"}
CACHEUPLOAD=${CACHEUPLOAD:-"0"}
OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF=${OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF:-"\
$REPO_PREFIX/delorean.repo \
$REPO_PREFIX/delorean-current.repo \
$REPO_PREFIX/delorean-deps.repo"}
# Use Ceph/Jewel for all but mitaka
if [[ "${STABLE_RELEASE}" = "mitaka" ]] ; then
CEPH_RELEASE=hammer
else
CEPH_RELEASE=jewel
fi
CEPH_REPO_FILE=centos-ceph-$CEPH_RELEASE.repo
if [[ -e /etc/ci/mirror_info.sh ]]; then
source /etc/ci/mirror_info.sh
fi
NODEPOOL_CENTOS_MIRROR=${NODEPOOL_CENTOS_MIRROR:-http://mirror.centos.org/centos}
NODEPOOL_RDO_PROXY=${NODEPOOL_RDO_PROXY:-https://trunk.rdoproject.org}
NODEPOOL_BUILDLOGS_CENTOS_PROXY="${NODEPOOL_BUILDLOGS_CENTOS_PROXY:-https://buildlogs.centos.org}"
OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF=${OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF}"\
$REPO_PREFIX/$CEPH_REPO_FILE"
OPSTOOLS_REPO_ENABLED=${OPSTOOLS_REPO_ENABLED:-"0"}
if [[ "${OPSTOOLS_REPO_ENABLED}" = 1 ]]; then
OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF=${OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF}"\
$REPO_PREFIX/centos-opstools.repo"
fi
FEATURE_BRANCH=${FEATURE_BRANCH:-}
DELOREAN_SETUP=${DELOREAN_SETUP:-""}
DELOREAN_BUILD=${DELOREAN_BUILD:-""}
MULTINODE_SETUP=${MULTINODE_SETUP:-""}
MULTINODE_ENV_NAME=${MULTINODE_ENV_NAME:-}
MTU=${MTU:-"1450"}
BOOTSTRAP_SUBNODES=${BOOTSTRAP_SUBNODES:-""}
SETUP_NODEPOOL_FILES=${SETUP_NODEPOOL_FILES:-""}
PRIMARY_NODE_IP=${PRIMARY_NODE_IP:-""}
SUB_NODE_IPS=${SUB_NODE_IPS:-""}
NODEPOOL_REGION=${NODEPOOL_REGION:-"nodepool_region"}
NODEPOOL_CLOUD=${NODEPOOL_CLOUD:-"nodepool_cloud"}
STDERR=/dev/null
UNDERCLOUD=${UNDERCLOUD:-""}
UNDERCLOUD_CONF=${UNDERCLOUD_CONF:-"/usr/share/instack-undercloud/undercloud.conf.sample"}
UNDERCLOUD_SSL=${UNDERCLOUD_SSL:-""}
BASE=${BASE:-$TRIPLEO_ROOT}
USE_CONTAINERS=${USE_CONTAINERS:-""}
TEMPEST_RUN=${TEMPEST_RUN:-""}
TEMPEST_ARGS=${TEMPEST_ARGS:-"--parallel --subunit"}
TEMPEST_ADD_CONFIG=${TEMPEST_ADD_CONFIG:-}
TEMPEST_REGEX=${TEMPEST_REGEX:-"^(?=(.*smoke))(?!(tempest.api.orchestration.stacks|tempest.scenario.test_volume_boot_pattern|tempest.api.telemetry))"}
TEMPEST_PINNED="72ccabcb685df7c3e28cd25639b05d8a031901c8"
SSH_OPTIONS=${SSH_OPTIONS:-'-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=Verbose -o PasswordAuthentication=no -o ConnectionAttempts=32'}
ALT_OVERCLOUDRC=${ALT_OVERCLOUDRC:-""}
export SCRIPTS_DIR=$(dirname ${BASH_SOURCE[0]:-$0})
OVB=${OVB:-0}
if [[ "${STABLE_RELEASE}" = "mitaka" ]] ; then
export OS_IMAGE_API_VERSION=1
fi
# Make sure we use Puppet to deploy packages on scenario upgrades jobs after ocata release
if [[ "${STABLE_RELEASE}" != "newton" ]] ; then
OVERCLOUD_UPGRADE_ARGS="$OVERCLOUD_UPGRADE_ARGS -e $TRIPLEO_ROOT/tripleo-ci/test-environments/enable_package_install.yaml "
OVERCLOUD_UPGRADE_CONVERGE_ARGS="$OVERCLOUD_UPGRADE_CONVERGE_ARGS -e $TRIPLEO_ROOT/tripleo-ci/test-environments/enable_package_install.yaml "
fi
# Temporary workarounds
while true ; do
case "$1" in
--all|-a ) ALL="1"; shift 1;;
--use-containers) USE_CONTAINERS="1"; shift 1;;
--enable-check) OVERCLOUD_UPDATE_CHECK="1"; shift 1;;
--introspect-nodes) INTROSPECT_NODES="1"; shift 1;;
--register-nodes) REGISTER_NODES="1"; shift 1;;
--overcloud-deploy) OVERCLOUD_DEPLOY="1"; shift 1;;
--overcloud-update) OVERCLOUD_UPDATE="1"; shift 1;;
--overcloud-upgrade) OVERCLOUD_UPGRADE="1"; shift 1;;
--overcloud-upgrade-converge) OVERCLOUD_UPGRADE_CONVERGE="1"; shift 1;;
--overcloud-delete) OVERCLOUD_DELETE="1"; shift 1;;
--overcloud-images) OVERCLOUD_IMAGES="1"; shift 1;;
--overcloud-pingtest) OVERCLOUD_PINGTEST="1"; shift 1;;
--skip-pingtest-cleanup) SKIP_PINGTEST_CLEANUP="1"; shift 1;;
--overcloud-sanitytest) OVERCLOUD_SANITYTEST="1"; shift 1;;
--skip-sanitytest-create) OVERCLOUD_SANITYTEST_SKIP_CREATE="1"; shift 1;;
--skip-sanitytest-cleanup) OVERCLOUD_SANITYTEST_SKIP_CLEANUP="1"; shift 1;;
--run-tempest) TEMPEST_RUN="1"; shift 1;;
--repo-setup) REPO_SETUP="1"; shift 1;;
--delorean-setup) DELOREAN_SETUP="1"; shift 1;;
--delorean-build) DELOREAN_BUILD="1"; shift 1;;
--undercloud) UNDERCLOUD="1"; shift 1;;
--undercloud-upgrade) UNDERCLOUD_UPGRADE="1"; shift 1;;
--multinode-setup) MULTINODE_SETUP="1"; shift 1;;
--bootstrap-subnodes) BOOTSTRAP_SUBNODES="1"; shift 1;;
--setup-nodepool-files) SETUP_NODEPOOL_FILES="1"; shift 1;;
-x) set -x; STDERR=/dev/stderr; shift 1;;
-h | --help) show_options 0;;
--) shift ; break ;;
*) echo "Error: unsupported option $1." ; exit 1 ;;
esac
done
function log {
echo "#################"
echo -n "$SCRIPT_NAME -- "
echo $@
echo "#################"
}
function source_rc {
if [ $1 = "stackrc" ] ; then cloud="Undercloud"; else cloud="Overcloud"; fi
echo "You must source a $1 file for the $cloud."
echo "Attempting to source $HOME/$1"
source $HOME/$1
echo "Done"
}
function stackrc_check {
source_rc "stackrc"
}
function overcloudrc_check {
if [ -z "$ALT_OVERCLOUDRC" ]; then
source_rc "overcloudrc"
else
source_rc "$ALT_OVERCLOUDRC"
fi
}
function repo_setup {
log "Repository setup"
sudo yum clean metadata
# sets $TRIPLEO_OS_FAMILY and $TRIPLEO_OS_DISTRO
source $(dirname ${BASH_SOURCE[0]:-$0})/set-os-type
if [ "$TRIPLEO_OS_DISTRO" = "centos" ]; then
# Enable Storage/SIG Ceph repo
if [[ "${STABLE_RELEASE}" = "mitaka" ]] ; then
if rpm -q centos-release-ceph-hammer; then
sudo yum -y erase centos-release-ceph-hammer
fi
else
if rpm -q centos-release-ceph-jewel; then
sudo yum -y erase centos-release-ceph-jewel
fi
fi
sudo /bin/bash -c "cat <<-EOF>$REPO_PREFIX/$CEPH_REPO_FILE
[centos-ceph-$CEPH_RELEASE]
name=centos-ceph-$CEPH_RELEASE
baseurl=$NODEPOOL_CENTOS_MIRROR/7/storage/x86_64/ceph-$CEPH_RELEASE/
gpgcheck=0
enabled=1
EOF"
if [[ "${OPSTOOLS_REPO_ENABLED}" = 1 ]]; then
sudo /bin/bash -c "cat <<-EOF>$REPO_PREFIX/centos-opstools.repo
[centos-opstools]
name=centos-opstools
baseurl=$NODEPOOL_CENTOS_MIRROR/7/opstools/x86_64/
gpgcheck=0
enabled=1
EOF"
fi
fi
# @matbu TBR debuginfo:
log "Stable release: $STABLE_RELEASE"
if [ -z "$STABLE_RELEASE" ]; then
# Enable the Delorean Deps repository
sudo curl -fLvo $REPO_PREFIX/delorean-deps.repo https://trunk.rdoproject.org/centos7/delorean-deps.repo
sudo sed -i -e 's%priority=.*%priority=30%' $REPO_PREFIX/delorean-deps.repo
sudo sed -i -e "s~http://mirror.centos.org/centos~$NODEPOOL_CENTOS_MIRROR~" $REPO_PREFIX/delorean-deps.repo
sudo sed -i -e "s~https://buildlogs.centos.org~$NODEPOOL_BUILDLOGS_CENTOS_PROXY~" $REPO_PREFIX/delorean-deps.repo
sudo sed -i -e "s~https://trunk.rdoproject.org~$NODEPOOL_RDO_PROXY~" $REPO_PREFIX/delorean-deps.repo
cat $REPO_PREFIX/delorean-deps.repo
# Enable last known good RDO Trunk Delorean repository
sudo curl -fLvo $REPO_PREFIX/delorean.repo $DELOREAN_REPO_URL/$DELOREAN_REPO_FILE
sudo sed -i -e 's%priority=.*%priority=20%' $REPO_PREFIX/delorean.repo
sudo sed -i -e "s~https://trunk.rdoproject.org~$NODEPOOL_RDO_PROXY~" $REPO_PREFIX/delorean.repo
cat $REPO_PREFIX/delorean.repo
# Enable latest RDO Trunk Delorean repository if not promotion job
if [[ $CACHEUPLOAD != 1 ]]; then
sudo curl -fLvo $REPO_PREFIX/delorean-current.repo https://trunk.rdoproject.org/centos7/current/delorean.repo
sudo sed -i -e 's%priority=.*%priority=10%' $REPO_PREFIX/delorean-current.repo
sudo sed -i 's/\[delorean\]/\[delorean-current\]/' $REPO_PREFIX/delorean-current.repo
sudo sed -i -e "s~https://trunk.rdoproject.org~$NODEPOOL_RDO_PROXY~" $REPO_PREFIX/delorean-current.repo
sudo /bin/bash -c "cat <<-EOF>>$REPO_PREFIX/delorean-current.repo
includepkgs=diskimage-builder,instack,instack-undercloud,os-apply-config,os-collect-config,os-net-config,os-refresh-config,python-tripleoclient,openstack-tripleo-*,openstack-puppet-modules,puppet-*
EOF"
else
# Create empty delorean-current for dib image building
sudo sh -c "> $REPO_PREFIX/delorean-current.repo"
fi
cat $REPO_PREFIX/delorean-current.repo
else
# Enable the Delorean Deps repository
sudo curl -fLvo $REPO_PREFIX/delorean-deps.repo https://trunk.rdoproject.org/centos7-$STABLE_RELEASE/delorean-deps.repo
sudo sed -i -e 's%priority=.*%priority=30%' $REPO_PREFIX/delorean-deps.repo
sudo sed -i -e "s~http://mirror.centos.org/centos~$NODEPOOL_CENTOS_MIRROR~" $REPO_PREFIX/delorean-deps.repo
sudo sed -i -e "s~https://buildlogs.centos.org~$NODEPOOL_BUILDLOGS_CENTOS_PROXY~" $REPO_PREFIX/delorean-deps.repo
cat $REPO_PREFIX/delorean-deps.repo
# Enable delorean current for the stable version
sudo curl -fLvo $REPO_PREFIX/delorean.repo $DELOREAN_STABLE_REPO_URL/$DELOREAN_REPO_FILE
sudo sed -i -e 's%priority=.*%priority=20%' $REPO_PREFIX/delorean.repo
sudo sed -i -e "s~https://trunk.rdoproject.org~$NODEPOOL_RDO_PROXY~" $REPO_PREFIX/delorean.repo
cat $REPO_PREFIX/delorean.repo
# Create empty delorean-current for dib image building
sudo sh -c "> $REPO_PREFIX/delorean-current.repo"
cat $REPO_PREFIX/delorean-current.repo
fi
# Install the yum-plugin-priorities package so that the Delorean repository
# takes precedence over the main RDO repositories.
sudo yum -y install yum-plugin-priorities
# Make sure EPEL is uninstalled.
if rpm --quiet -q epel-release; then
sudo rpm -e epel-release
fi
sudo yum clean all
sudo yum makecache
log "Repository setup - DONE."
}
function delorean_setup {
log "Delorean setup"
# Install delorean as per combination of toci-instack and delorean docs
sudo yum install -y createrepo git mock rpm-build yum-plugin-priorities yum-utils gcc rpmdevtools redhat-rpm-config
# NOTE(pabelanger): Check if virtualenv is already install, if not install
# from packages.
if ! command -v virtualenv ; then
sudo yum install -y python-virtualenv
fi
# Workaround until https://review.openstack.org/#/c/311734/ is merged and a new image is built
sudo yum install -y libffi-devel openssl-devel
# Add the current user to the mock group
sudo usermod -G mock -a $(id -nu)
mkdir -p $TRIPLEO_ROOT
[ -d $TRIPLEO_ROOT/delorean ] || git clone https://github.com/softwarefactory-project/DLRN.git $TRIPLEO_ROOT/delorean
pushd $TRIPLEO_ROOT/delorean
sudo rm -rf data commits.sqlite
mkdir -p data
sed -i -e "s%reponame=.*%reponame=delorean-ci%" projects.ini
sed -i -e "s%target=.*%target=centos%" projects.ini
# Remove the rpm install test to speed up delorean (our ci test will to this)
if [ -f scripts/build_rpm.sh ]; then
# DLRN < 0.8.0
sed -i -e 's%--postinstall%%' scripts/build_rpm.sh
else
# This is an option in DLRN since 0.8.0 for the mock build driver
sed -i -e 's/^#install_after_build=1.*/install_after_build=0/' projects.ini
fi
virtualenv venv
# NOTE(pabelanger): We need to update setuptools to the latest version for
# CentOS 7. Also, pytz is not declared as a dependency so we need to
# manually add it. Lastly, use pip install . to use wheel AFS pypi mirrors.
./venv/bin/pip install -U pip
./venv/bin/pip install -U setuptools
./venv/bin/pip install pytz
./venv/bin/pip install .
popd
log "Delorean setup - DONE."
}
function delorean_build {
log "Delorean build"
export PATH=/sbin:/usr/sbin:$PATH
source $(dirname ${BASH_SOURCE[0]:-$0})/common_functions.sh
pushd $TRIPLEO_ROOT/delorean
if [ -n "$REVIEW_RELEASE" ]; then
log "Building for release $REVIEW_RELEASE"
# first check if we have a stable release
sed -i -e "s%baseurl=.*%baseurl=$NODEPOOL_RDO_PROXY/centos7-$REVIEW_RELEASE%" projects.ini
if [ "$REVIEW_RELEASE" = "mitaka" ]; then
sed -i -e "s%distro=.*%distro=rpm-$REVIEW_RELEASE%" projects.ini
else
# RDO changed the distgit branch for stable releases starting from newton.
sed -i -e "s%distro=.*%distro=$REVIEW_RELEASE-rdo%" projects.ini
fi
sed -i -e "s%source=.*%source=stable/$REVIEW_RELEASE%" projects.ini
elif [ -n "$FEATURE_BRANCH" ]; then
# next, check if we are testing for a feature branch
log "Building for feature branch $FEATURE_BRANCH"
sed -i -e "s%baseurl=.*%baseurl=$NODEPOOL_RDO_PROXY/centos7%" projects.ini
sed -i -e "s%distro=.*%distro=rpm-$FEATURE_BRANCH%" projects.ini
sed -i -e "s%source=.*%source=$FEATURE_BRANCH%" projects.ini
else
log "Building for master"
sed -i -e "s%baseurl=.*%baseurl=$NODEPOOL_RDO_PROXY/centos7%" projects.ini
sed -i -e "s%distro=.*%distro=rpm-master%" projects.ini
sed -i -e "s%source=.*%source=master%" projects.ini
fi
sudo rm -rf data commits.sqlite
mkdir -p data
# build packages
# loop through each of the projects listed in DELOREAN_BUILD_REFS, if it is a project we
# are capable of building an rpm for then build it.
# e.g. DELOREAN_BUILD_REFS="openstack/cinder openstack/heat etc.."
for PROJ in $DELOREAN_BUILD_REFS ; do
log "Building $PROJ"
PROJ=$(filterref $PROJ)
# Clone the repo if it doesn't yet exist
if [ ! -d $TRIPLEO_ROOT/$PROJ ]; then
git clone https://git.openstack.org/openstack/$PROJ.git $TRIPLEO_ROOT/$PROJ
if [ ! -z "$REVIEW_RELEASE" ]; then
pushd $TRIPLEO_ROOT/$PROJ
git checkout -b stable/$REVIEW_RELEASE origin/stable/$REVIEW_RELEASE
popd
fi
fi
# Work around inconsistency where map-project-name expects oslo-*
MAPPED_NAME=$(echo $PROJ | sed "s/oslo./oslo-/")
MAPPED_PROJ=$(./venv/bin/python scripts/map-project-name $MAPPED_NAME || true)
[ -e data/$MAPPED_PROJ ] && continue
cp -r $TRIPLEO_ROOT/$PROJ data/$MAPPED_PROJ
pushd data/$MAPPED_PROJ
GITHASH=$(git rev-parse HEAD)
# Set the branches delorean reads to the same git hash as PROJ has left for us
for BRANCH in master origin/master stable/mitaka origin/stable/mitaka stable/newton origin/stable/newton stable/ocata origin/stable/ocata stable/pike origin/stable/pike stable/queens origin/stable/queens; do
git checkout -b $BRANCH || git checkout $BRANCH
git reset --hard $GITHASH
done
popd
set +e
while true; do
DELOREANCMD="./venv/bin/dlrn --config-file projects.ini --head-only --package-name $MAPPED_PROJ --local --use-public --build-env http_proxy=${http_proxy:-} --info-repo rdoinfo"
# Using sudo to su a command as ourselves to run the command with a new login
# to ensure the addition to the mock group has taken effect.
sudo su $(id -nu) -c "$DELOREANCMD"
EXITCODE=$?
# delorean exits with 2 if the error is a network glitch, we can retry
if [ "$EXITCODE" == "2" ] ; then
continue
elif [ "$EXITCODE" == "0" ] ; then
break
fi
set -e
exit 1
done
set -e
done
popd
log "Delorean build - DONE."
}
function undercloud {
log "Undercloud install"
sudo yum install -y python-tripleoclient ceph-ansible
if [ ! -f ~/undercloud.conf ]; then
cp -b -f $UNDERCLOUD_CONF ~/undercloud.conf
else
log "~/undercloud.conf already exists, not overwriting"
fi
# Hostname check, add to /etc/hosts if needed
if ! grep -E "^127.0.0.1\s*$(hostname -f)" /etc/hosts; then
sudo sed -i "s/127.0.0.1\s*\(.*\)/127.0.0.1\t$(hostname -f) $(hostname -s) \1/" /etc/hosts
fi
if ! grep -E "^::1\s*$(hostname -f)" /etc/hosts; then
sudo sed -i "s/::1\s*\(.*\)/::1\t$(hostname -f) $(hostname -s) \1/" /etc/hosts
fi
openstack undercloud install
# Masquerade traffic to external networks from controllers on baremetal undercloud
# In ovb deployments, baremental nodes use undercloud as default route to reach DNS etc...
if [ $OVB -eq 1 ]; then
sudo iptables -A BOOTSTACK_MASQ -s 10.0.0.0/24 ! -d 10.0.0.0/24 -j MASQUERADE -t nat
sudo iptables-save | sudo tee /etc/sysconfig/iptables
fi
log "Undercloud install - DONE."
}
function overcloud_images {
log "Overcloud images"
# This hack is no longer needed in ocata.
if [[ "${STABLE_RELEASE}" =~ ^(mitaka|newton)$ ]]; then
# Ensure yum-plugin-priorities is installed
# get the right path for diskimage-builder version
COMMON_ELEMENTS_PATH=$(python -c '
try:
import diskimage_builder.paths
diskimage_builder.paths.show_path("elements")
except:
print("/usr/share/diskimage-builder/elements")
')
echo -e '#!/bin/bash\nyum install -y yum-plugin-priorities' | sudo tee ${COMMON_ELEMENTS_PATH}/yum/pre-install.d/99-tmphacks
sudo chmod +x ${COMMON_ELEMENTS_PATH}/yum/pre-install.d/99-tmphacks
fi
# To install the undercloud instack-undercloud is run as root,
# as a result all of the git repositories get cached to
# ~root/.cache/image-create/source-repositories, lets not clone them again
if [ -d ~root/.cache/image-create/source-repositories ] && \
[ ! -d ~/.cache/image-create/source-repositories ] ; then
sudo cp -r ~root/.cache/image-create/source-repositories ~/.cache/image-create/source-repositories
sudo chown -R $(id -u) ~/.cache/image-create/source-repositories
fi
export DIB_YUM_REPO_CONF=$OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF
log "Overcloud images saved in $OVERCLOUD_IMAGES_PATH"
pushd $OVERCLOUD_IMAGES_PATH
log "OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF=$OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF"
if [[ "${STABLE_RELEASE}" =~ ^(mitaka|newton)$ ]] ; then
OVERCLOUD_IMAGES_ARGS="$OVERCLOUD_IMAGES_LEGACY_ARGS"
fi
DIB_YUM_REPO_CONF=$OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF \
openstack overcloud image build $OVERCLOUD_IMAGES_ARGS 2>&1 | \
tee -a overcloud-image-build.log
stackrc_check
openstack overcloud image upload --update-existing
popd
log "Overcloud images - DONE."
}
function register_nodes {
log "Register nodes"
if [ ! -f $INSTACKENV_JSON_PATH ]; then
echo Could not find instackenv.json at $INSTACKENV_JSON_PATH
echo Specify the path to instackenv.json with '$INSTACKENV_JSON_PATH'
exit 1
fi
stackrc_check
if [[ "${STABLE_RELEASE}" = "mitaka" ]] ; then
openstack baremetal import --json $INSTACKENV_JSON_PATH
# This step is a part of the import command from Newton on
openstack baremetal configure boot
else
if [ "$INTROSPECT_NODES" = 1 ]; then
# Keep the nodes in manageable state so that they may be
# introspected later.
openstack overcloud node import $INSTACKENV_JSON_PATH
else
openstack overcloud node import $INSTACKENV_JSON_PATH --provide
fi
fi
ironic node-list
log "Register nodes - DONE."
}
function introspect_nodes {
log "Introspect nodes"
stackrc_check
if [[ "${STABLE_RELEASE}" = "mitaka" ]] ; then
openstack baremetal introspection bulk start
else
# Note: Unlike the legacy bulk command, overcloud node
# introspect will only run on nodes in the 'manageable'
# provisioning state.
openstack overcloud node introspect --all-manageable
openstack overcloud node provide --all-manageable
fi
log "Introspect nodes - DONE."
}
function overcloud_deploy {
log "Overcloud deploy"
# Force use of --templates
if [[ ! $OVERCLOUD_DEPLOY_ARGS =~ --templates ]]; then
OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS --templates"
fi
stackrc_check
OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS $OVERCLOUD_VALIDATE_ARGS"
# Set dns server for the overcloud nodes
subnet_id=$(openstack network list -f value -c Name -c Subnets | grep ctlplane | cut -d " " -f 2)
neutron subnet-update $subnet_id --dns-nameserver $(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }' | sed ':a;N;$!ba;s/\n/ --dns-nameserver /g')
if [[ $USE_CONTAINERS == 1 ]]; then
if ! glance image-list | grep -q atomic-image; then
wget --progress=dot:mega $ATOMIC_URL
glance image-create --name atomic-image --file `basename $ATOMIC_URL` --disk-format qcow2 --container-format bare
fi
#TODO: When container job is changed to network-isolation remove this
neutron subnet-update $(neutron net-list | grep ctlplane | cut -d ' ' -f 6) --dns-nameserver 8.8.8.8
OVERCLOUD_DEPLOY_ARGS="$OVERCLOUD_DEPLOY_ARGS $CONTAINER_ARGS"
fi
log "unsetting any http proxy"
unset http_proxy
log "Overcloud create started."
exitval=0
log "Deploy command arguments: $OVERCLOUD_DEPLOY_ARGS"
openstack overcloud deploy $OVERCLOUD_DEPLOY_ARGS || exitval=1
if [ $exitval -eq 1 ];
then
log "Overcloud create - FAILED!"
exit 1
fi
log "Overcloud create - DONE."
}
function undercloud_upgrade {
log "Undercloud upgrade"
# Setup repositories
repo_setup
# In pike and above this is handled by the pre-upgrade hook
if [[ "$STABLE_RELEASE" =~ ^(newton|ocata)$ ]]; then
sudo systemctl stop openstack-*
sudo systemctl stop neutron-*
sudo systemctl stop openvswitch
sudo systemctl stop httpd
fi
# tripleo cli needs to be updated first
sudo yum -y update python-tripleoclient
# Upgrade the undercloud
openstack undercloud upgrade
log "Undercloud upgrade - Done."
}
function overcloud_update {
# Force use of --templates
if [[ ! $OVERCLOUD_UPDATE_ARGS =~ --templates ]]; then
OVERCLOUD_UPDATE_ARGS="$OVERCLOUD_UPDATE_ARGS --templates"
fi
stackrc_check
if openstack stack show "$OVERCLOUD_NAME" | grep "stack_status " | egrep "(CREATE|UPDATE)_COMPLETE"; then
FILE_PREFIX=$(date "+overcloud-update-resources-%s")
BEFORE_FILE="/tmp/${FILE_PREFIX}-before.txt"
AFTER_FILE="/tmp/${FILE_PREFIX}-after.txt"
# This is an update, so if enabled, compare the before/after resource lists
if [ ! -z "$OVERCLOUD_UPDATE_CHECK" ]; then
openstack stack resource list -n5 overcloud | awk '{print $2, $4, $6}' | sort > $BEFORE_FILE
fi
log "Overcloud update started."
exitval=0
openstack overcloud deploy $OVERCLOUD_UPDATE_ARGS || exitval=1
if [ $exitval -eq 1 ];
then
log "Overcloud update - FAILED!"
exit 1
fi
log "Overcloud update - DONE."
if [ ! -z "$OVERCLOUD_UPDATE_CHECK" ]; then
openstack stack resource list -n5 overcloud | awk '{print $2, $4, $6}' | sort > $AFTER_FILE
diff_rsrc=$(diff $BEFORE_FILE $AFTER_FILE)
if [ ! -z "$diff_rsrc" ]; then
log "Overcloud update - Completed but unexpected resource differences: $diff_rsrc"
exit 1
fi
fi
log "Overcloud update - DONE."
if [[ $OVERCLOUD_UPDATE_RM_FILES == 1 ]]; then
rm -f $BEFORE_FILE $AFTER_FILE
fi
else
log "Overcloud FAILED - No stack $OVERCLOUD_NAME."
exit 1
fi
}
function overcloud_upgrade {
stackrc_check
if openstack stack show "$OVERCLOUD_NAME" 2>&1 > /dev/null ; then
log "Create overcloud repo template file"
/bin/bash -c "cat <<EOF>$HOME/init-repo.yaml
parameter_defaults:
UpgradeInitCommand: |
set -e
# For some reason '$HOME' is not defined when the Heat agent executes this
# script and tripleo.sh expects it. Just reuse the same value from the
# current undercloud user.
yum clean all
export STABLE_RELEASE=$STABLE_RELEASE
HOME=$HOME $TRIPLEO_ROOT/tripleo-ci/scripts/tripleo.sh --repo-setup
yum clean all
yum install -y python-heat-agent-*
# TODO: (slagle)
# remove the --noscripts install of openstack-tripleo-image-elements
# once https://review.rdoproject.org/r/4225 merges
pushd /tmp
yumdownloader openstack-tripleo-image-elements
rpm -Uvh --noscripts --force ./openstack-tripleo-image-elements*
rm -f openstack-tripleo-image-elements*
popd
# FIXME: matbu
# Remove those packages is temporary workaround since the fix in
# https://bugs.launchpad.net/tripleo/+bug/1649284
# will be release and landed in the packages
yum remove -y python-UcsSdk openstack-neutron-bigswitch-agent python-networking-bigswitch openstack-neutron-bigswitch-lldp python-networking-odl
EOF"
log "Overcloud upgrade started."
log "Upgrade command arguments: $OVERCLOUD_UPGRADE_ARGS"
log "Execute major upgrade."
openstack overcloud deploy $OVERCLOUD_UPGRADE_ARGS
log "Major upgrade - DONE."
if openstack stack show "$OVERCLOUD_NAME" | grep "stack_status " | egrep "UPDATE_COMPLETE"; then
log "Major Upgrade - DONE."
else
log "Major Upgrade FAILED."
exit 1
fi
else
log "Overcloud upgrade FAILED - No stack $OVERCLOUD_NAME."
exit 1
fi
}
function overcloud_upgrade_converge {
stackrc_check
if openstack stack show "$OVERCLOUD_NAME" 2>&1 > /dev/null; then
log "Overcloud upgrade converge started."
log "Upgrade command arguments: $OVERCLOUD_UPGRADE_CONVERGE_ARGS"
log "Execute major upgrade converge."
openstack overcloud deploy $OVERCLOUD_UPGRADE_CONVERGE_ARGS
log "Major upgrade converge - DONE."
if openstack stack show "$OVERCLOUD_NAME" | grep "stack_status " | egrep "UPDATE_COMPLETE"; then
log "Major Upgrade converge - DONE."
else
log "Major Upgrade converge FAILED."
exit 1
fi
else
log "Overcloud upgrade converge FAILED - No stack $OVERCLOUD_NAME."
exit 1
fi
}
function overcloud_delete {
log "Overcloud delete"
stackrc_check
OVERCLOUD_ID=$(openstack stack list | grep "$OVERCLOUD_NAME" | awk '{print $2}')
wait_command="openstack stack show $OVERCLOUD_ID"
openstack stack delete --yes "$OVERCLOUD_NAME"
if $($(dirname $0)/wait_for -w $OVERCLOUD_DELETE_TIMEOUT -d 10 -s "DELETE_COMPLETE" -- "$wait_command"); then
log "Overcloud $OVERCLOUD_ID DELETE_COMPLETE"
else
log "Overcloud $OVERCLOUD_ID delete failed or timed out:"
openstack stack show $OVERCLOUD_ID
exit 1
fi
if [[ "${STABLE_RELEASE}" != "mitaka" ]] ; then
openstack overcloud plan delete "$OVERCLOUD_NAME" && exitval=0 || exitval=1
if [ ${exitval} -eq 0 ]; then
log "Overcloud $OVERCLOUD_ID plan delete SUCCESS"
else
log "Overcloud $OVERCLOUD_ID plan delete FAILED"
exit 1
fi
fi
}
function run_cmd {
if ! $@; then
echo "Command: $@ FAILED" >&2
exit 1
else
echo "Command: $@ OK"
fi
}
function overcloud_sanitytest_create {
ENABLED_SERVICES=$@
for service in $ENABLED_SERVICES; do
case $service in
"keystone" )
run_cmd openstack user create ${SANITYTEST_CONTENT_NAME}
run_cmd openstack user list
;;
"glance_api" )
run_cmd openstack image create ${SANITYTEST_CONTENT_NAME}
run_cmd openstack image list
;;
"neutron_api" )
run_cmd openstack network create ${SANITYTEST_CONTENT_NAME}
run_cmd openstack network list
;;
"cinder_api" )
run_cmd openstack volume create ${SANITYTEST_CONTENT_NAME} --size 1
run_cmd openstack volume list
;;
"heat_api" )
echo "heat_template_version: newton" > /tmp/${SANITYTEST_CONTENT_NAME}.yaml
openstack stack create ${SANITYTEST_CONTENT_NAME} --template /tmp/${SANITYTEST_CONTENT_NAME}.yaml
openstack stack list
;;
"swift_proxy" )
openstack container create ${SANITYTEST_CONTENT_NAME}
openstack container list
;;
"sahara_api" )
# glance_api must also be enabled
run_cmd openstack image create sahara_${SANITYTEST_CONTENT_NAME}
run_cmd openstack dataprocessing image register sahara_${SANITYTEST_CONTENT_NAME} --username centos
run_cmd openstack dataprocessing image list
;;
esac
done
}
function overcloud_sanitytest_check {
ENABLED_SERVICES=$@
for service in $ENABLED_SERVICES; do
case $service in
"keystone" )
run_cmd openstack user show ${SANITYTEST_CONTENT_NAME}
;;
"glance_api" )
run_cmd openstack image show ${SANITYTEST_CONTENT_NAME}
;;
"neutron_api" )
run_cmd openstack network show ${SANITYTEST_CONTENT_NAME}
;;
"cinder_api" )
run_cmd openstack volume show ${SANITYTEST_CONTENT_NAME}
;;
"heat_api" )
run_cmd openstack stack show ${SANITYTEST_CONTENT_NAME}
# FIXME(shardy): It'd be good to add pre/post upgrade checks
# on the actual version, but this is still good for debugging
run_cmd openstack orchestration template version list
;;
"swift_proxy" )
run_cmd openstack container show ${SANITYTEST_CONTENT_NAME}
;;
"sahara_api" )
run_cmd openstack dataprocessing image show sahara_${SANITYTEST_CONTENT_NAME}
;;
esac
done
}
function overcloud_sanitytest_cleanup {
ENABLED_SERVICES=$@
for service in $ENABLED_SERVICES; do
case $service in
"keystone" )
echo "Sanity test keystone"
run_cmd openstack user delete ${SANITYTEST_CONTENT_NAME}
;;
"glance_api" )
run_cmd openstack image delete ${SANITYTEST_CONTENT_NAME}
;;
"neutron_api" )
run_cmd openstack network delete ${SANITYTEST_CONTENT_NAME}
;;
"cinder_api" )
run_cmd openstack volume delete ${SANITYTEST_CONTENT_NAME}
;;
"heat_api" )
run_cmd openstack stack delete --yes ${SANITYTEST_CONTENT_NAME}
;;
"swift_proxy" )
run_cmd openstack container delete ${SANITYTEST_CONTENT_NAME}
;;
"sahara_api" )
run_cmd openstack dataprocessing image unregister sahara_${SANITYTEST_CONTENT_NAME}
run_cmd openstack image delete sahara_${SANITYTEST_CONTENT_NAME}
;;
esac
done
}
function overcloud_sanitytest {
log "Overcloud sanitytest"
exitval=0
stackrc_check
if openstack stack show "$OVERCLOUD_NAME" | grep "stack_status " | egrep -q "(CREATE|UPDATE)_COMPLETE"; then
ENABLED_SERVICES=$(openstack stack output show overcloud EnabledServices -f json | \
jq -r ".output_value" | jq '.Controller | .[]' | tr "\n" " " | sed "s/\"//g")
echo "Sanity Test, ENABLED_SERVICES=$ENABLED_SERVICES"
overcloudrc_check
if [ "$OVERCLOUD_SANITYTEST_SKIP_CREATE" != 1 ]; then
overcloud_sanitytest_create $ENABLED_SERVICES
fi
overcloud_sanitytest_check $ENABLED_SERVICES