-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos-upgrade
135 lines (127 loc) · 3.25 KB
/
os-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
#!/bin/bash
### Script for updating OpenStack services
### Marius Lazar @ AeriaGames - 10.05.2021
#
# VARIABLES
ver="focal-wallaby" # version to update to
### cloud:focal-wallaby
declare -a machines
# STEP 1 - Update the machines
#
## running the updates on all machines
./os-update-distro
#
# STEP 2 - update charms
# use with caution - needs work
#./os-up-charm
#
# STEP 3 - Do a db backup
#
echo "Create DB backup and save it localy in /backup"
#juju run-action --wait mysql-innodb-cluster/0 mysqldump
# copy the backup into /backups
#juju ssh mysql-innodb-cluster/0 sudo chown -R ubuntu. /var/backups/mysql/
#juju scp -- mysql-innodb-cluster/0:/var/backups/mysql/mysqldump-all-databases-$(date +"%Y%m%d")*.gz /backups
# archive old data
juju run-action --wait nova-cloud-controller/0 archive-data
#
# STEP 4 - run the actual update in the order of dependencies
# create the function for updating
function update(){
local charm=$1
local status=$2 ### <y or n> sow the status
echo "Starting update on " $charm
juju run-action --wait $charm pause
juju run-action --wait $charm openstack-upgrade
juju run-action --wait $charm resume
sleep 10
if [ $status = "y" ]; then
watch -n5 -c juju status --color
fi
}
# create preparation function
function prep(){
local charm=$1 ### what is updating
local type=$2 ### how it's updating <origin or source>
declare -a units
# this won't hurt if it's failing
juju config $charm action-managed-upgrade=True
if [ $type = "origin" ]; then
juju config $charm openstack-origin=cloud:$ver
elif [ $type = "source" ]; then
juju config $charm source=cloud:$ver
else
echo "WRONG type!!!"
exit 1
fi
# trying to find the leader as it should always be updated first
cdetail=$(juju status --format="json" $charm | jq .applications.\"$charm\".units)
cunits=$(echo $cdetail | jq -rc 'keys')
# removing the [ ]
cunits=${cunits:1:-1}
OLDIFS=$IFS
IFS=','
for cunit in $cunits
do
IFS=$OLDIFS
# removing " "
cunit=${cunit:1:-1}
trueleader=$(echo $cdetail | jq .\"$cunit\".leader)
if [ $trueleader = "true" ]; then
cleader=$cunit
echo $cleader
else
units+=($cunit)
fi
done
IFS=$OLDIFS
# running the actual update starting with the leader
update $cleader y
if [ ${#units[@]} -gt 0 ] ; then
for unit in "${units[@]}"
do
update $unit n
done
fi
# clean up variables
unset unit units charm type cleader OLDIFS cunit trueleader cunits cdetail
}
# ITEMIZED UPDATE!
#prep rabbitmq-server origin
### different update procedure
#juju run-action --wait rabbitmq-server complete-cluster-series-upgrade
# leave ceph alone!
#prep ceph-mon source
prep keystone origin
prep vault origin
### this may fail and it's OK-ish
#prep aodh origin
#barbican
#prep celiometer origin
#ceph-fs
#prep ceph-radosgw source
prep cinder origin
#designate
#designate-bind
#prep glance origin
#prep gnocchi origin
#heat
#manila
#manila-generic
prep neutron-api origin
#neutron-gateway
prep placement origin
prep nova-cloud-controller origin
prep openstack-dashboard origin
prep nova-compute origin
#prep ceph-osd source
#swift-proxy
#swift storage
#octavia
prep ovn-central source
prep cinder-ceph origin
### may fail
#prep memcached origin
prep neutron-api-plugin-ovn origin
prep ovn-chassis origin
### may fail