-
Notifications
You must be signed in to change notification settings - Fork 139
/
qa_crowbarsetup.sh
6725 lines (5918 loc) · 256 KB
/
qa_crowbarsetup.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
# based on https://github.com/SUSE/cloud/wiki/SUSE-Cloud-Installation-Manual
# This has only been tested on aarch64, x86_64 and s390x so far
shopt -s extglob
mkcconf=mkcloud.config
if [ -z "$testfunc" ] && [ -e $mkcconf ]; then
source $mkcconf
fi
: ${SCRIPTS_DIR:=$(dirname $(readlink -e $BASH_SOURCE))}
scripts_lib_dir=${SCRIPTS_DIR}/lib
common_scripts="mkcloud-common.sh qa_crowbarsetup-help.sh"
for script in $common_scripts; do
source ${scripts_lib_dir}/$script
done
# not being sourced from mkcloud is a feature
is_onhost && complain 9 "qa_crowbarsetup.sh should not be sourced within mkcloud. Shared functions are in files in scripts/lib/: eg. mkcloud-common.sh or qa_crowbarsetup-help.sh."
# this needs to be after mkcloud.config got sourced
if [[ $debug_qa_crowbarsetup = 1 ]] ; then
set -x
PS4='+(${BASH_SOURCE##*/}:${LINENO}) ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
fi
# defaults
: ${cinder_backend:=''}
: ${cinder_netapp_storage_protocol:=iscsi}
: ${cinder_netapp_login:=openstack}
: ${cinder_netapp_password:=''}
: ${want_separate_ceph_network:=0}
: ${crowbar_networkingmode:=single}
: ${crowbar_name:=crowbar}
: ${want_rootpw:=linux}
: ${want_raidtype:="raid1"}
: ${want_ipmi_username:=root}
: ${want_ipmi_pxeextraopts:=options=persistent}
: ${want_multidnstest:=1}
: ${want_tempest:=1}
: ${want_s390:=''}
: ${want_horizon_integration_test:=''}
: ${want_batch_dir:="${SCRIPTS_DIR}/scenarios"}
: ${upgrade_test_stack_count:=1}
: ${crowbar_sync_mark_timeout_multiplier:="2.0"}
if iscloudver 8plus; then
: ${want_cinder_rbd_flatten_snaps:=1}
: ${want_clustered_rabbitmq:=1}
else
: ${want_cinder_rbd_flatten_snaps:=0}
: ${want_clustered_rabbitmq:=0}
fi
: ${want_octavia_network:=1}
if [[ $arch = "s390x" ]] ; then
want_s390=1
fi
# global variables that are set within this script
novacontroller=
horizonserver=
horizonservice=
manila_service_vm_uuid=
manila_tenant_vm_ip=
clusternodesdrbd=
clusternodesdata=
clusternodesnetwork=
clusternodesservices=
clusternodesrabbit=
clusternamedata="data"
clusternameservices="services"
clusternamenetwork="network"
clusternamerabbit="data" # default to database nodes
wanthyperv=
crowbar_api=http://localhost:3000
crowbar_api_installer_path=/installer/installer
crowbar_api_digest="--digest -u crowbar:crowbar"
crowbar_install_log=/var/log/crowbar/install.log
crowbar_init_api=http://localhost:4567/api
crowbar_lib_dir=/var/lib/crowbar
crowbar_api_v2_header="Accept: application/vnd.crowbar.v2.0+json"
extended_upgrade_templates="2-instances-upgrade-bothvolumes.yaml 2-instances-upgrade-mixedvolumes.yaml 2-instances-upgrade-novolumes.yaml"
declare -a unclustered_nodes
export magnum_k8s_image_name=openstack-magnum-k8s-image
export nodenumber=${nodenumber:-2}
if [[ $want_ironic = 1 ]] ; then
# TODO: re-enable BaremetalBFV when Ironic barclamp supports BFV
export tempestoptions=${tempestoptions:--r ironic --black-regex BaremetalBFV}
elif iscloudver 7plus; then
export tempestoptions=${tempestoptions:---smoke}
else
export tempestoptions=${tempestoptions:--t -s}
fi
export nodes=
export cinder_backend
export cinder_netapp_storage_protocol
export cinder_netapp_login
export cinder_netapp_password
export localreposdir_target
export want_ipmi=${want_ipmi:-}
[ "$libvirt_type" = hyperv ] && export wanthyperv=1
[ "$libvirt_type" = xen ] && export wantxenpv=1 # xenhvm is broken anyway
export CROWBAR_EXPERIMENTAL=true
export CROWBAR_VERIFY_SSL=false
# export crowbar timeout to have the new timeout also in GM without updates
export CROWBAR_TIMEOUT=3600
[ -e /etc/profile.d/crowbar.sh ] && . /etc/profile.d/crowbar.sh
export ZYPP_LOCK_TIMEOUT=120
function onadmin_help
{
# The help moved to lib/qa_crowbarsetup-help.sh
# because it needs to be usable from mkcloud as well.
# This function is here only for backwards compatibility.
qacrowbarsetup_help
}
# run hook code before the actual script does its function
# example usage: export pre_do_installcrowbar=$(base64 -w 0 <<EOF
# echo foo
# EOF
# )
function pre_hook
{
func=$1
pre=$(eval echo \$pre_$func | base64 -d)
setcloudnetvars $cloud
set_noproxyvar
test -n "$pre" && eval "$pre"
echo $func >> /root/qa_crowbarsetup.steps.log
}
function mount_localreposdir_target
{
if [ -z "$localreposdir_target" ]; then
return
fi
if mountpoint -q -- "$localreposdir_target" ; then
echo "$localreposdir_target is already mounted"
return
fi
mkdir -p $localreposdir_target
if ! grep -q "$localreposdir_target\s\+$localreposdir_target" /etc/fstab ; then
echo 'force_drivers+="9pnet_virtio"' > /etc/dracut.conf.d/03-libvirt.conf
dracut -f
echo "$localreposdir_target $localreposdir_target 9p ro,trans=virtio,version=9p2000.L,msize=262144 0 0" >> /etc/fstab
fi
mount "$localreposdir_target"
}
function add_bind_mount
{
local src="$1"
local dst="$2"
mkdir -p "${dst}"
if ! [ -d "${src}" ] ; then
complain 31 "source ${src} for bind-mount does not exist"
fi
umount "${dst}"
if ! grep -q "$src\s\+$dst" /etc/fstab ; then
echo "$src $dst bind defaults,bind 0 0" >> /etc/fstab
fi
safely mount "$dst"
}
function add_nfs_mount
{
local nfs="$1"
local dir="$2"
# skip if dir has content
test -d "$dir"/rpm && return
mkdir -p "$dir"
if grep -q "$nfs\s\+$dir" /etc/fstab ; then
return
fi
echo "$nfs $dir nfs ro,nosuid,rsize=8192,wsize=8192,hard,intr,nolock 0 0" >> /etc/fstab
safely mount "$dir"
}
# mount a zypper repo either from NFS or from the host (if localreposdir_target is set)
# also adds an entry to /etc/fstab so that mounts can be restored after a reboot
# input1: path - path within the specified reposerver
# input2: targetdir - where to mount (usually in /srv/tftpboot/repos/DIR )
# input3(optional): zypper_alias - if set, this dir is added as a local repo for zypper
function add_mount
{
local path="$1"
local targetdir="$2"
local zypper_alias="$3"
local localreposdir_path
nfssrc="$nfsserver_ip:$nfsserver_base_path/$path"
localreposdir_path="$localreposdir_target/$path"
if [ -n "$localreposdir_target" ]; then
# localreposdir_src holds a mirror of clouddata
if [ -z "$localreposdir_path" ]; then
complain 34 "IBS builds are not supported in local mode"
fi
add_bind_mount "$localreposdir_path" "$targetdir"
else
if [ -z "$nfssrc" ]; then
complain 50 "BUG: add_mount() called with empty nfssrc parameter" \
"(targetdir=$targetdir alias=$zypper_alias)\n" \
"This will break for those using NFS."
fi
add_nfs_mount "$nfssrc" "$targetdir"
fi
if [ -n "${zypper_alias}" ]; then
$zypper rr "${zypper_alias}"
safely $zypper ar -f "${targetdir}" "${zypper_alias}"
fi
}
function issusenode
{
local machine=$1
[[ $machine =~ ^${crowbar_name}\. ]] && return 0
knife node show $machine -a node.target_platform | grep -q suse-
}
if [[ $want_ssl_trusted != 1 ]] ; then
function openstack
{
command openstack --insecure "$@"
}
function nova
{
command nova --insecure "$@"
}
function neutron
{
command neutron --insecure "$@"
}
export NEUTRONCLIENT_INSECURE=true
export NOVACLIENT_INSECURE=true
export SWIFTCLIENT_INSECURE=true
export CINDERCLIENT_INSECURE=true
export MAGNUMCLIENT_INSECURE=true
# Extra environment variable because of https://launchpad.net/bugs/1535284
export manilaclient_INSECURE=true
export MANILACLIENT_INSECURE=true
export MISTRALCLIENT_INSECURE=true
export TROVECLIENT_INSECURE=true
fi
function isrepoworking
{
local repo=$1
curl -s $reposerver_url/disabled | egrep -q "^$repo" && {
echo "WARNING: The repo $repo is marked as broken"
return 1
}
return 0
}
function export_tftpboot_dirs
{
tftpboot_suse_dir=/srv/tftpboot/suse-$suseversion
tftpboot_repos_dir=$tftpboot_suse_dir/$arch/repos
}
function addslestestupdates
{
if isrepoworking SLES$slesversion-Updates-test ; then
add_mount "repos/$arch/SLES$slesversion-Updates-test/" \
"$tftpboot_repos_dir/SLES$slesversion-Updates-test/" "slestup"
fi
if iscloudver 8minus && isrepoworking SLES$slesversion-LTSS-Updates-test ; then
add_mount "repos/$arch/SLES$slesversion-LTSS-Updates-test/" \
"$tftpboot_repos_dir/SLES$slesversion-LTSS-Updates-test/" "slesltup"
fi
}
function addcloudmaintupdates
{
add_mount "repos/$arch/SUSE-OpenStack-Cloud-$cloudrepover-Updates/" \
"$tftpboot_repos_dir/SUSE-OpenStack-Cloud-$cloudrepover-Updates/" \
"cloudmaintup"
}
function addcloudtestupdates
{
if isrepoworking SUSE-OpenStack-Cloud-$cloudrepover-Updates-test ; then
add_mount "repos/$arch/SUSE-OpenStack-Cloud-$cloudrepover-Updates-test/" \
"$tftpboot_repos_dir/SUSE-OpenStack-Cloud-$cloudrepover-Updates-test/" "cloudtup"
fi
}
function addcloudpool
{
add_mount "repos/$arch/SUSE-OpenStack-Cloud-$cloudrepover-Pool/" \
"$tftpboot_repos_dir/SUSE-OpenStack-Cloud-$cloudrepover-Pool/" \
"cloudpool"
}
function add_salt_repo
{
local suffix
for suffix in Pool Updates; do
add_mount "repos/$arch/SLE12-Module-Adv-Systems-Management-$suffix/" \
"$tftpboot_repos_dir/SLE12-Module-Adv-Systems-Management-$suffix/" "salt-$suffix"
done
}
function add_sdk_repo
{
local sdk_repo_priority
sdk_repo_priority=199
export_tftpboot_dirs
local suffix
for suffix in Pool Updates; do
add_mount "repos/$arch/SLE$slesversion-SDK-$suffix/" \
"$tftpboot_repos_dir/SLE$slesversion-SDK-$suffix/" "SDK-$suffix"
done
if [[ "$want_test_updates" = 1 ]] && isrepoworking SLE$slesversion-SDK-Updates-test ; then
add_mount "repos/$arch/SLE$slesversion-SDK-Updates-test/" \
"$tftpboot_repos_dir/SLE$slesversion-SDK-Updates-test/" "SDK-Updates-test"
fi
}
function add_continuousdelivery_repo
{
local stage=
[[ $TESTHEAD ]] && stage=":/Staging"
# priority required to overwrite the default cloud6 packages
$zypper ar -p 92 -f http://$susedownload/ibs/Devel:/Cloud:/6:/SAP${stage}/SLE_12_SP1/ dc6cd
}
function add_ha_repo
{
local repo
for repo in SLE$slesversion-HA-{Pool,Updates}; do
# Note no zypper alias parameter here since we don't want to
# zypper addrepo on the admin node.
add_mount "repos/$arch/$repo" \
"$tftpboot_repos_dir/$repo"
done
if [[ $want_test_updates = 1 ]] && isrepoworking SLE$slesversion-HA-Updates-test ; then
add_mount "repos/$arch/SLE$slesversion-HA-Updates-test/" \
"$tftpboot_repos_dir/SLE$slesversion-HA-Updates-test/"
fi
}
function add_suse_storage_repo
{
# Note no zypper alias parameter here since we don't want
# to zypper addrepo on the admin node.
local repo
if [ -n "$deployceph" ] || [[ $want_external_ceph = 1 ]]; then
for repo in SUSE-Enterprise-Storage-$sesversion-{Pool,Updates}; do
add_mount "repos/$arch/$repo" "$tftpboot_repos_dir/$repo"
done
if [[ "$want_test_updates" = 1 ]] ; then
if isrepoworking SUSE-Enterprise-Storage-$sesversion-Updates-test ; then
add_mount "repos/$arch/SUSE-Enterprise-Storage-$sesversion-Updates-test/" \
"$tftpboot_repos_dir/SUSE-Enterprise-Storage-$sesversion-Updates-test/"
fi
fi
fi
}
function get_disk_id_by_serial_and_libvirt_type
{
# default libvirt_type is "kvm"
local libvirt="${1:-kvm}"
local serial="$2"
diskid="unknown"
case "$libvirt" in
xen) diskid="scsi-SATA_QEMU_HARDDISK_$serial" ;;
kvm) diskid="virtio-$serial" ;;
esac
echo -n "$diskid"
}
function get_all_nodes
{
crowbar_node_list=$(safely crowbarctl node list --no-meta --plain | LC_ALL=C sort)
if [ -n "$custom_crowbar_node_order" ]; then
# return only the nodes that are registered
for onenode in $custom_crowbar_node_order ; do
printf "%s\n" ${crowbar_node_list[@]} | grep $onenode
done
else
printf "%s\n" ${crowbar_node_list[@]}
fi
}
function get_all_suse_nodes
{
for m in $(get_all_nodes) ; do
issusenode "$m" || continue
echo "$m"
done
}
function get_all_discovered_nodes
{
# names of discovered nodes start with 'd'
# so it is excluding the crowbar node
get_all_nodes | grep "^d"
}
function get_crowbar_node
{
# crowbar node may have any name, so better use grep -v
# and make sure it is only one
get_all_nodes | grep -v "^d" | head -n 1
}
function get_unclustered_sles12plus_nodes
{
local target="suse-12.0"
iscloudver 6 && target="suse-12.1"
iscloudver 7 && target="suse-12.2"
iscloudver 8 && target="suse-12.3"
iscloudver 9plus && target="suse-12.4"
local sles12plusnodes=($(knife search node "target_platform:$target AND \
NOT crowbar_admin_node:true" -a name | grep ^name: | cut -d : -f 2 | \
sort | sed 's/\s//g'))
if [[ $hacloud = 1 ]]; then
# This basically does an intersection of the lists in sles12plusnode and unclustered_node
# i.e. pick all sles12plus nodes that are not part of a cluster
sles12plusnodes=($(comm -1 -2 <(printf "%s\n" ${sles12plusnodes[@]}) \
<(printf "%s\n" ${unclustered_nodes[@]})))
fi
echo ${sles12plusnodes[@]}
}
function show_crowbar_nodes_to_upgrade
{
crowbarctl upgrade status nodes --plain | grep not_upgraded | cut -d ' ' -f 2 | cut -d '.' -f 1 | \
sort | tr '\n' ','| sed 's/,$//' | xargs printf 'Upgrading nodes: %s\r'
}
function remove_node_from_list
{
local onenode="$1"
local list="$@"
printf "%s\n" $list | grep -iv "$onenode"
}
function cluster_node_assignment
{
if [ -n "$clusternodesdata" ] ; then
# exit if node assignment is already done
return 0
fi
local nodesavailable=`get_all_discovered_nodes`
local dmachine
# the nodes that contain drbd volumes are defined via drbdnode_mac_vol
for dmachine in ${drbdnode_mac_vol//+/ } ; do
local mac
local serial
mac=${dmachine%#*}
serial=${dmachine#*#}
# find and remove drbd nodes from nodesavailable
for node in $nodesavailable ; do
if crowbar machines show "$node" | grep "\"macaddress\"" | grep -qi $mac ; then
nodesavailable=`remove_node_from_list "$node" "$nodesavailable"`
clusternodesdrbd="$clusternodesdrbd $node"
echo "Claiming disk for DRBD on node: $node"
# assign drbd volume via knife
knife exec -E "
nodes.find(:name => '${node}').each do |n|
if n['crowbar_wall']['claimed_disks']
n['crowbar_wall']['claimed_disks'].each do |k,v|
next if v.is_a? Hash and v['owner'] !~ /LVM_DRBD/;
n['crowbar_wall']['claimed_disks'].delete(k);
end
else
n['crowbar_wall']['claimed_disks'] = {}
end
n['crowbar_wall']['claimed_disks']['/dev/disk/by-id/$(get_disk_id_by_serial_and_libvirt_type "$libvirt_type" "$serial")']={'owner' => 'LVM_DRBD'};
n.save
end
"
fi
done
done
### Examples for clusterconfig:
# clusterconfig="data+services+network=2"
# clusterconfig="services+data=2:network=3:::"
# clusterconfig="services=3:data=2:network=2:"
for cluster in ${clusterconfig//:/ } ; do
[ -z "$cluster" ] && continue
# split off the number => group
local group=${cluster%=*}
# split off the group => number
local number=${cluster#*=}
# get first element of the group => clustername
local clustername=${group%%+*}
local nodes=
# clusternodesdata can only be the drbd nodes
if [[ $group =~ data ]] ; then
nodes="$clusternodesdrbd"
fi
# fetch nodes for this cluster if not yet defined
if [ -z "$nodes" ] ; then
nodes=`printf "%s\n" $nodesavailable | head -n$number`
fi
# remove the selected nodes from the list of available nodes
for onenode in $nodes ; do
nodesavailable=`printf "%s\n" $nodesavailable | grep -iv $onenode`
done
case $clustername in
data)
clusternodesdata="$nodes"
[[ $group =~ "+services" ]] && clusternameservices=$clustername
[[ $group =~ "+network" ]] && clusternamenetwork=$clustername
[[ $group =~ "+rabbit" ]] && clusternamerabbit=$clustername
;;
services)
clusternodesservices="$nodes"
[[ $group =~ "+data" ]] && clusternamedata=$clustername
[[ $group =~ "+network" ]] && clusternamenetwork=$clustername
[[ $group =~ "+rabbit" ]] && clusternamerabbit=$clustername
;;
network)
clusternodesnetwork="$nodes"
[[ $group =~ "+data" ]] && clusternamedata=$clustername
[[ $group =~ "+services" ]] && clusternameservices=$clustername
[[ $group =~ "+rabbit" ]] && clusternamerabbit=$clustername
;;
rabbit)
clusternamerabbit="$clustername" # defaults to data cluster
clusternodesrabbit="$nodes"
[[ $group =~ "+services" ]] && clusternameservices=$clustername
[[ $group =~ "+network" ]] && clusternamenetwork=$clustername
[[ $group =~ "+data" ]] && clusternamedata=$clustername
;;
esac
done
if [[ $clusternamerabbit = data ]]; then
clusternodesrabbit=$clusternodesdata
fi
unclustered_nodes=($nodesavailable)
echo "............................................................"
echo "The cluster node assignment (for your information):"
echo "data cluster:"
printf " %s\n" $clusternodesdata
echo "network cluster:"
printf " %s\n" $clusternodesnetwork
echo "services cluster:"
printf " %s\n" $clusternodesservices
echo "rabbitmq cluster:"
printf " %s\n" $clusternodesrabbit
echo "other non-clustered nodes (free for compute / storage):"
printf " %s\n" ${unclustered_nodes[@]}
echo "............................................................"
}
function wget_iso_and_unpack_to
{
local isourl="$1"
local distiso="$2"
local targetdir="$3"
mkdir -p /mnt/cloud "$targetdir"
(
cd "$targetdir"
wget --progress=dot:mega -r -np -nc -e robots=off -A "$distiso" http://$isourl \
|| complain 71 "iso not found"
local cloudiso=$(ls $isourl/*.iso | tail -1)
if [ -z "$cloudiso" ]; then
complain 75 "failed to download $distiso from http://$isourl"
fi
safely mount -o loop,ro -t iso9660 $cloudiso /mnt/cloud
safely rsync -av --delete-after /mnt/cloud/ .
safely umount /mnt/cloud
echo $cloudiso > isoversion
)
}
function onadmin_prepare_sles12sp1_repos
{
onadmin_prepare_sles_installmedia
onadmin_prepare_sles12sp1_other_repos
}
function onadmin_prepare_sles12plus_cloud_repos
{
# create empty repository when there is none yet
ensure_packages_installed createrepo
for repo in SUSE-OpenStack-Cloud-$cloudrepover-{Pool,Updates}; do
if [ ! -e "$tftpboot_repos_dir/$repo/repodata/" ] ; then
mkdir -p "$tftpboot_repos_dir/$repo"
safely createrepo "$tftpboot_repos_dir/$repo"
fi
done
}
function onadmin_prepare_sles_installmedia
{
local a
for a in $architectures; do
local sles_mount="$tftpboot_suse_dir/$a/install"
add_mount "install/suse-$suseversion/$a/install" "$sles_mount"
if [ ! -d "$sles_mount/media.1" ] ; then
complain 34 "We do not have suse-$suseversion install media - giving up"
fi
done
}
function onadmin_prepare_sles12sp1_other_repos
{
for repo in SLES12-SP1-{Pool,Updates,LTSS-Updates}; do
add_mount "repos/$arch/$repo" "$tftpboot_repos_dir/$repo"
if [[ $want_s390 ]] ; then
add_mount "repos/s390x/$repo" \
"$tftpboot_suse12sp1_dir/s390x/repos/$repo"
fi
done
}
function onadmin_prepare_sles_other_repos
{
for repo in SLES$slesversion-{Pool,Updates}; do
add_mount "repos/$arch/$repo" "$tftpboot_repos_dir/$repo"
done
# FIXME LTSS repo empty for SLE12-SP4, do not add it as zypper does not like empty repos
if iscloudver 9minus ; then
add_mount "repos/$arch/SLES$slesversion-LTSS-Updates" "$tftpboot_repos_dir/SLES$slesversion-LTSS-Updates" "SLES$slesversion-LTSS-Updates"
fi
}
function onadmin_prepare_cloud_repos
{
local targetdir="$tftpboot_repos_dir/Cloud"
mkdir -p $targetdir
if [ -n "${localreposdir_target}" ]; then
add_mount "repos/$arch/${CLOUDLOCALREPOS}/" \
"$targetdir"
else
wget_iso_and_unpack_to "$CLOUDISOURL" "$CLOUDISONAME" "$targetdir"
if [[ $want_s390 ]] ; then
wget_iso_and_unpack_to "$CLOUDISOURL" "${CLOUDISONAME/$arch/s390x}" "${targetdir/$arch/s390x}"
fi
fi
if [ ! -e "$targetdir/media.1" ] ; then
complain 35 "We do not have cloud install media in $targetdir - giving up"
fi
case "$cloudsource" in
GM6|GM7|GM8|GM9)
addcloudpool
;;
GM6+up|GM7+up|GM8+up|GM9+up)
addcloudpool
addcloudmaintupdates
;;
esac
if [[ "$want_test_updates" = 1 ]] ; then
case "$cloudsource" in
GM6|GM7|GM8|GM9)
addslestestupdates
;;
GM6+up|GM7+up|GM8+up|GM9+up)
addslestestupdates
addcloudtestupdates
;;
develcloud6)
addslestestupdates
;;
develcloud7)
addslestestupdates
;;
develcloud8)
addslestestupdates
;;
*cloud9|M?*|Beta*|RC*|GMC*)
addslestestupdates
;;
*)
complain 26 "no test update repos defined for cloudsource=$cloudsource"
;;
esac
fi
}
function onadmin_add_cloud_repo
{
local targetdir="$tftpboot_repos_dir/Cloud/"
$zypper rr Cloud
safely $zypper ar -f $targetdir Cloud
if [ -n "${localreposdir_target}" ]; then
echo $CLOUDLOCALREPOS > /etc/cloudversion
else
cat "$targetdir/isoversion" > /etc/cloudversion
fi
# Just document the list of extra repos
if [[ $UPDATEREPOS ]]; then
local repo
for repo in ${UPDATEREPOS//+/ } ; do
echo "+ with extra repo from $repo" >> /etc/cloudversion
done
fi
(
echo -n "This cloud was installed from: "
cat /etc/cloudversion
echo
) >> /etc/motd
}
function onadmin_write_cloud_info
{
(
echo -n "This cloud was installed on: "
cat ~/cloud
echo
if [[ $JENKINS_BUILD_URL ]] ; then
echo "Installed via Jenkins"
echo " created by the job: $JENKINS_BUILD_URL"
echo " on the Jenkins worker: $JENKINS_NODE_NAME"
echo " using executor number: $JENKINS_EXECUTOR_NUMBER"
echo " using workspace path: $JENKINS_WORKSPACE"
echo
fi
if [[ $clouddescription ]] ; then
echo "Cloud Description (set by the deployer):"
echo "$clouddescription"
echo
fi
) >> /etc/motd
}
function do_set_repos_skip_checks
{
# We don't use the proper pool/updates repos when using a devel build
if iscloudver 5plus && [[ $cloudsource =~ (develcloud|GM5$|GM6$) ]]; then
export REPOS_SKIP_CHECKS+=" SUSE-Cloud-$cloudrepover-Pool SUSE-Cloud-$cloudrepover-Updates"
fi
}
function create_repos_yml_for_platform
{
local platform=$1
local arch=$2
local tftpboot_dir=$3
shift; shift; shift
local platform_created
local repo
local repo_name
local repo_url
for repo in $*; do
repo_name=${repo%%=*}
repo_url=${repo##*=}
if [ -z "$platform_created" ]; then
echo "$platform:"
echo " $arch:"
platform_created=1
fi
echo " $repo_name:"
echo " url: '$repo_url'"
case "$repo_name" in
SLES*)
echo " features: ['os']"
;;
*HA*)
echo " features: ['ha']"
;;
*Storage*)
echo " features: ['ceph']"
;;
*OpenStack*)
echo " features: ['openstack']"
;;
esac
done
}
function create_repos_yml
{
local repos_yml="/etc/crowbar/repos.yml"
local tmp_yml=$(mktemp).yml
local additional_repos=
echo --- > $tmp_yml
common_set_versions
# Clone test updates from admin node
local baseurl=http://${crowbar_name}.$cloudfqdn:8091/
grep -q SLES$slesversion-Updates-test /etc/fstab && \
additional_repos+=" SLES$slesversion-Updates-test=$baseurl/suse-$suseversion/$arch/repos/SLES$slesversion-Updates-test"
# FIXME LTSS repo empty for SLE12-SP4, do not add it as zypper does not like empty repos
if iscloudver 9minus ; then
grep -q SLES$slesversion-LTSS-Updates /etc/fstab && \
additional_repos+=" SLES$slesversion-LTSS-Updates=$baseurl/suse-$suseversion/$arch/repos/SLES$slesversion-LTSS-Updates"
grep -q SLES$slesversion-LTSS-Updates-test /etc/fstab && \
additional_repos+=" SLES$slesversion-LTSS-Updates-test=$baseurl/suse-$suseversion/$arch/repos/SLES$slesversion-LTSS-Updates-test"
fi
grep -q SLE$slesversion-HA-Updates-test /etc/fstab && \
additional_repos+=" SLE$slesversion-HA-Updates-test=$baseurl/suse-$suseversion/$arch/repos/SLE$slesversion-HA-Updates-test"
grep -q SUSE-OpenStack-Cloud-$cloudrepover-Updates-test /etc/fstab && \
additional_repos+=" SUSE-OpenStack-Cloud-$cloudrepover-Updates-test=$baseurl/suse-$suseversion/$arch/repos/SUSE-OpenStack-Cloud-$cloudrepover-Updates-test"
grep -q SUSE-Enterprise-Storage-$sesversion-Updates-test /etc/fstab && \
additional_repos+=" SUSE-Enterprise-Storage-$sesversion-Updates-test=$baseurl/suse-$suseversion/$arch/repos/SUSE-Enterprise-Storage-$sesversion-Updates-test"
if iscloudver 6; then
for devel_repo in ${want_devel_repos//,/ }; do
case "$devel_repo" in
storage)
additional_repos+=" Devel-Storage=http://$susedownload/ibs/Devel:/Storage:/2.1/SLE12_SP1/"
;;
virt)
additional_repos+=" Devel-Virt=http://$susedownload/ibs/Devel:/Virt:/SLE-12-SP1/SUSE_SLE-12-SP1_Update_standard/"
;;
esac
done
fi
if iscloudver 7; then
for devel_repo in ${want_devel_repos//,/ }; do
case "$devel_repo" in
storage)
additional_repos+=" Devel-Storage=http://$susedownload/ibs/Devel:/Storage:/4.0/SLE12_SP2/"
;;
virt)
additional_repos+=" Devel-Virt=http://$susedownload/ibs/Devel:/Virt:/SLE-12-SP2/SUSE_SLE-12-SP2_GA_standard/"
;;
esac
done
fi
create_repos_yml_for_platform "suse-$suseversion" "$arch" "$tftpboot_repos_dir" \
$additional_repos \
>> $tmp_yml
mv $tmp_yml $repos_yml
}
function onadmin_set_source_variables
{
case "$cloudsource" in
develcloud6)
if [ -n "$want_cloud6_iso_url" ]; then
CLOUDISOURL="$want_cloud6_iso_url"
else
CLOUDISOURL="$susedownload/ibs/Devel:/Cloud:/6/images/iso/"
[ -n "$TESTHEAD" ] && CLOUDISOURL="$susedownload/ibs/Devel:/Cloud:/6:/Staging/images/iso/"
fi
CLOUDISONAME=${want_cloud6_iso:="SUSE-OPENSTACK-CLOUD-6-${arch}-Media1.iso"}
CLOUDLOCALREPOS="SUSE-OpenStack-Cloud-6-devel"
;;
develcloud7)
if [ -n "$want_cloud7_iso_url" ]; then
CLOUDISOURL="$want_cloud7_iso_url"
else
CLOUDISOURL="$susedownload/ibs/Devel:/Cloud:/7/images/iso/"
[ -n "$TESTHEAD" ] && CLOUDISOURL="$susedownload/ibs/Devel:/Cloud:/7:/Staging/images/iso/"
fi
CLOUDISONAME=${want_cloud7_iso:="SUSE-OPENSTACK-CLOUD-7-${arch}-Media1.iso"}
CLOUDLOCALREPOS="SUSE-OpenStack-Cloud-7-devel"
;;
develcloud8)
if [ -n "$want_cloud8_iso_url" ]; then
CLOUDISOURL="$want_cloud8_iso_url"
else
CLOUDISOURL="$susedownload/ibs/Devel:/Cloud:/8/images/iso/"
[ -n "$TESTHEAD" ] && CLOUDISOURL="$susedownload/ibs/Devel:/Cloud:/8:/Staging/images/iso/"
fi
CLOUDISONAME=${want_cloud8_iso:="SUSE-OPENSTACK-CLOUD-CROWBAR-8-${arch}-Media1.iso"}
CLOUDLOCALREPOS="SUSE-OpenStack-Cloud-Crowbar-8-devel"
;;
develcloud9)
if [ -n "$want_cloud9_iso_url" ]; then
CLOUDISOURL="$want_cloud9_iso_url"
else
CLOUDISOURL="$susedownload/ibs/Devel:/Cloud:/9/images/iso/"
[ -n "$TESTHEAD" ] && CLOUDISOURL="$susedownload/ibs/Devel:/Cloud:/9:/Staging/images/iso/"
fi
CLOUDISONAME=${want_cloud9_iso:="SUSE-OPENSTACK-CLOUD-CROWBAR-9-${arch}-Media1.iso"}
CLOUDLOCALREPOS="SUSE-OpenStack-Cloud-Crowbar-9-devel"
;;
GM9|GM9+up)
cs=$cloudsource
[[ $cs =~ GM9 ]] && cs=GM
CLOUDISOURL="${want_cloud9_iso_url:=$reposerver/install/SLE-12-SP4-Cloud9-$cs/}"
CLOUDISONAME=${want_cloud9_iso:="SUSE-OPENSTACK-CLOUD-CROWBAR-9-${arch}*1.iso"}
CLOUDLOCALREPOS="SUSE-OpenStack-Cloud-Crowbar-9-official"
;;
GM6|GM6+up)
cs=$cloudsource
[[ $cs =~ GM6 ]] && cs=GM
CLOUDISOURL="${want_cloud6_iso_url:=$reposerver/install/SLE-12-SP1-Cloud6-$cs/}"
CLOUDISONAME=${want_cloud6_iso:="SUSE-OPENSTACK-CLOUD-6-${arch}*1.iso"}
CLOUDLOCALREPOS="SUSE-OpenStack-Cloud-6-official"
;;
GM7|GM7+up)
cs=$cloudsource
[[ $cs =~ GM7 ]] && cs=GM
CLOUDISOURL="${want_cloud7_iso_url:=$reposerver/install/SLE-12-SP2-Cloud7-$cs/}"
CLOUDISONAME=${want_cloud7_iso:="SUSE-OPENSTACK-CLOUD-7-${arch}*1.iso"}
CLOUDLOCALREPOS="SUSE-OpenStack-Cloud-7-official"
;;
GM8|GM8+up)
cs=$cloudsource
[[ $cs =~ GM8 ]] && cs=GM
CLOUDISOURL="${want_cloud8_iso_url:=$reposerver/install/SLE-12-SP3-Cloud8-$cs/}"
CLOUDISONAME=${want_cloud8_iso:="SUSE-OPENSTACK-CLOUD-CROWBAR-8-${arch}*1.iso"}
CLOUDLOCALREPOS="SUSE-OpenStack-Cloud-Crowbar-8-official"
;;
GMC*|M?*|RC?)
cs=$cloudsource
CLOUDISOURL="${want_cloud9_iso_path:=$susedownload/install/SLE-12-SP4-Cloud9-$cs/}"
CLOUDISONAME=${want_cloud9_iso:="SUSE-OPENSTACK-CLOUD-CROWBAR-9-${arch}-Media1.iso"}
CLOUDLOCALREPOS="SUSE-OpenStack-Cloud-Crowbar-9-official"
;;
*)
complain 76 "You must set environment variable cloudsource=develcloud6|develcloud7|develcloud8|develcloud9|Mx|GM6|GM7"
;;
esac
if [ -n "$TESTHEAD" ] && [[ $cloudsource =~ (develcloud) ]]; then
CLOUDLOCALREPOS="$CLOUDLOCALREPOS-staging"
fi
common_set_versions
}
# replace zypper repos from the image with user-specified ones
# because the reposerver might not be reachable from where this runs
function onadmin_setup_local_zypper_repositories
{
local localrepos_base
# Delete all repos except PTF repo, because this could
# be called after the addupdaterepo step.
$zypper lr -e - | sed -n '/^name=/ {s///; /ptf/! p}' | \
xargs -r zypper rr
[ -n "${localreposdir_target}" ] && mount_localreposdir_target
mkdir -p /hostmirror
for repo in SLES$slesversion-{Pool,Updates}; do
add_mount "repos/$arch/$repo" "/hostmirror/$repo" $repo
done
}
# setup network/DNS, add repos and install crowbar packages
function onadmin_prepareinstallcrowbar
{
pre_hook $FUNCNAME
[[ $forcephysicaladmin ]] || lsmod | grep -q ^virtio_blk || complain 25 "this script should be run in the crowbar admin VM"
[[ $want_ssl_keys ]] && ! [[ -e /root/cloud-keys/ ]] && rsync -a "$want_ssl_keys/" /root/cloud-keys/
[[ $want_rootpw = linux ]] || echo -e "$want_rootpw\n$want_rootpw" | passwd
echo configure static IP and absolute + resolvable hostname ${crowbar_name}.$cloudfqdn gw:$net${ip_sep}1
# We want to use static networking which needs a static resolv.conf .
# The SUSE sysconfig/ifup scripts drop DNS-servers received from DHCP
# when switching from DHCP to static.
# This dropping is avoided by stripping comments.
sed -i -e 's/#.*//' /etc/resolv.conf
cat > /etc/sysconfig/network/ifcfg-eth0 <<EOF