-
Notifications
You must be signed in to change notification settings - Fork 16
/
jenkins-deb-chef-upgrade
executable file
·169 lines (133 loc) · 4.35 KB
/
jenkins-deb-chef-upgrade
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
#!/bin/bash
#
# $1 = test repo number
#
# force a local default so this can be run on command line
DISTRELEASE=${DISTRELEASE-ubuntu-natty}
declare -A componentmap
componentmap=(
[diablo-d5]="cookbooks-release-2011.3-d5.tgz"
[diablo-final]="cookbooks.tgz"
)
[ -e $(dirname $0)/jenkins-deb-common ] || exit 1
. $(dirname $0)/jenkins-deb-common
jenkins_init
jenkins_set_vars
echo ${DISTRELEASE}
echo ${FROMCOMPONENT}
echo ${TOCOMPONENT}
echo ${componentmap[${FROMCOMPONENT-}]-}
echo ${componentmap[${TOCOMPONENT-}]-}
FROM_TARBALL=${componentmap[${FROMCOMPONENT}]}
TO_TARBALL=${componentmap[${TOCOMPONENT}]}
function err_cleanup_chefsolo() {
# $1 - name
if [ "${NOCLEAN-0}" == "1" ]; then
exit 0
fi
sudo virsh destroy ${1}
sleep 5
sudo lvremove -f ${LVM_ROOT}/${1}
exit 1
}
kvm_instance_name=${BINARY_BUILD_RELEASE}-upgrade-test
# kvm_instance_name=${BINARY_BUILD_RELEASE}-${NOVA_RELEASE}-${MILESTONE}-chefsolo
# this sets IP as a side-effect
get_ip $kvm_instance_name
MEMORY=2048000
maybe_make_kvm_instance $kvm_instance_name
start_kvm_instance $kvm_instance_name ${IP} http://192.168.1.1/packages ${BINARY_BUILD_RELEASE} ${FROMCOMPONENT}
trap "err_cleanup_chefsolo ${kvm_instance_name}" SIGINT SIGTERM EXIT ERR
cat > /tmp/${kvm_instance_name}-FROM.json <<EOF
{
"public": {
"label": "public",
"num_networks": "1",
"network_size": "255",
"bridge": "br100",
"bridge_dev": "eth0.100",
"dns1": "8.8.8.8",
"dns2": "8.8.4.4"
},
"private": {
"label": "private",
"num_networks": "1",
"network_size": "255",
"bridge": "br101",
"bridge_dev": "eth0.101",
"dns1": "8.8.8.8",
"dns2": "8.8.4.4"
},
"image": {
"oneiric": "http://${IMAGE_CACHE}/ubuntu-11.10-server-uec-amd64-multinic.tar.gz",
"natty": "http://${IMAGE_CACHE}/ubuntu-11.04-server-uec-amd64-multinic.tar.gz",
"maverick": "http://${IMAGE_CACHE}/ubuntu-10.10-server-uec-amd64-multinic.tar.gz"
},
"package_url": "http://build.monkeypuppetlabs.com/packages",
"package_release": "${BINARY_BUILD_RELEASE}",
"package_component": "${FROMCOMPONENT}",
"virt_type": "qemu",
"run_list": [ "recipe[apt]", "recipe[openstack::allinone]" ]
}
EOF
ssh root@${IP} apt-get install vlan -y --force-yes
ssh root@${IP} vconfig add eth0 100
ssh root@${IP} vconfig add eth0 101
run_chef_solo ${IP} "https://raw.github.com/rcbops/chef-cookbooks/diablo/${FROM_TARBALL}" /tmp/${kvm_instance_name}-FROM.json
sleep 20
# Glance upgrade fixup
ssh root@${IP} "stop glance-api && stop glance-registry"
ssh root@${IP} "glance-manage version_control"
ssh root@${IP} "mysql -u root glance -e 'update migrate_version set version=8'"
# box should be configured now....
echo "#########################################"
echo "## ${FROMCOMPONENT} HAS BEEN INSTALLED ##"
echo "#########################################"
echo "## GONNA UPGRADE TO ${TOCOMPONENT} NOW ##"
echo "#########################################"
# Need to clean up diablo-d5 source file..
ssh root@${IP} "rm /etc/apt/sources.list.d/rcb-packages.list"
ssh root@${IP} "apt-get -qq -y --force-yes install git"
ssh root@${IP} "cd /opt && git clone https://github.com/rcbops/keystone-upgrade"
if ! ( ssh root@${IP} "cd /opt/keystone-upgrade && ./keystone_upgrade.py" ); then
echo "Keystone-Upgrade FAILED"
exit 1
fi
# NEED TO RUN AN UPGRADE HERE
cat > /tmp/${kvm_instance_name}-TO.json <<EOF
{
"public": {
"label": "public",
"num_networks": "1",
"network_size": "255",
"bridge": "br100",
"bridge_dev": "eth0.100",
"dns1": "8.8.8.8",
"dns2": "8.8.4.4"
},
"private": {
"label": "private",
"num_networks": "1",
"network_size": "255",
"bridge": "br101",
"bridge_dev": "eth0.101",
"dns1": "8.8.8.8",
"dns2": "8.8.4.4"
},
"package_url": "http://build.monkeypuppetlabs.com/packages",
"package_release": "${BINARY_BUILD_RELEASE}",
"package_component": "${TOCOMPONENT}",
"virt_type": "qemu",
"run_list": [ "recipe[apt]", "recipe[openstack::allinone]", "recipe[kong]" ]
}
EOF
run_chef_solo ${IP} "https://raw.github.com/rcbops/chef-cookbooks/diablo/${TO_TARBALL}" /tmp/${kvm_instance_name}-TO.json
sleep 20
if ! ( ssh root@${IP} "cd /opt/kong; ./run_tests.sh --nova" ); then
echo "Error in NOVA tests"
exit 1
fi
trap - SIGINT SIGTERM EXIT ERR
sudo virsh destroy ${kvm_instance_name}
sleep 5
sudo lvremove -f ${LVM_ROOT}/${kvm_instance_name}