blob: 8f2aebdad18f4b1c3d918b11383cd1ce54293050 [file] [log] [blame]
Jiri Broulikbb447ac2017-05-04 15:36:22 +02001/**
2 * Update packages on given nodes
3 *
4 * Expected parameters:
5 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
6 * SALT_MASTER_URL Full Salt API address [http://10.10.10.1:8000].
Jiri Broulik3792c962017-05-17 18:26:36 +02007 * STAGE_TEST_UPGRADE Run test upgrade stage (bool)
8 * STAGE_REAL_UPGRADE Run real upgrade stage (bool)
9 * STAGE_ROLLBACK_UPGRADE Run rollback upgrade stage (bool)
Jiri Broulikbb447ac2017-05-04 15:36:22 +020010 *
11**/
12
13def common = new com.mirantis.mk.Common()
14def salt = new com.mirantis.mk.Salt()
chnyda625f4b42017-10-11 14:10:31 +020015def python = new com.mirantis.mk.Python()
Jiri Broulikbb447ac2017-05-04 15:36:22 +020016
chnyda625f4b42017-10-11 14:10:31 +020017def pepperEnv = "pepperEnv"
Jiri Broulikbb447ac2017-05-04 15:36:22 +020018
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040019node() {
Jiri Broulikbb447ac2017-05-04 15:36:22 +020020
chnyda625f4b42017-10-11 14:10:31 +020021 stage('Setup virtualenv for Pepper') {
Dmitrii Kabanovf31c8962017-10-12 21:00:30 -070022 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040023 }
Jiri Broulikbb447ac2017-05-04 15:36:22 +020024
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040025 if (STAGE_TEST_UPGRADE.toBoolean() == true) {
26 stage('Test upgrade') {
Jiri Broulik3792c962017-05-17 18:26:36 +020027
Jiri Broulik3792c962017-05-17 18:26:36 +020028
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040029 try {
chnyda625f4b42017-10-11 14:10:31 +020030 salt.enforceState(pepperEnv, 'I@salt:master', 'reclass')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040031 } catch (Exception e) {
32 common.warningMsg("Some parts of Reclass state failed. The most probable reasons were uncommited changes. We should continue to run")
33 }
Jiri Broulik80d96752017-05-22 19:42:01 +020034
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040035 try {
chnyda625f4b42017-10-11 14:10:31 +020036 salt.runSaltProcessStep(pepperEnv, '*', 'saltutil.refresh_pillar', [], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040037 } catch (Exception e) {
38 common.warningMsg("No response from some minions. We should continue to run")
39 }
Jiri Broulik3792c962017-05-17 18:26:36 +020040
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040041 try {
chnyda625f4b42017-10-11 14:10:31 +020042 salt.runSaltProcessStep(pepperEnv, '*', 'saltutil.sync_all', [], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040043 } catch (Exception e) {
44 common.warningMsg("No response from some minions. We should continue to run")
45 }
Jiri Broulik3792c962017-05-17 18:26:36 +020046
chnyda625f4b42017-10-11 14:10:31 +020047 def _pillar = salt.getGrain(pepperEnv, 'I@salt:master', 'domain')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040048 def domain = _pillar['return'][0].values()[0].values()[0]
49 print(_pillar)
50 print(domain)
Jiri Broulik3792c962017-05-17 18:26:36 +020051
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040052 // read backupninja variable
chnyda625f4b42017-10-11 14:10:31 +020053 _pillar = salt.getPillar(pepperEnv, 'I@backupninja:client', '_param:backupninja_backup_host')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040054 def backupninja_backup_host = _pillar['return'][0].values()[0]
55 print(_pillar)
56 print(backupninja_backup_host)
Jiri Broulik3792c962017-05-17 18:26:36 +020057
chnyda625f4b42017-10-11 14:10:31 +020058 _pillar = salt.getGrain(pepperEnv, 'I@salt:control', 'id')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040059 def kvm01 = _pillar['return'][0].values()[0].values()[0]
60 print(_pillar)
61 print(kvm01)
62
chnyda625f4b42017-10-11 14:10:31 +020063 _pillar = salt.getPillar(pepperEnv, "${kvm01}", 'salt:control:cluster:internal:node:upg01:provider')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040064 def upgNodeProvider = _pillar['return'][0].values()[0]
65 print(_pillar)
66 print(upgNodeProvider)
Jiri Broulikbb447ac2017-05-04 15:36:22 +020067
Jiri Broulik6fc9d3f2017-05-12 07:11:29 +020068
chnyda625f4b42017-10-11 14:10:31 +020069 salt.runSaltProcessStep(pepperEnv, "${upgNodeProvider}", 'virt.destroy', ["upg01.${domain}"], null, true)
70 salt.runSaltProcessStep(pepperEnv, "${upgNodeProvider}", 'virt.undefine', ["upg01.${domain}"], null, true)
Jiri Broulik6fc9d3f2017-05-12 07:11:29 +020071
72
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040073 try {
chnyda625f4b42017-10-11 14:10:31 +020074 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d upg01.${domain} -y")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040075 } catch (Exception e) {
76 common.warningMsg("upg01.${domain} does not match any accepted, unaccepted or rejected keys. The key did not exist yet or was already removed. We should continue to run")
77 }
Jiri Broulikbb447ac2017-05-04 15:36:22 +020078
Jiri Broulikbb447ac2017-05-04 15:36:22 +020079
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040080 // salt 'kvm02*' state.sls salt.control
chnyda625f4b42017-10-11 14:10:31 +020081 salt.enforceState(pepperEnv, "${upgNodeProvider}", 'salt.control')
Jiri Broulikbb447ac2017-05-04 15:36:22 +020082
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040083 // wait until upg node is registered in salt-key
chnyda625f4b42017-10-11 14:10:31 +020084 salt.minionPresent(pepperEnv, 'I@salt:master', 'upg01')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040085
86 // salt '*' saltutil.refresh_pillar
chnyda625f4b42017-10-11 14:10:31 +020087 salt.runSaltProcessStep(pepperEnv, 'upg*', 'saltutil.refresh_pillar', [], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040088 // salt '*' saltutil.sync_all
chnyda625f4b42017-10-11 14:10:31 +020089 salt.runSaltProcessStep(pepperEnv, 'upg*', 'saltutil.sync_all', [], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040090
91 // salt "upg*" state.sls linux,openssh,salt.minion,ntp,rsyslog
92 try {
chnyda625f4b42017-10-11 14:10:31 +020093 salt.enforceState(pepperEnv, 'upg*', ['linux', 'openssh', 'salt.minion', 'ntp', 'rsyslog'])
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040094 } catch (Exception e) {
95 common.warningMsg('Received no response because salt-minion was restarted. We should continue to run')
96 }
chnyda625f4b42017-10-11 14:10:31 +020097 salt.enforceState(pepperEnv, 'upg*', ['linux', 'openssh', 'salt.minion', 'ntp', 'rsyslog'])
Jiri Broulikbb447ac2017-05-04 15:36:22 +020098
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +040099 // salt "upg*" state.sls rabbitmq
chnyda625f4b42017-10-11 14:10:31 +0200100 salt.enforceState(pepperEnv, 'upg*', ['rabbitmq', 'memcached'])
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400101 try {
chnyda625f4b42017-10-11 14:10:31 +0200102 salt.enforceState(pepperEnv, 'I@backupninja:client', ['openssh.client', 'salt.minion'])
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400103 } catch (Exception e) {
104 common.warningMsg('salt-minion was restarted. We should continue to run')
105 }
106 try {
chnyda625f4b42017-10-11 14:10:31 +0200107 salt.enforceState(pepperEnv, 'I@backupninja:server', ['salt.minion'])
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400108 } catch (Exception e) {
109 common.warningMsg('salt-minion was restarted. We should continue to run')
110 }
111 // salt '*' state.apply salt.minion.grains
chnyda625f4b42017-10-11 14:10:31 +0200112 //salt.enforceState(pepperEnv, '*', 'salt.minion.grains')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400113 // salt -C 'I@backupninja:server' state.sls backupninja
chnyda625f4b42017-10-11 14:10:31 +0200114 salt.enforceState(pepperEnv, 'I@backupninja:server', 'backupninja')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400115 // salt -C 'I@backupninja:client' state.sls backupninja
chnyda625f4b42017-10-11 14:10:31 +0200116 salt.enforceState(pepperEnv, 'I@backupninja:client', 'backupninja')
117 salt.runSaltProcessStep(pepperEnv, 'I@backupninja:client', 'ssh.rm_known_host', ["root", "${backupninja_backup_host}"], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400118 try {
chnyda625f4b42017-10-11 14:10:31 +0200119 salt.cmdRun(pepperEnv, 'I@backupninja:client', "arp -d ${backupninja_backup_host}")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400120 } catch (Exception e) {
121 common.warningMsg('The ARP entry does not exist. We should continue to run.')
122 }
chnyda625f4b42017-10-11 14:10:31 +0200123 salt.runSaltProcessStep(pepperEnv, 'I@backupninja:client', 'ssh.set_known_host', ["root", "${backupninja_backup_host}"], null, true)
124 salt.cmdRun(pepperEnv, 'I@backupninja:client', 'backupninja -n --run /etc/backup.d/101.mysql')
125 salt.cmdRun(pepperEnv, 'I@backupninja:client', 'backupninja -n --run /etc/backup.d/200.backup.rsync > /tmp/backupninjalog')
Jiri Broulik6fc9d3f2017-05-12 07:11:29 +0200126
chnyda625f4b42017-10-11 14:10:31 +0200127 salt.enforceState(pepperEnv, 'I@xtrabackup:server', 'xtrabackup')
128 salt.enforceState(pepperEnv, 'I@xtrabackup:client', 'openssh.client')
129 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
130 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh'")
Jiri Broulik6fc9d3f2017-05-12 07:11:29 +0200131
chnyda625f4b42017-10-11 14:10:31 +0200132 def databases = salt.cmdRun(pepperEnv, 'I@mysql:client','salt-call mysql.db_list | grep upgrade | awk \'/-/ {print \$2}\'')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400133 if(databases && databases != ""){
134 def databasesList = databases['return'][0].values()[0].trim().tokenize("\n")
135 for( i = 0; i < databasesList.size(); i++){
136 if(databasesList[i].toLowerCase().contains('upgrade')){
chnyda625f4b42017-10-11 14:10:31 +0200137 salt.runSaltProcessStep(pepperEnv, 'I@mysql:client', 'mysql.db_remove', ["${databasesList[i]}"], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400138 common.warningMsg("removing database ${databasesList[i]}")
chnyda625f4b42017-10-11 14:10:31 +0200139 salt.runSaltProcessStep(pepperEnv, 'I@mysql:client', 'file.remove', ["/root/mysql/flags/${databasesList[i]}-installed"], null, true)
Jiri Broulik3792c962017-05-17 18:26:36 +0200140 }
Jiri Broulik3792c962017-05-17 18:26:36 +0200141 }
chnyda625f4b42017-10-11 14:10:31 +0200142 salt.enforceState(pepperEnv, 'I@mysql:client', 'mysql.client')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400143 }else{
144 common.errorMsg("No _upgrade databases were returned")
145 }
Jiri Broulikbb447ac2017-05-04 15:36:22 +0200146
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400147 try {
chnyda625f4b42017-10-11 14:10:31 +0200148 salt.enforceState(pepperEnv, 'upg*', 'keystone.server')
149 salt.runSaltProcessStep(pepperEnv, 'upg*', 'service.restart', ['apache2'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400150 } catch (Exception e) {
151 common.warningMsg('Restarting Apache2')
chnyda625f4b42017-10-11 14:10:31 +0200152 salt.runSaltProcessStep(pepperEnv, 'upg*', 'service.restart', ['apache2'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400153 }
154 try {
chnyda625f4b42017-10-11 14:10:31 +0200155 salt.enforceState(pepperEnv, 'upg*', 'keystone.client')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400156 } catch (Exception e) {
157 common.warningMsg('running keystone.client state again')
chnyda625f4b42017-10-11 14:10:31 +0200158 salt.enforceState(pepperEnv, 'upg*', 'keystone.client')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400159 }
160 try {
chnyda625f4b42017-10-11 14:10:31 +0200161 salt.enforceState(pepperEnv, 'upg*', 'glance')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400162 } catch (Exception e) {
163 common.warningMsg('running glance state again')
chnyda625f4b42017-10-11 14:10:31 +0200164 salt.enforceState(pepperEnv, 'upg*', 'glance')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400165 }
chnyda625f4b42017-10-11 14:10:31 +0200166 salt.enforceState(pepperEnv, 'upg*', 'keystone.server')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400167 try {
chnyda625f4b42017-10-11 14:10:31 +0200168 salt.enforceState(pepperEnv, 'upg*', 'nova')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400169 } catch (Exception e) {
170 common.warningMsg('running nova state again')
chnyda625f4b42017-10-11 14:10:31 +0200171 salt.enforceState(pepperEnv, 'upg*', 'nova')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400172 }
173 // run nova state again as sometimes nova does not enforce itself for some reason
174 try {
chnyda625f4b42017-10-11 14:10:31 +0200175 salt.enforceState(pepperEnv, 'upg*', 'nova')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400176 } catch (Exception e) {
177 common.warningMsg('running nova state again')
chnyda625f4b42017-10-11 14:10:31 +0200178 salt.enforceState(pepperEnv, 'upg*', 'nova')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400179 }
180 try {
chnyda625f4b42017-10-11 14:10:31 +0200181 salt.enforceState(pepperEnv, 'upg*', 'cinder')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400182 } catch (Exception e) {
183 common.warningMsg('running cinder state again')
chnyda625f4b42017-10-11 14:10:31 +0200184 salt.enforceState(pepperEnv, 'upg*', 'cinder')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400185 }
186 try {
chnyda625f4b42017-10-11 14:10:31 +0200187 salt.enforceState(pepperEnv, 'upg*', 'neutron')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400188 } catch (Exception e) {
189 common.warningMsg('running neutron state again')
chnyda625f4b42017-10-11 14:10:31 +0200190 salt.enforceState(pepperEnv, 'upg*', 'neutron')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400191 }
192 try {
chnyda625f4b42017-10-11 14:10:31 +0200193 salt.enforceState(pepperEnv, 'upg*', 'heat')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400194 } catch (Exception e) {
195 common.warningMsg('running heat state again')
chnyda625f4b42017-10-11 14:10:31 +0200196 salt.enforceState(pepperEnv, 'upg*', 'heat')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400197 }
chnyda625f4b42017-10-11 14:10:31 +0200198 salt.cmdRun(pepperEnv, 'upg01*', '. /root/keystonercv3; openstack service list; openstack image list; openstack flavor list; openstack compute service list; openstack server list; openstack network list; openstack volume list; openstack orchestration service list')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400199
200 if (STAGE_TEST_UPGRADE.toBoolean() == true && STAGE_REAL_UPGRADE.toBoolean() == true) {
201 stage('Ask for manual confirmation') {
202 input message: "Do you want to continue with upgrade?"
Jiri Broulik3792c962017-05-17 18:26:36 +0200203 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400204 }
205 }
206 }
207
208 if (STAGE_REAL_UPGRADE.toBoolean() == true) {
209 stage('Real upgrade') {
210 // # actual upgrade
211
chnyda625f4b42017-10-11 14:10:31 +0200212 _pillar = salt.getGrain(pepperEnv, 'I@salt:master', 'domain')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400213 domain = _pillar['return'][0].values()[0].values()[0]
214 print(_pillar)
215 print(domain)
216
chnyda625f4b42017-10-11 14:10:31 +0200217 _pillar = salt.getGrain(pepperEnv, 'I@salt:control', 'id')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400218 kvm01 = _pillar['return'][0].values()[0].values()[0]
219 print(_pillar)
220 print(kvm01)
221
222 def errorOccured = false
223
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100224 def proxy_general_target = ""
225 def proxy_target_hosts = salt.getMinions(pepperEnv, 'I@horizon:server')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400226
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100227 for (t in proxy_target_hosts) {
228 def target = t.split("\\.")[0]
Jiri Broulik42dfbb12017-11-13 11:27:45 +0100229 proxy_general_target = target.replaceAll('\\d+$', "")
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100230 _pillar = salt.getPillar(pepperEnv, "${kvm01}", "salt:control:cluster:internal:node:${target}:provider")
231 def nodeProvider = _pillar['return'][0].values()[0]
232 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'virt.destroy', ["${target}.${domain}"], null, true)
233 sleep(2)
234 try {
235 salt.cmdRun(pepperEnv, "${nodeProvider}", "[ ! -f /root/${target}.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/${target}.${domain}/system.qcow2 ./${target}.${domain}.qcow2.bak")
236 } catch (Exception e) {
237 common.warningMsg('File already exists')
238 }
239 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'virt.undefine', ["${target}.${domain}"], null, true)
240 try {
241 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
242 } catch (Exception e) {
243 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
244 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400245 }
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100246 def control_general_target = ""
247 def control_target_hosts = salt.getMinions(pepperEnv, 'I@keystone:server')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400248
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100249 for (t in control_target_hosts) {
250 def target = t.split("\\.")[0]
Jiri Broulik42dfbb12017-11-13 11:27:45 +0100251 control_general_target = target.replaceAll('\\d+$', "")
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100252 _pillar = salt.getPillar(pepperEnv, "${kvm01}", "salt:control:cluster:internal:node:${target}:provider")
253 def nodeProvider = _pillar['return'][0].values()[0]
254 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'virt.destroy', ["${target}.${domain}"], null, true)
255 sleep(2)
256 try {
257 salt.cmdRun(pepperEnv, "${nodeProvider}", "[ ! -f /root/${target}.${domain}.qcow2.bak ] && cp /var/lib/libvirt/images/${target}.${domain}/system.qcow2 ./${target}.${domain}.qcow2.bak")
258 } catch (Exception e) {
259 common.warningMsg('File already exists')
260 }
261 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'virt.undefine', ["${target}.${domain}"], null, true)
262 try {
263 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
264 } catch (Exception e) {
265 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
266 }
267 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400268
chnyda625f4b42017-10-11 14:10:31 +0200269 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh'")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400270
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400271 // salt 'kvm*' state.sls salt.control
chnyda625f4b42017-10-11 14:10:31 +0200272 salt.enforceState(pepperEnv, 'I@salt:control', 'salt.control')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400273
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100274 for (t in control_target_hosts) {
275 def target = t.split("\\.")[0]
276 // wait until ctl and prx nodes are registered in salt-key
277 salt.minionPresent(pepperEnv, 'I@salt:master', '${target}')
278 }
279 for (t in proxy_target_hosts) {
280 def target = t.split("\\.")[0]
281 // wait until ctl and prx nodes are registered in salt-key
282 salt.minionPresent(pepperEnv, 'I@salt:master', '${target}')
283 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400284
285 // salt '*' saltutil.refresh_pillar
chnyda625f4b42017-10-11 14:10:31 +0200286 salt.runSaltProcessStep(pepperEnv, '*', 'saltutil.refresh_pillar', [], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400287 // salt '*' saltutil.sync_all
chnyda625f4b42017-10-11 14:10:31 +0200288 salt.runSaltProcessStep(pepperEnv, '*', 'saltutil.sync_all', [], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400289
290 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100291 salt.enforceState(pepperEnv, "${proxy_general_target}* or ${control_general_target}*", ['linux', 'openssh', 'salt.minion', 'ntp', 'rsyslog'])
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400292 } catch (Exception e) {
293 common.warningMsg('Received no response because salt-minion was restarted. We should continue to run')
294 }
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100295 salt.enforceState(pepperEnv, "${proxy_general_target}* or ${control_general_target}*", ['linux', 'openssh', 'salt.minion', 'ntp', 'rsyslog'])
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400296
297 // salt 'ctl*' state.sls keepalived
298 // salt 'ctl*' state.sls haproxy
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100299 salt.enforceState(pepperEnv, "${control_general_target}*", ['keepalived', 'haproxy'])
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400300 // salt 'ctl*' service.restart rsyslog
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100301 salt.runSaltProcessStep(pepperEnv, "${control_general_target}*", 'service.restart', ['rsyslog'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400302 // salt "ctl*" state.sls memcached
303 // salt "ctl*" state.sls keystone.server
304 try {
Jiri Broulik69de13a2017-05-18 13:53:58 +0200305 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100306 salt.enforceState(pepperEnv, "${control_general_target}*", ['memcached', 'keystone.server'])
307 salt.runSaltProcessStep(pepperEnv, "${control_general_target}*", 'service.restart', ['apache2'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400308 } catch (Exception e) {
309 common.warningMsg('Restarting Apache2 and enforcing keystone.server state again')
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100310 salt.runSaltProcessStep(pepperEnv, "${control_general_target}*", 'service.restart', ['apache2'], null, true)
311 salt.enforceState(pepperEnv, "${control_general_target}*", 'keystone.server')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400312 }
313 // salt 'ctl01*' state.sls keystone.client
314 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100315 salt.enforceState(pepperEnv, "I@keystone:client and ${control_general_target}*", 'keystone.client')
Jiri Broulik69de13a2017-05-18 13:53:58 +0200316 } catch (Exception e) {
317 common.warningMsg('running keystone.client state again')
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100318 salt.enforceState(pepperEnv, "I@keystone:client and ${control_general_target}*", 'keystone.client')
Jiri Broulik69de13a2017-05-18 13:53:58 +0200319 }
Jiri Broulik5f83c292017-05-18 12:09:07 +0200320 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100321 salt.enforceState(pepperEnv, "${control_general_target}*", 'glance')
Jiri Broulik5f83c292017-05-18 12:09:07 +0200322 } catch (Exception e) {
323 common.warningMsg('running glance state again')
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100324 salt.enforceState(pepperEnv, "${control_general_target}*", 'glance')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400325 } // salt 'ctl*' state.sls glusterfs.client
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100326 salt.enforceState(pepperEnv, "${control_general_target}*", 'glusterfs.client')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400327 // salt 'ctl*' state.sls keystone.server
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100328 salt.enforceState(pepperEnv, "${control_general_target}*", 'keystone.server')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400329 // salt 'ctl*' state.sls nova
Jiri Broulik5f83c292017-05-18 12:09:07 +0200330 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100331 salt.enforceState(pepperEnv, "${control_general_target}*", 'nova')
Jiri Broulik5f83c292017-05-18 12:09:07 +0200332 } catch (Exception e) {
333 common.warningMsg('running nova state again')
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100334 salt.enforceState(pepperEnv, "${control_general_target}*", 'nova')
Jiri Broulik5f83c292017-05-18 12:09:07 +0200335 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400336 // salt 'ctl*' state.sls cinder
Jiri Broulik80d96752017-05-22 19:42:01 +0200337 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100338 salt.enforceState(pepperEnv, "${control_general_target}*", 'cinder')
Jiri Broulikbda0a212017-05-18 12:54:51 +0200339 } catch (Exception e) {
340 common.warningMsg('running cinder state again')
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100341 salt.enforceState(pepperEnv, "${control_general_target}*", 'cinder')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400342 }
Jiri Broulik5f83c292017-05-18 12:09:07 +0200343 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100344 salt.enforceState(pepperEnv, "${control_general_target}*", 'neutron')
Jiri Broulik5f83c292017-05-18 12:09:07 +0200345 } catch (Exception e) {
346 common.warningMsg('running neutron state again')
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100347 salt.enforceState(pepperEnv, "${control_general_target}*", 'neutron')
Jiri Broulik5f83c292017-05-18 12:09:07 +0200348 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400349 // salt 'ctl*' state.sls heat
Jiri Broulikbda0a212017-05-18 12:54:51 +0200350 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100351 salt.enforceState(pepperEnv, "${control_general_target}*", 'heat')
Jiri Broulikbda0a212017-05-18 12:54:51 +0200352 } catch (Exception e) {
353 common.warningMsg('running heat state again')
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100354 salt.enforceState(pepperEnv, "${control_general_target}*", 'heat')
Jiri Broulik3792c962017-05-17 18:26:36 +0200355 }
356
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400357 } catch (Exception e) {
358 errorOccured = true
359 common.warningMsg('Some states that require syncdb failed. Restoring production databases')
Jiri Broulik3792c962017-05-17 18:26:36 +0200360
Jiri Broulik00d01092017-06-01 19:38:15 +0200361 // database restore section
362 try {
chnyda625f4b42017-10-11 14:10:31 +0200363 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400364 } catch (Exception er) {
Jiri Broulik00d01092017-06-01 19:38:15 +0200365 common.warningMsg('Mysql service already stopped')
Jiri Broulik3792c962017-05-17 18:26:36 +0200366 }
Jiri Broulik00d01092017-06-01 19:38:15 +0200367 try {
chnyda625f4b42017-10-11 14:10:31 +0200368 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400369 } catch (Exception er) {
Jiri Broulik00d01092017-06-01 19:38:15 +0200370 common.warningMsg('Mysql service already stopped')
371 }
372 try {
chnyda625f4b42017-10-11 14:10:31 +0200373 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400374 } catch (Exception er) {
Jiri Broulik00d01092017-06-01 19:38:15 +0200375 common.warningMsg('Files are not present')
376 }
377 try {
chnyda625f4b42017-10-11 14:10:31 +0200378 salt.cmdRun(pepperEnv, 'I@galera:master', "mkdir /root/mysql/mysql.bak")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400379 } catch (Exception er) {
380 common.warningMsg('Directory already exists')
381 }
382 try {
chnyda625f4b42017-10-11 14:10:31 +0200383 salt.cmdRun(pepperEnv, 'I@galera:master', "rm -rf /root/mysql/mysql.bak/*")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400384 } catch (Exception er) {
Jiri Broulik00d01092017-06-01 19:38:15 +0200385 common.warningMsg('Directory already empty')
386 }
387 try {
chnyda625f4b42017-10-11 14:10:31 +0200388 salt.cmdRun(pepperEnv, 'I@galera:master', "mv /var/lib/mysql/* /root/mysql/mysql.bak")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400389 } catch (Exception er) {
390 common.warningMsg('Files were already moved')
391 }
392 try {
chnyda625f4b42017-10-11 14:10:31 +0200393 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'file.remove', ["/var/lib/mysql/.galera_bootstrap"], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400394 } catch (Exception er) {
Jiri Broulik00d01092017-06-01 19:38:15 +0200395 common.warningMsg('File is not present')
396 }
chnyda625f4b42017-10-11 14:10:31 +0200397 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
398 _pillar = salt.getPillar(pepperEnv, "I@galera:master", 'xtrabackup:client:backup_dir')
Jiri Broulik00d01092017-06-01 19:38:15 +0200399 backup_dir = _pillar['return'][0].values()[0]
400 if(backup_dir == null || backup_dir.isEmpty()) { backup_dir='/var/backups/mysql/xtrabackup' }
401 print(backup_dir)
chnyda625f4b42017-10-11 14:10:31 +0200402 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'file.remove', ["${backup_dir}/dbrestored"], null, true)
403 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
404 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'], null, true)
Jiri Broulik8dabbfd2017-07-25 10:49:45 +0200405
406 // wait until mysql service on galera master is up
chnyda625f4b42017-10-11 14:10:31 +0200407 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
Jiri Broulik8dabbfd2017-07-25 10:49:45 +0200408
chnyda625f4b42017-10-11 14:10:31 +0200409 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'], null, true)
Jiri Broulik00d01092017-06-01 19:38:15 +0200410 //
Jiri Broulik3792c962017-05-17 18:26:36 +0200411
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400412 common.errorMsg("Stage Real control upgrade failed")
413 }
414 if(!errorOccured){
415
416 ceph = null
417
418 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100419 ceph = salt.cmdRun(pepperEnv, "${control_general_target}*", "salt-call grains.item roles | grep ceph.client")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400420
421 } catch (Exception er) {
422 common.infoMsg("Ceph is not used")
423 }
424
425 if(ceph != null) {
426 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100427 salt.enforceState(pepperEnv, "${control_general_target}*", 'ceph.client')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400428 } catch (Exception er) {
429 common.warningMsg("Ceph client state on controllers failed. Please fix it manually")
430 }
431 }
Jiri Broulik3792c962017-05-17 18:26:36 +0200432
433 // salt 'cmp*' cmd.run 'service nova-compute restart'
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100434 salt.runSaltProcessStep(pepperEnv, 'I@nova:compute', 'service.restart', ['nova-compute'], null, true)
435 salt.runSaltProcessStep(pepperEnv, "${control_general_target}*", 'service.restart', ['nova-conductor'], null, true)
436 salt.runSaltProcessStep(pepperEnv, "${control_general_target}*", 'service.restart', ['nova-scheduler'], null, true)
Jiri Broulikf20c7672017-06-19 21:20:52 +0200437
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400438
439 // salt 'prx*' state.sls linux,openssh,salt.minion,ntp,rsyslog
440 // salt 'ctl*' state.sls keepalived
441 // salt 'prx*' state.sls keepalived
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100442 salt.enforceState(pepperEnv, "${proxy_general_target}*", 'keepalived')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400443 // salt 'prx*' state.sls horizon
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100444 salt.enforceState(pepperEnv, "${proxy_general_target}*", 'horizon')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400445 // salt 'prx*' state.sls nginx
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100446 salt.enforceState(pepperEnv, "${proxy_general_target}*", 'nginx')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400447 // salt "prx*" state.sls memcached
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100448 salt.enforceState(pepperEnv, "${proxy_general_target}*", 'memcached')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400449
450 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100451 salt.enforceHighstate(pepperEnv, "${control_general_target}*")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400452 } catch (Exception er) {
453 common.errorMsg("Highstate was executed on controller nodes but something failed. Please check it and fix it accordingly.")
454 }
455
456 try {
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100457 salt.enforceHighstate(pepperEnv, "${proxy_general_target}*")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400458 } catch (Exception er) {
459 common.errorMsg("Highstate was executed on proxy nodes but something failed. Please check it and fix it accordingly.")
460 }
461
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100462 salt.cmdRun(pepperEnv, "${control_general_target}01*", '. /root/keystonercv3; openstack service list; openstack image list; openstack flavor list; openstack compute service list; openstack server list; openstack network list; openstack volume list; openstack orchestration service list')
Jiri Broulik3792c962017-05-17 18:26:36 +0200463 }
Jiri Broulik6fc9d3f2017-05-12 07:11:29 +0200464 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400465
466 if (STAGE_REAL_UPGRADE.toBoolean() == true && STAGE_ROLLBACK_UPGRADE.toBoolean() == true) {
467 stage('Ask for manual confirmation') {
468 input message: "Please verify if the control upgrade was successful. If it did not succeed, in the worst scenario, you can click YES to continue with control-upgrade-rollback. Do you want to continue with the rollback?"
469 }
470 }
471 }
472
473 if (STAGE_ROLLBACK_UPGRADE.toBoolean() == true) {
474 stage('Rollback upgrade') {
475
476 stage('Ask for manual confirmation') {
477 input message: "Do you really want to continue with the rollback?"
478 }
479
chnyda625f4b42017-10-11 14:10:31 +0200480 _pillar = salt.getGrain(pepperEnv, 'I@salt:master', 'domain')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400481 domain = _pillar['return'][0].values()[0].values()[0]
482 print(_pillar)
483 print(domain)
484
chnyda625f4b42017-10-11 14:10:31 +0200485 _pillar = salt.getGrain(pepperEnv, 'I@salt:control', 'id')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400486 kvm01 = _pillar['return'][0].values()[0].values()[0]
487 print(_pillar)
488 print(kvm01)
489
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100490 def proxy_general_target = ""
491 def proxy_target_hosts = salt.getMinions(pepperEnv, 'I@horizon:server')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400492
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100493 for (t in proxy_target_hosts) {
494 def target = t.split("\\.")[0]
Jiri Broulik42dfbb12017-11-13 11:27:45 +0100495 proxy_general_target = target.replaceAll('\\d+$', "")
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100496 _pillar = salt.getPillar(pepperEnv, "${kvm01}", "salt:control:cluster:internal:node:${target}:provider")
497 def nodeProvider = _pillar['return'][0].values()[0]
498 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'virt.destroy', ["${target}.${domain}"], null, true)
499 sleep(2)
500 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'file.copy', ["/root/${target}.${domain}.qcow2.bak", "/var/lib/libvirt/images/${target}.${domain}/system.qcow2"], null, true)
501 try {
502 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
503 } catch (Exception e) {
504 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
505 }
506 }
507 def control_general_target = ""
508 def control_target_hosts = salt.getMinions(pepperEnv, 'I@keystone:server')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400509
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100510 for (t in control_target_hosts) {
511 def target = t.split("\\.")[0]
Jiri Broulik42dfbb12017-11-13 11:27:45 +0100512 control_general_target = target.replaceAll('\\d+$', "")
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100513 _pillar = salt.getPillar(pepperEnv, "${kvm01}", "salt:control:cluster:internal:node:${target}:provider")
514 def nodeProvider = _pillar['return'][0].values()[0]
515 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'virt.destroy', ["${target}.${domain}"], null, true)
516 sleep(2)
517 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'file.copy', ["/root/${target}.${domain}.qcow2.bak", "/var/lib/libvirt/images/${target}.${domain}/system.qcow2"], null, true)
518 try {
519 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
520 } catch (Exception e) {
521 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
522 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400523 }
524
525 // database restore section
526 try {
chnyda625f4b42017-10-11 14:10:31 +0200527 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400528 } catch (Exception e) {
529 common.warningMsg('Mysql service already stopped')
530 }
531 try {
chnyda625f4b42017-10-11 14:10:31 +0200532 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400533 } catch (Exception e) {
534 common.warningMsg('Mysql service already stopped')
535 }
536 try {
chnyda625f4b42017-10-11 14:10:31 +0200537 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400538 } catch (Exception e) {
539 common.warningMsg('Files are not present')
540 }
541 try {
chnyda625f4b42017-10-11 14:10:31 +0200542 salt.cmdRun(pepperEnv, 'I@galera:master', "rm -rf /var/lib/mysql/*")
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400543 } catch (Exception e) {
544 common.warningMsg('Directory already empty')
545 }
546 try {
chnyda625f4b42017-10-11 14:10:31 +0200547 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'file.remove', ["/var/lib/mysql/.galera_bootstrap"], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400548 } catch (Exception e) {
549 common.warningMsg('File is not present')
550 }
chnyda625f4b42017-10-11 14:10:31 +0200551 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
552 _pillar = salt.getPillar(pepperEnv, "I@galera:master", 'xtrabackup:client:backup_dir')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400553 backup_dir = _pillar['return'][0].values()[0]
554 if(backup_dir == null || backup_dir.isEmpty()) { backup_dir='/var/backups/mysql/xtrabackup' }
555 print(backup_dir)
chnyda625f4b42017-10-11 14:10:31 +0200556 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'file.remove', ["${backup_dir}/dbrestored"], null, true)
557 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
558 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400559
560 // wait until mysql service on galera master is up
chnyda625f4b42017-10-11 14:10:31 +0200561 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400562
chnyda625f4b42017-10-11 14:10:31 +0200563 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400564 //
565
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100566 for (t in control_target_hosts) {
567 def target = t.split("\\.")[0]
568 _pillar = salt.getPillar(pepperEnv, "${kvm01}", "salt:control:cluster:internal:node:${target}:provider")
569 def nodeProvider = _pillar['return'][0].values()[0]
570 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'virt.start', ["${target}.${domain}"], null, true)
571 }
572 for (t in proxy_target_hosts) {
573 def target = t.split("\\.")[0]
574 _pillar = salt.getPillar(pepperEnv, "${kvm01}", "salt:control:cluster:internal:node:${target}:provider")
575 def nodeProvider = _pillar['return'][0].values()[0]
576 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}", 'virt.start', ["${target}.${domain}"], null, true)
577 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400578
579 // salt 'cmp*' cmd.run 'service nova-compute restart'
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100580 salt.runSaltProcessStep(pepperEnv, 'I@nova:compute', 'service.restart', ['nova-compute'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400581
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100582 for (t in control_target_hosts) {
583 def target = t.split("\\.")[0]
584 salt.minionPresent(pepperEnv, 'I@salt:master', "${target}")
585 }
586 for (t in proxy_target_hosts) {
587 def target = t.split("\\.")[0]
588 salt.minionPresent(pepperEnv, 'I@salt:master', "${target}")
589 }
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400590
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100591 salt.runSaltProcessStep(pepperEnv, "${control_general_target}*", 'service.restart', ['nova-conductor'], null, true)
592 salt.runSaltProcessStep(pepperEnv, "${control_general_target}*", 'service.restart', ['nova-scheduler'], null, true)
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400593
Jiri Broulik3f5ed1a2017-11-10 17:35:52 +0100594 salt.cmdRun(pepperEnv, "${control_general_target}01*", '. /root/keystonerc; nova service-list; glance image-list; nova flavor-list; nova hypervisor-list; nova list; neutron net-list; cinder list; heat service-list')
Ruslan Kamaldinov6feef402017-08-02 16:55:58 +0400595 }
Jiri Broulikbb447ac2017-05-04 15:36:22 +0200596 }
597}