forked from kronosnet/ci-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci-setup-anvil-bm-vm-kmods
executable file
·130 lines (109 loc) · 3.35 KB
/
ci-setup-anvil-bm-vm-kmods
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
#!/bin/bash
set -e
. $HOME/ci-tools/ci-setup-anvil-vm-env
echo "Destroying VMs (if any)"
for i in $ALLNODES $CACHENODES; do
destroy_vm $i
done
$HOME/ci-tools/ci-setup-anvil-bm-vm-cache $BUILD none none
echo "Building drbd kmod for ${BUILD} repo: ${REPOSRC} anvil: ${ANVILSRC}"
cd "$DEPLOYDIR/cache"
rm -f an-cache-vol.qcow2
qemu-img create -b "$DEPLOYDIR/cache/${BUILD}-latest.qcow2" -F qcow2 -f qcow2 "an-cache-vol.qcow2" 200G
cat "$TEMPLATESDIR/anvil_striker_net_config.cfg" | sed -e "s#@IFNIP@#192.168.122.2#g" > an-cache_net_config.cfg
cat "$TEMPLATESDIR/anvil_cloud_init_${BUILD}.cfg" | \
sed \
-e "s#@HOSTNAME@#an-cache#g" \
-e "s#@BUILD@#${BUILD}#g" \
-e "s#@SSHKEY@#${SSHKEY}#g" \
-e "s#@KEY@#${KEY}#g" \
-e "s#@ORG@#${ORG}#g" \
-e "s#@AKEY@#${AKEY}#g" \
-e "s#@PRNUM@#${PRNUM}#g" \
-e "s#@PRREPO@#${PRREPO}#g" \
-e "s#@ANVIL@#${ANVIL}#g" \
-e "s#@ANVILDEPS@#${ANVILDEPS}#g" \
-e "s#@ALTEEVE@#${ALTEEVE}#g" \
-e "s#@ALTEEVESTAGING@#${ALTEEVESTAGING}#g" \
-e "s#@ANVILPKG@# - akmod-drbd#g" \
> "an-cache_cloud_init.cfg"
rm -f "an-cache-seed.img"
echo "instance-id: $(uuidgen)" > "an-cache-metadata"
cloud-localds -v --network-config="an-cache_net_config.cfg" "an-cache-seed.img" "an-cache_cloud_init.cfg" "an-cache-metadata"
virt-install --name an-cache \
--virt-type kvm --memory 16384 --vcpus 6 \
--boot hd,menu=on \
--disk path="$DEPLOYDIR/cache/an-cache-seed.img",device=cdrom \
--disk path="$DEPLOYDIR/cache/an-cache-vol.qcow2",device=disk \
--graphics vnc \
--os-variant $KVMVAR \
--network network:ifn1_bridge1,model=e1000 \
--noautoconsole
echo "Waiting for nodes and cloud-init to complete full init"
bootdone=no
expected=1
error=0
while [ "$bootdone" = "no" ]; do
actual=0
for i in $CACHENODES; do
status=$(ssh $i cloud-init status 2>/dev/null | awk '{print $NF}')
echo "cloud-init status node $i: $status"
if [ "$status" = "error" ]; then
error=1
expected=$((expected - 1))
echo "ERROR cloud init log for node $i:"
ssh $i cat /var/log/cloud-init-output.log
echo "---------------------------"
fi
if [ "$status" = "done" ]; then
actual=$((actual + 1))
fi
done
echo "$(date) actual: $actual expected: $expected"
if [ "$actual" = "$expected" ]; then
bootdone=yes
else
sleep 10
fi
done
if [ "$error" = "1" ]; then
echo "Unable to deploy an-cache vm to build drbd module"
destroy_vm an-cache
exit 1
fi
echo "Waiting for akmods to complete build"
timeout=360
builddone=no
while [ "$builddone" = no ] && [ "$timeout" -gt 0 ]; do
if ! ssh an-cache ls /var/cache/akmods/drbd/*.rpm 2>/dev/null; then
echo "build not found, sleeping 10 seconds"
sleep 10
timeout=$((timeout - 10))
else
echo "build found"
builddone=yes
fi
done
if [ "$builddone" = yes ]; then
rm -rf temp
mkdir -p temp
scp an-cache:/var/cache/akmods/drbd/*.rpm temp/ || error=1
cd temp
ssh anvil-ci-proxy "mkdir -p /var/www/html/kmods/${BUILD}/${REPOSRC}/"
scp *.rpm anvil-ci-proxy:/var/www/html/kmods/${BUILD}/${REPOSRC}/ || error=1
ssh anvil-ci-proxy "cd /var/www/html/kmods/${BUILD}/${REPOSRC}/ && createrepo ." || error=1
cd -
rm -rf temp
else
error=1
fi
destroy_vm an-cache
# repeat to make sure known_hosts is clean after caching
rm -f $HOME/.ssh/known_hosts
ssh-keyscan github.com > $HOME/.ssh/known_hosts
if [ "$error" = "1" ]; then
echo "Failed to build drbd kmods"
else
echo "Done building drbd kmods"
fi
exit $error