blob: 8c8b8b60d95d5f0baaea665d0c19a973a62a2065 [file] [log] [blame]
Jiri Broulik60dcab32018-03-08 17:42:06 +01001/**
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 [https://10.10.10.1:8000].
7 * SNAPSHOT_NAME Snapshot name
8 * CFG_NODE_PROVIDER Physical machine name hosting Salt-Master VM (ex. kvm01*)
9 * INTERACTIVE Ask interactive questions during pipeline run (bool)
10 * PER_NODE Target nodes will be managed one by one (bool)
11 * ROLLBACK_BY_REDEPLOY Omit taking live snapshots. Rollback is planned to be done by redeployment (bool)
12 * STOP_SERVICES Stop API services before update (bool)
Jiri Broulikba6d85d2018-04-05 13:29:07 +020013 * TARGET_KERNEL_UPDATES Comma separated list of nodes to update kernel if newer version is available (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
14 * TARGET_REBOOT Comma separated list of nodes to reboot after update or physical machine rollback (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
15 * TARGET_HIGHSTATE Comma separated list of nodes to run Salt Highstate on after update or physical machine rollback (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
Jiri Broulik60dcab32018-03-08 17:42:06 +010016 * TARGET_UPDATES Comma separated list of nodes to update (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid,cmp,kvm,osd,gtw-physical)
Jiri Broulik906e9972018-03-26 16:12:00 +020017 * TARGET_ROLLBACKS Comma separated list of nodes to rollback (Valid values are ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cmp,kvm,osd,gtw-physical)
Jiri Broulik5dac8d82018-03-29 13:34:39 +020018 * TARGET_SNAPSHOT_MERGES Comma separated list of nodes to merge live snapshot for (Valid values are cfg,ctl,prx,msg,dbs,log,mon,mtr,ntw,nal,gtw-virtual,cmn,rgw,cid)
Jiri Broulik60dcab32018-03-08 17:42:06 +010019 * CTL_TARGET Salt targeted CTL nodes (ex. ctl*)
20 * PRX_TARGET Salt targeted PRX nodes (ex. prx*)
21 * MSG_TARGET Salt targeted MSG nodes (ex. msg*)
22 * DBS_TARGET Salt targeted DBS nodes (ex. dbs*)
23 * LOG_TARGET Salt targeted LOG nodes (ex. log*)
24 * MON_TARGET Salt targeted MON nodes (ex. mon*)
25 * MTR_TARGET Salt targeted MTR nodes (ex. mtr*)
26 * NTW_TARGET Salt targeted NTW nodes (ex. ntw*)
27 * NAL_TARGET Salt targeted NAL nodes (ex. nal*)
28 * CMN_TARGET Salt targeted CMN nodes (ex. cmn*)
29 * RGW_TARGET Salt targeted RGW nodes (ex. rgw*)
30 * CID_TARGET Salt targeted CID nodes (ex. cid*)
31 * CMP_TARGET Salt targeted physical compute nodes (ex. cmp001*)
32 * KVM_TARGET Salt targeted physical KVM nodes (ex. kvm01*)
33 * CEPH_OSD_TARGET Salt targeted physical Ceph OSD nodes (ex. osd001*)
Jiri Broulik906e9972018-03-26 16:12:00 +020034 * GTW_TARGET Salt targeted physical or virtual GTW nodes (ex. gtw01*)
Jiri Broulik906e9972018-03-26 16:12:00 +020035 * ROLLBACK_PKG_VERSIONS Space separated list of pkgs=versions to rollback to on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
36 * PURGE_PKGS Space separated list of pkgs=versions to be purged on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
37 * REMOVE_PKGS Space separated list of pkgs=versions to be removed on physical targeted machines (ex. pkg_name1=pkg_version1 pkg_name2=pkg_version2)
Jiri Broulik60dcab32018-03-08 17:42:06 +010038 * RESTORE_GALERA Restore Galera DB (bool)
39 * RESTORE_CONTRAIL_DB Restore Cassandra and Zookeeper DBs for OpenContrail (bool)
40 *
41**/
42def common = new com.mirantis.mk.Common()
43def salt = new com.mirantis.mk.Salt()
44def python = new com.mirantis.mk.Python()
45def virsh = new com.mirantis.mk.Virsh()
46
47def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
48def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()}
Jiri Broulik5dac8d82018-03-29 13:34:39 +020049def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()}
Jiri Broulik7ba05e42018-04-06 11:39:25 +020050def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
Jiri Broulik60dcab32018-03-08 17:42:06 +010051
52def pepperEnv = "pepperEnv"
53def minions
54def result
55def packages
56def command
57def commandKwargs
58
59def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
60 def salt = new com.mirantis.mk.Salt()
61 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020062 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
63 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010064 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010065 def pkgs
66 def out
67
68 salt.enforceState(pepperEnv, target, 'linux.system.repo')
69
70 stage("List package upgrades") {
71 common.infoMsg("Listing all the packages that have a new update available on ${target}")
Jiri Broulikba6d85d2018-04-05 13:29:07 +020072 if (kernelUpdates.contains(targetType)) {
73 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
74 } else {
75 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true))
76 }
Jiri Broulik60dcab32018-03-08 17:42:06 +010077 if(targetPackages != "" && targetPackages != "*"){
78 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
79 }
80 }
81
82 if (INTERACTIVE.toBoolean()) {
83 stage("Confirm live package upgrades on ${target}") {
84 if (targetPackages=="") {
85 def userInput = input(
86 id: 'userInput', message: 'Insert package names for update', parameters: [
87 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
88 ])
89 if (userInput!= "" && userInput!= "*") {
90 targetPackages = userInput
91 }
92 } else {
93 input message: "Approve live package upgrades on ${target} nodes?"
94 }
95 }
96 } else {
97 targetPackages = pkgs.keySet().join(",").toString()
98 }
99
100 if (targetPackages != "") {
101 // list installed versions of pkgs that will be upgraded
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200102 if (targetType == 'kvm' || targetType == 'cmp' || targetType == 'osd' || targetType == 'gtw-physical') {
103 def installedPkgs = []
104 def newPkgs = []
105 def targetPkgList = targetPackages.tokenize(',')
106 for (pkg in targetPkgList) {
107 def version
108 try {
109 def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true))
110 version = pkgsDetails.get(pkg).get('version')
111 } catch (Exception er) {
112 common.infoMsg("${pkg} not installed yet")
113 }
114 if (version?.trim()) {
115 installedPkgs.add(pkg + '=' + version)
116 } else {
117 newPkgs.add(pkg)
118 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100119 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200120 common.warningMsg("the following list of pkgs will be upgraded")
121 common.warningMsg(installedPkgs.join(" "))
122 common.warningMsg("the following list of pkgs will be newly installed")
123 common.warningMsg(newPkgs.join(" "))
Jiri Broulik60dcab32018-03-08 17:42:06 +0100124 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100125 // set variables
126 command = "pkg.install"
127 packages = targetPackages
128 commandKwargs = ['only_upgrade': 'true','force_yes': 'true']
129
130 }else {
131 command = "pkg.upgrade"
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200132 if (kernelUpdates.contains(targetType)) {
133 commandKwargs = ['dist_upgrade': 'true']
134 distUpgrade = true
135 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100136 packages = null
137 }
138
Jiri Broulik60dcab32018-03-08 17:42:06 +0100139 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200140 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
141 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200142 contrailServices(pepperEnv, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100143 } else {
144 def probe = salt.getFirstMinion(pepperEnv, "${target}")
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200145 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100146 }
147 }
148 }
149
150 stage('Apply package upgrades') {
151 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200152 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100153 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
154 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5)
155 salt.minionsReachable(pepperEnv, 'I@salt:master', '*')
156 }
157 // salt minion pkg
158 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5)
159 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
160 common.infoMsg('Performing pkg upgrades ... ')
161 common.retry(3){
162 out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs)
163 salt.printSaltCommandResult(out)
164 }
165 def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename')
166 if (osRelease.toString().toLowerCase().contains('trusty')) {
167 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
168 } else {
169 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
170 }
171 if (out.toString().contains('errors:')) {
172 try {
173 if (packages?.trim()) {
174 packages = packages.replaceAll(',', ' ')
175 common.retry(3){
176 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
177 }
178 } else {
179 if (distUpgrade) {
180 common.retry(3){
181 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
182 }
183 } else {
184 common.retry(3){
185 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
186 }
187 } }
188 if (out.toString().contains('E: ')) {
189 common.errorMsg(out)
190 if (INTERACTIVE.toBoolean()) {
191 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
192 } else {
193 salt.printSaltCommandResult(out)
194 throw new Exception("Pkgs update failed")
195 }
196 }
197 } catch (Exception e) {
198 common.errorMsg(out)
199 common.errorMsg(e)
200 if (INTERACTIVE.toBoolean()) {
201 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
202 } else {
203 throw new Exception("Pkgs update failed")
204 }
205 }
206 }
207 }
208}
209
210def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") {
211 def salt = new com.mirantis.mk.Salt()
212 def common = new com.mirantis.mk.Common()
213 def probe = salt.getFirstMinion(pepperEnv, "${target}")
214 def distUpgrade
215 def pkgs
216 def out
217
218 salt.enforceState(pepperEnv, target, 'linux.system.repo')
219
220 if (ROLLBACK_PKG_VERSIONS == "") {
221 stage("List package upgrades") {
222 common.infoMsg("Listing all the packages that have a new update available on ${target}")
223 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
224 if(targetPackages != "" && targetPackages != "*"){
225 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
226 }
227 }
228
229 if (INTERACTIVE.toBoolean()) {
230 stage("Confirm live package upgrades on ${target}") {
231 if(targetPackages==""){
232 timeout(time: 2, unit: 'HOURS') {
233 def userInput = input(
234 id: 'userInput', message: 'Insert package names for update', parameters: [
235 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
236 ])
237 if(userInput!= "" && userInput!= "*"){
238 targetPackages = userInput
239 }
240 }
241 }else{
242 timeout(time: 2, unit: 'HOURS') {
243 input message: "Approve live package upgrades on ${target} nodes?"
244 }
245 }
246 }
247 } else {
248 targetPackages = pkgs.keySet().join(",").toString()
249 }
250 } else {
251 targetPackages = ROLLBACK_PKG_VERSIONS
252 }
253
254 if (targetPackages != "") {
255 // set variables
256 packages = targetPackages
257 } else {
258 distUpgrade = true
259 packages = null
260 }
261
262 stage("stop services on ${target}") {
263 try {
264 if (INTERACTIVE.toBoolean()) {
265 input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue."
266 }
267 } catch (Exception er) {
268 common.infoMsg('skipping stopping services')
269 return
270 }
271 if (STOP_SERVICES.toBoolean()) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200272 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100273 }
274 }
275
276 stage('Apply package downgrades') {
277 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
278 common.infoMsg('Performing pkgs purge/remove ... ')
279 try {
280 if (PURGE_PKGS != "") {
281 def purgePackages = PURGE_PKGS.replaceAll(',', ' ')
282 common.retry(3){
283 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages])
284 }
285 }
286 if (REMOVE_PKGS != "") {
287 def removePackages = REMOVE_PKGS.replaceAll(',', ' ')
288 common.retry(3){
289 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages])
290 }
291 }
292 if (out.toString().contains('E: ')) {
293 common.errorMsg(out)
294 if (INTERACTIVE.toBoolean()) {
295 input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually."
296 } else {
297 salt.printSaltCommandResult(out)
298 throw new Exception("Pkgs {packages} purge failed")
299 }
300 }
301 } catch (Exception e) {
302 common.errorMsg(out)
303 common.errorMsg(e)
304 if (INTERACTIVE.toBoolean()) {
305 input message: "Pkgs {packages} purge on ${target}. Please fix it manually."
306 } else {
307 throw new Exception("Pkgs {packages} purge failed")
308 }
309 }
310
311 common.infoMsg('Performing pkg downgrades ... ')
312 try {
313 packages = packages.replaceAll(',', ' ')
314 if (packages?.trim()) {
315 packages = packages.replaceAll(',', ' ')
316 common.retry(3){
317 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5)
318 }
319 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
320 common.retry(3){
321 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
322 }
323 } else {
324 if (distUpgrade) {
325 common.retry(3){
326 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
327 }
328 } else {
329 common.retry(3){
330 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
331 }
332 }
333 }
334 if (out.toString().contains('E: ')) {
335 common.errorMsg(out)
336 if (INTERACTIVE.toBoolean()) {
337 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
338 } else {
339 salt.printSaltCommandResult(out)
340 throw new Exception("Pkgs rollback failed")
341 }
342 }
343 } catch (Exception e) {
344 common.errorMsg(out)
345 common.errorMsg(e)
346 if (INTERACTIVE.toBoolean()) {
347 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
348 } else {
349 throw new Exception("Pkgs rollback failed")
350 }
351 }
352 }
353}
354
Jiri Broulik827d0112018-04-25 16:00:07 +0200355def getNodeProvider(pepperEnv, nodeName, type='') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100356 def salt = new com.mirantis.mk.Salt()
357 def common = new com.mirantis.mk.Common()
Jiri Broulik827d0112018-04-25 16:00:07 +0200358 def kvms = salt.getMinions(pepperEnv, 'I@salt:control')
359 for (kvm in kvms) {
360 try {
361 vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true))
362 if (vms.toString().contains(nodeName)) {
363 if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100364 CFG_NODE_PROVIDER = kvm
Jiri Broulik827d0112018-04-25 16:00:07 +0200365 } else {
366 return kvm
Jiri Broulik60dcab32018-03-08 17:42:06 +0100367 //break
368 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100369 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100370 } catch (Exception er) {
Jiri Broulik827d0112018-04-25 16:00:07 +0200371 common.infoMsg("${nodeName} not present on ${kvm}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100372 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100373 }
374}
375
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200376def services(pepperEnv, probe, target, action='stop') {
377 def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"]
378 if (action == 'stop') {
379 def openstack = new com.mirantis.mk.Openstack()
380 openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean())
Jiri Broulik60dcab32018-03-08 17:42:06 +0100381 } else {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200382 def salt = new com.mirantis.mk.Salt()
383 for (s in services) {
384 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, "${probe}*", "service --status-all | grep ${s} | awk \'{print \$4}\'"))
385 def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item
386 if (servicesList) {
387 for (name in servicesList) {
388 if (!name.contains('Salt command')) {
389 salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"])
390 }
391 }
392 }
393 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100394 }
395}
396
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200397// must be treated separately due to OC on Trusty
398def contrailServices(pepperEnv, target, action='stop') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100399 def salt = new com.mirantis.mk.Salt()
400 def common = new com.mirantis.mk.Common()
401 def services = []
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200402 if (action == 'stop') {
403 services.add('supervisor-control')
404 services.add('supervisor-config')
405 services.add('supervisor-database')
406 services.add('zookeeper')
407 services.add('ifmap-server')
408 services.add('haproxy')
409 services.add('keepalived')
410 } else {
411 services.add('keepalived')
412 services.add('haproxy')
413 services.add('ifmap-server')
414 services.add('zookeeper')
415 services.add('supervisor-database')
416 services.add('supervisor-config')
417 services.add('supervisor-control')
418 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100419 for (s in services) {
420 try {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200421 salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100422 } catch (Exception er) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200423 common.warningMsg(er)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100424 }
425 }
426}
427
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200428def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100429 def salt = new com.mirantis.mk.Salt()
430 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200431 def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()}
432 def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
433 // optionally run highstate
434 if (highstates.contains(type)) {
435 stage("Apply highstate on ${target} nodes") {
436 try {
437 common.retry(3){
438 salt.enforceHighstate(pepperEnv, target)
439 }
440 } catch (Exception e) {
441 common.errorMsg(e)
442 if (INTERACTIVE.toBoolean()) {
443 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
444 } else {
445 throw new Exception("highstate failed")
446 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100447 }
448 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200449 } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') {
450 if (type == 'ntw' || type == 'nal') {
451 contrailServices(pepperEnv, target, 'start')
452 } else {
453 def probe = salt.getFirstMinion(pepperEnv, "${target}")
454 services(pepperEnv, probe, target, 'start')
455 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100456 }
457 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200458 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100459 stage("Reboot ${target} nodes") {
460 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
461 sleep(10)
462 salt.minionsReachable(pepperEnv, 'I@salt:master', target)
463 }
464 }
465}
466
467def rollback(pepperEnv, tgt, generalTarget) {
468 def common = new com.mirantis.mk.Common()
469 try {
470 if (INTERACTIVE.toBoolean()) {
471 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
472 }
473 } catch (Exception er) {
474 common.infoMsg('skipping rollback')
475 return
476 }
477 try {
478 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
479 } catch (Exception err) {
480 common.errorMsg(err)
481 if (INTERACTIVE.toBoolean()) {
482 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
483 } else {
484 throw new Exception("Rollback failed for ${tgt}")
485 }
486 }
487}
488
489def liveSnapshot(pepperEnv, tgt, generalTarget) {
490 def salt = new com.mirantis.mk.Salt()
491 def common = new com.mirantis.mk.Common()
492 def virsh = new com.mirantis.mk.Virsh()
493 def domain = salt.getDomainName(pepperEnv)
494 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
495 common.warningMsg(target_hosts)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100496 for (t in target_hosts) {
497 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200498 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100499 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100500 }
501}
502
503def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
504 def salt = new com.mirantis.mk.Salt()
505 def virsh = new com.mirantis.mk.Virsh()
506 def domain = salt.getDomainName(pepperEnv)
507 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100508 for (t in target_hosts) {
509 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200510 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200511 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100512 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
513 } else {
514 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200515 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100516 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
517 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100518 }
Jiri Broulik906e9972018-03-26 16:12:00 +0200519 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100520}
521
522
523
524def rollbackLiveSnapshot(pepperEnv, tgt, generalTarget) {
525 def salt = new com.mirantis.mk.Salt()
526 def virsh = new com.mirantis.mk.Virsh()
527 def common = new com.mirantis.mk.Common()
528 def domain = salt.getDomainName(pepperEnv)
529 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
530 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100531 for (t in target_hosts) {
532 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200533 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100534 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100535 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100536 // rollback vms
537 for (t in target_hosts) {
538 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200539 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100540 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100541 }
542 try {
543 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
544 // purge and setup previous repos
545 salt.enforceState(pepperEnv, tgt, 'linux.system.repo')
546 } catch (Exception e) {
547 common.errorMsg(e)
548 if (INTERACTIVE.toBoolean()) {
549 input message: "Salt state linux.system.repo on ${tgt} failed. Do you want to PROCEED?."
550 } else {
551 throw new Exception("Salt state linux.system.repo on ${tgt} failed")
552 }
553 }
554}
555
556def removeNode(pepperEnv, tgt, generalTarget) {
557 def salt = new com.mirantis.mk.Salt()
558 def virsh = new com.mirantis.mk.Virsh()
559 def common = new com.mirantis.mk.Common()
560 def domain = salt.getDomainName(pepperEnv)
561 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
562 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100563 for (t in target_hosts) {
564 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200565 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100566 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200567 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100568 try {
569 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
570 } catch (Exception e) {
571 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
572 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100573 }
574}
575
Jiri Broulik906e9972018-03-26 16:12:00 +0200576def saltMasterBackup(pepperEnv) {
577 def salt = new com.mirantis.mk.Salt()
578 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
579 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
580}
581
Jiri Broulik60dcab32018-03-08 17:42:06 +0100582def backupCeph(pepperEnv, tgt) {
583 def salt = new com.mirantis.mk.Salt()
584 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
585 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
586 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
587}
588
589def backupGalera(pepperEnv) {
590 def salt = new com.mirantis.mk.Salt()
591 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
592 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
593 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
594 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
595}
596
597// cluster galera - wsrep_cluster_size
598def clusterGalera(pepperEnv) {
599 def salt = new com.mirantis.mk.Salt()
600 def common = new com.mirantis.mk.Common()
601 try {
602 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
603 } catch (Exception er) {
604 common.warningMsg('Mysql service already stopped')
605 }
606 try {
607 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
608 } catch (Exception er) {
609 common.warningMsg('Mysql service already stopped')
610 }
611 try {
612 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
613 } catch (Exception er) {
614 common.warningMsg('Files are not present')
615 }
616 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
617 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
618 // wait until mysql service on galera master is up
619 try {
620 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
621 } catch (Exception er) {
622 if (INTERACTIVE.toBoolean()) {
623 input message: "Database is not running please fix it first and only then click on PROCEED."
624 } else {
625 throw new Exception("Database is not running correctly")
626 }
627 }
628 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
629}
630
631def restoreGalera(pepperEnv) {
632 def salt = new com.mirantis.mk.Salt()
633 def common = new com.mirantis.mk.Common()
634 def openstack = new com.mirantis.mk.Openstack()
635 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
636 openstack.restoreGaleraDb(pepperEnv)
637}
638
639def backupZookeeper(pepperEnv) {
640 def salt = new com.mirantis.mk.Salt()
641 def common = new com.mirantis.mk.Common()
642 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
643 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
644 try {
645 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
646 } catch (Exception er) {
647 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
648 }
649}
650
651def backupCassandra(pepperEnv) {
652 def salt = new com.mirantis.mk.Salt()
653 def common = new com.mirantis.mk.Common()
654
655 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
656 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
657 try {
658 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
659 } catch (Exception er) {
660 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
661 }
662}
663
664def backupContrail(pepperEnv) {
665 backupZookeeper(pepperEnv)
666 backupCassandra(pepperEnv)
667}
668
669// cassandra and zookeeper
670def restoreContrailDb(pepperEnv) {
671 def salt = new com.mirantis.mk.Salt()
672 def common = new com.mirantis.mk.Common()
673 build job: "deploy-zookeeper-restore", parameters: [
674 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
675 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
676 ]
677 build job: "deploy-cassandra-db-restore", parameters: [
678 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
679 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
680 ]
681}
682
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200683def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100684 def salt = new com.mirantis.mk.Salt()
685 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200686 def out = salt.cmdRun(pepperEnv, target, '. /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')
687 if (out.toString().toLowerCase().contains('error')) {
688 common.errorMsg(out)
689 if (INTERACTIVE.toBoolean()) {
690 input message: "APIs are not working as expected. Please fix it manually."
691 } else {
692 throw new Exception("APIs are not working as expected")
693 }
694 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100695}
696
Jiri Broulikad606d02018-03-28 14:22:43 +0200697def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100698 def salt = new com.mirantis.mk.Salt()
699 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200700 def out
701 while(count < maxRetries) {
702 try {
703 out = salt.getReturnValues(salt.cmdRun(pepperEnv, target, 'salt-call mysql.status | grep -A1 wsrep_cluster_size'))
704 } catch (Exception er) {
705 common.infoMsg(er)
706 }
707 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
708 count++
709 if (count == maxRetries) {
710 if (INTERACTIVE.toBoolean()) {
711 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
712 } else {
713 common.errorMsg(out)
714 throw new Exception("Galera is not working as expected")
715 }
716 }
717 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100718 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200719 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100720 }
721 }
722}
723
724def verifyContrail(pepperEnv, target) {
725 def salt = new com.mirantis.mk.Salt()
726 def common = new com.mirantis.mk.Common()
727 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
728}
729
730
731def verifyService(pepperEnv, target, service) {
732 def salt = new com.mirantis.mk.Salt()
733 def common = new com.mirantis.mk.Common()
734 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
735 for (t in targetHosts) {
736 try {
737 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
738 } catch (Exception er) {
739 common.errorMsg(er)
740 if (INTERACTIVE.toBoolean()) {
741 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
742 } else {
743 throw new Exception("${service} service is not running correctly on ${t}")
744 }
745 }
746 }
747}
748
749def verifyCeph(pepperEnv, target, type) {
750 def salt = new com.mirantis.mk.Salt()
751 def common = new com.mirantis.mk.Common()
752 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
753 for (t in targetHosts) {
754 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
755 try {
756 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
757 } catch (Exception er) {
758 common.errorMsg(er)
759 if (INTERACTIVE.toBoolean()) {
760 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
761 } else {
762 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
763 }
764 }
765 }
766}
767
768def verifyCephOsds(pepperEnv, target) {
769 def salt = new com.mirantis.mk.Salt()
770 def common = new com.mirantis.mk.Common()
771 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
772 for (t in targetHosts) {
773 def osd_ids = []
774 // get list of osd disks of the host
775 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
776 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
777 if(cephGrain['return'].isEmpty()){
778 throw new Exception("Ceph salt grain cannot be found!")
779 }
780 common.print(cephGrain)
781 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
782 for (i in ceph_disks) {
783 def osd_id = i.getKey().toString()
784 osd_ids.add('osd.' + osd_id)
785 print("Will check osd." + osd_id)
786 }
787 for (i in osd_ids) {
788 try {
789 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
790 } catch (Exception er) {
791 common.errorMsg(er)
792 if (INTERACTIVE.toBoolean()) {
793 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
794 } else {
795 throw new Exception("Ceph ${i} is not running correctly on ${t}")
796 }
797 }
798 }
799 }
800}
801
802
803timeout(time: 12, unit: 'HOURS') {
804 node() {
805 try {
806
807 stage('Setup virtualenv for Pepper') {
808 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
809 }
810
811 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
812
813 /*
814 * Update section
815 */
816 if (updates.contains("cfg")) {
817 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200818 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100819 if (salt.testTarget(pepperEnv, target)) {
820 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200821 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100822 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
823 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200824 } else {
825 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100826 }
827 if (PER_NODE.toBoolean()) {
828 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
829 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200830 updatePkgs(pepperEnv, t, type)
831 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100832 }
833 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200834 updatePkgs(pepperEnv, target, type)
835 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100836 }
837 }
838 }
839
840 if (updates.contains("ctl")) {
841 def target = CTL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200842 def type = 'ctl'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100843 if (salt.testTarget(pepperEnv, target)) {
844 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200845 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100846 }
847 if (PER_NODE.toBoolean()) {
848 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
849 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200850 updatePkgs(pepperEnv, t, type)
851 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100852 }
853 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200854 updatePkgs(pepperEnv, target, type)
855 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100856 }
857 verifyAPIs(pepperEnv, target)
858 }
859 }
860
861 if (updates.contains("prx")) {
862 def target = PRX_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200863 def type = 'prx'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100864 if (salt.testTarget(pepperEnv, target)) {
865 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200866 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100867 }
868 if (PER_NODE.toBoolean()) {
869 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
870 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200871 updatePkgs(pepperEnv, t, type)
872 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100873 }
874 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200875 updatePkgs(pepperEnv, target, type)
876 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100877 }
878 verifyService(pepperEnv, target, 'nginx')
879 }
880 }
881
882 if (updates.contains("msg")) {
883 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200884 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100885 if (salt.testTarget(pepperEnv, target)) {
886 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200887 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100888 }
889 if (PER_NODE.toBoolean()) {
890 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
891 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200892 updatePkgs(pepperEnv, t, type)
893 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100894 }
895 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200896 updatePkgs(pepperEnv, target, type)
897 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100898 }
899 verifyService(pepperEnv, target, 'rabbitmq-server')
900 }
901 }
902
903 if (updates.contains("dbs")) {
904 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200905 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100906 if (salt.testTarget(pepperEnv, target)) {
907 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100908 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200909 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100910 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200911 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100912 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100913 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200914 updatePkgs(pepperEnv, t, type)
915 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200916 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100917 }
918 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200919 updatePkgs(pepperEnv, target, type)
920 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200921 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100922 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100923 }
924 }
925
926 if (updates.contains("ntw")) {
927 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200928 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100929 if (salt.testTarget(pepperEnv, target)) {
930 backupContrail(pepperEnv)
931 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200932 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100933 }
934 if (PER_NODE.toBoolean()) {
935 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
936 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200937 updatePkgs(pepperEnv, t, type)
938 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100939 verifyContrail(pepperEnv, t)
940 }
941 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200942 updatePkgs(pepperEnv, target, type)
943 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100944 verifyContrail(pepperEnv, target)
945 }
946 }
947 }
948
949 if (updates.contains("nal")) {
950 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200951 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100952 if (salt.testTarget(pepperEnv, target)) {
953 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200954 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100955 }
956 if (PER_NODE.toBoolean()) {
957 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
958 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200959 updatePkgs(pepperEnv, t, type)
960 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100961 }
962 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200963 updatePkgs(pepperEnv, target, type)
964 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100965 }
966 verifyContrail(pepperEnv, target)
967 }
968 }
969
970 if (updates.contains("gtw-virtual")) {
971 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200972 def type = 'gtw-virtual'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100973 if (salt.testTarget(pepperEnv, target)) {
974 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200975 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100976 }
977 if (PER_NODE.toBoolean()) {
978 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
979 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200980 updatePkgs(pepperEnv, t, type)
981 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100982 }
983 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200984 updatePkgs(pepperEnv, target, type)
985 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100986 }
987 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
988 }
989 }
990
991 if (updates.contains("cmn")) {
992 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200993 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100994 if (salt.testTarget(pepperEnv, target)) {
995 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200996 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100997 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +0200998 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100999 }
1000 if (PER_NODE.toBoolean()) {
1001 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1002 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001003 updatePkgs(pepperEnv, t, type)
1004 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001005 }
1006 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001007 updatePkgs(pepperEnv, target, type)
1008 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001009 }
1010 verifyCeph(pepperEnv, target, 'mon@')
1011 }
1012 }
1013
1014 if (updates.contains("rgw")) {
1015 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001016 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001017 if (salt.testTarget(pepperEnv, target)) {
1018 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001019 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001020 }
1021 if (PER_NODE.toBoolean()) {
1022 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1023 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001024 updatePkgs(pepperEnv, t, type)
1025 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001026 }
1027 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001028 updatePkgs(pepperEnv, target, type)
1029 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001030 }
1031 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1032 }
1033 }
1034
1035 if (updates.contains("log")) {
1036 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001037 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001038 if (salt.testTarget(pepperEnv, target)) {
1039 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001040 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001041 }
1042 if (PER_NODE.toBoolean()) {
1043 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1044 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001045 updatePkgs(pepperEnv, t, type)
1046 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001047 }
1048 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001049 updatePkgs(pepperEnv, target, type)
1050 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001051 }
1052 }
1053 }
1054
1055 if (updates.contains("mon")) {
1056 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001057 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001058 if (salt.testTarget(pepperEnv, target)) {
1059 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001060 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001061 }
1062 if (PER_NODE.toBoolean()) {
1063 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1064 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001065 updatePkgs(pepperEnv, t, type)
1066 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001067 }
1068 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001069 updatePkgs(pepperEnv, target, type)
1070 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001071 }
1072 }
1073 }
1074
1075 if (updates.contains("mtr")) {
1076 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001077 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001078 if (salt.testTarget(pepperEnv, target)) {
1079 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001080 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001081 }
1082 if (PER_NODE.toBoolean()) {
1083 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1084 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001085 updatePkgs(pepperEnv, t, type)
1086 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001087 }
1088 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001089 updatePkgs(pepperEnv, target, type)
1090 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001091 }
1092 }
1093 }
1094
1095 if (updates.contains("cid")) {
1096 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001097 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001098 if (salt.testTarget(pepperEnv, target)) {
1099 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001100 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001101 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001102 updatePkgs(pepperEnv, target, type)
1103 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001104 verifyService(pepperEnv, target, 'docker')
1105 }
1106 }
1107
1108 //
1109 //physical machines update CMP_TARGET
1110 //
1111 if (updates.contains("cmp")) {
1112 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001113 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001114 if (salt.testTarget(pepperEnv, target)) {
1115 if (PER_NODE.toBoolean()) {
1116 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1117 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001118 updatePkgs(pepperEnv, t, type)
1119 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001120 }
1121 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001122 updatePkgs(pepperEnv, target, type)
1123 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001124 }
1125 verifyService(pepperEnv, target, 'nova-compute')
1126 }
1127 }
1128
1129 if (updates.contains("kvm")) {
1130 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001131 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001132 if (salt.testTarget(pepperEnv, target)) {
1133 if (PER_NODE.toBoolean()) {
1134 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1135 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001136 updatePkgs(pepperEnv, t, type)
1137 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001138 }
1139 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001140 updatePkgs(pepperEnv, target, type)
1141 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001142 }
1143 verifyService(pepperEnv, target, 'libvirt-bin')
1144 }
1145 }
1146
1147 if (updates.contains("osd")) {
1148 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001149 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001150 if (salt.testTarget(pepperEnv, target)) {
1151 if (PER_NODE.toBoolean()) {
1152 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1153 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001154 updatePkgs(pepperEnv, t, type)
1155 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001156 }
1157 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001158 updatePkgs(pepperEnv, target, type)
1159 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001160 }
1161 verifyCephOsds(pepperEnv, target)
1162 }
1163 }
1164
1165 if (updates.contains("gtw-physical")) {
1166 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001167 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001168 if (salt.testTarget(pepperEnv, target)) {
1169 if (PER_NODE.toBoolean()) {
1170 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1171 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001172 updatePkgs(pepperEnv, t, type)
1173 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001174 }
1175 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001176 updatePkgs(pepperEnv, target, type)
1177 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001178 }
1179 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1180 }
1181 }
1182
1183 /*
1184 * Rollback section
1185 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001186 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001187 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1188 stage('ROLLBACK_CFG') {
1189 input message: "To rollback CFG nodes run the following commands on kvm nodes hosting the CFG nodes: virsh destroy cfg0X.domain; virsh define /var/lib/libvirt/images/cfg0X.domain.xml; virsh start cfg0X.domain; virsh snapshot-delete cfg0X.domain --metadata ${SNAPSHOT_NAME}; rm /var/lib/libvirt/images/cfg0X.domain.${SNAPSHOT_NAME}.qcow2; rm /var/lib/libvirt/images/cfg0X.domain.xml; At the end restart 'docker' service on all cicd nodes and run 'linux.system.repo' Salt states on cicd nodes. After running the previous commands current pipeline job will be killed."
1190 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1191 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1192 }
1193 }
1194 } */
1195
1196 if (rollbacks.contains("ctl")) {
1197 def target = CTL_TARGET
1198 if (salt.testTarget(pepperEnv, target)) {
1199 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1200 rollback(pepperEnv, target, 'ctl')
1201 verifyAPIs(pepperEnv, target)
1202 } else {
1203 removeNode(pepperEnv, target, 'ctl')
1204 }
1205 }
1206 }
1207
1208 if (rollbacks.contains("prx")) {
1209 def target = PRX_TARGET
1210 if (salt.testTarget(pepperEnv, target)) {
1211 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1212 rollback(pepperEnv, target, 'prx')
1213 verifyService(pepperEnv, target, 'nginx')
1214 } else {
1215 removeNode(pepperEnv, target, 'prx')
1216 }
1217 }
1218 }
1219
1220 if (rollbacks.contains("msg")) {
1221 def target = MSG_TARGET
1222 if (salt.testTarget(pepperEnv, target)) {
1223 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1224 rollback(pepperEnv, target, 'msg')
1225 salt.enforceState(pepperEnv, target, 'rabbitmq')
1226 verifyService(pepperEnv, target, 'rabbitmq-server')
1227 } else {
1228 removeNode(pepperEnv, target, 'msg')
1229 }
1230 }
1231 }
1232
1233 if (rollbacks.contains("dbs")) {
1234 def target = DBS_TARGET
1235 if (salt.testTarget(pepperEnv, target)) {
1236 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1237 rollback(pepperEnv, target, 'dbs')
1238 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001239 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001240 } else {
1241 removeNode(pepperEnv, target, 'dbs')
1242 }
1243 }
1244 }
1245
1246 if (rollbacks.contains("ntw")) {
1247 def target = NTW_TARGET
1248 if (salt.testTarget(pepperEnv, target)) {
1249 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1250 rollback(pepperEnv, target, 'ntw')
1251 verifyContrail(pepperEnv, target)
1252 } else {
1253 removeNode(pepperEnv, target, 'ntw')
1254 }
1255 }
1256 }
1257
1258 if (rollbacks.contains("nal")) {
1259 def target = NAL_TARGET
1260 if (salt.testTarget(pepperEnv, target)) {
1261 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1262 rollback(pepperEnv, target, 'nal')
1263 verifyContrail(pepperEnv, target)
1264 } else {
1265 removeNode(pepperEnv, target, 'nal')
1266 }
1267 }
1268 }
1269
1270 if (rollbacks.contains("gtw-virtual")) {
1271 def target = GTW_TARGET
1272 if (salt.testTarget(pepperEnv, target)) {
1273 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1274 rollback(pepperEnv, target, 'gtw')
1275 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1276 } else {
1277 removeNode(pepperEnv, target, 'gtw')
1278 }
1279 }
1280 }
1281
1282 if (rollbacks.contains("cmn")) {
1283 def target = CMN_TARGET
1284 if (salt.testTarget(pepperEnv, target)) {
1285 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1286 rollback(pepperEnv, target, 'cmn')
1287 verifyCeph(pepperEnv, target, 'mon@')
1288 } else {
1289 removeNode(pepperEnv, target, 'cmn')
1290 }
1291 }
1292 }
1293
1294 if (rollbacks.contains("rgw")) {
1295 def target = RGW_TARGET
1296 if (salt.testTarget(pepperEnv, target)) {
1297 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1298 rollback(pepperEnv, target, 'rgw')
1299 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1300 } else {
1301 removeNode(pepperEnv, target, 'rgw')
1302 }
1303 }
1304 }
1305
1306 if (rollbacks.contains("log")) {
1307 def target = LOG_TARGET
1308 if (salt.testTarget(pepperEnv, target)) {
1309 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1310 rollback(pepperEnv, target, 'log')
1311 } else {
1312 removeNode(pepperEnv, target, 'log')
1313 }
1314 }
1315 }
1316
1317 if (rollbacks.contains("mon")) {
1318 def target = MON_TARGET
1319 if (salt.testTarget(pepperEnv, target)) {
1320 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1321 rollback(pepperEnv, target, 'mon')
1322 } else {
1323 removeNode(pepperEnv, target, 'mon')
1324 }
1325 }
1326 }
1327
1328 if (rollbacks.contains("mtr")) {
1329 def target = MTR_TARGET
1330 if (salt.testTarget(pepperEnv, target)) {
1331 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1332 rollback(pepperEnv, target, 'mtr')
1333 } else {
1334 removeNode(pepperEnv, target, 'mtr')
1335 }
1336 }
1337 }
1338 /*
1339 if (ROLLBACK_CID.toBoolean()) {
1340 def target = 'cid*'
1341 if (salt.testTarget(pepperEnv, target)) {
1342 stage('ROLLBACK_CID') {
1343 input message: "To rollback CICD nodes run the following commands on kvm nodes hosting the cicd nodes: virsh destroy cid0X.domain; virsh define /var/lib/libvirt/images/cid0X.domain.xml; virsh start cid0X.domain; virsh snapshot-delete cid0X.domain --metadata ${SNAPSHOT_NAME}; rm /var/lib/libvirt/images/cid0X.domain.${SNAPSHOT_NAME}.qcow2; rm /var/lib/libvirt/images/cid0X.domain.xml; At the end restart 'docker' service on all cicd nodes and run 'linux.system.repo' Salt states on cicd nodes. After running the previous commands current pipeline job will be killed."
1344 }
1345 }
1346 } */
1347
1348 //
1349 //physical machines rollback CMP_TARGET
1350 //
1351 if (rollbacks.contains("cmp")) {
1352 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001353 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001354 if (salt.testTarget(pepperEnv, target)) {
1355 if (PER_NODE.toBoolean()) {
1356 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1357 for (t in targetHosts) {
1358 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001359 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001360 }
1361 } else {
1362 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001363 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001364 }
1365 verifyService(pepperEnv, target, 'nova-compute')
1366 }
1367 }
1368
1369 if (rollbacks.contains("kvm")) {
1370 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001371 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001372 if (salt.testTarget(pepperEnv, target)) {
1373 if (PER_NODE.toBoolean()) {
1374 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1375 for (t in targetHosts) {
1376 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001377 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001378 }
1379 } else {
1380 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001381 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001382 }
1383 verifyService(pepperEnv, target, 'libvirt-bin')
1384 }
1385 }
1386
1387 if (rollbacks.contains("osd")) {
1388 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001389 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001390 if (salt.testTarget(pepperEnv, target)) {
1391 if (PER_NODE.toBoolean()) {
1392 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1393 for (t in targetHosts) {
1394 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001395 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001396 }
1397 } else {
1398 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001399 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001400 }
1401 verifyCephOsds(pepperEnv, target)
1402 }
1403 }
1404
1405 if (rollbacks.contains("gtw-physical")) {
1406 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001407 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001408 if (salt.testTarget(pepperEnv, target)) {
1409 if (PER_NODE.toBoolean()) {
1410 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1411 for (t in targetHosts) {
1412 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001413 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001414 }
1415 } else {
1416 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001417 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001418 }
1419 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1420 }
1421 }
1422
1423 /*
1424 * Merge snapshots section
1425 */
1426 if (merges.contains("cfg")) {
1427 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1428 mergeSnapshot(pepperEnv, 'I@salt:master')
1429 }
1430 }
1431
1432 if (merges.contains("ctl")) {
1433 if (salt.testTarget(pepperEnv, CTL_TARGET)) {
1434 mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl')
Jiri Broulik906e9972018-03-26 16:12:00 +02001435 verifyService(pepperEnv, CTL_TARGET, 'nova-api')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001436 }
1437 }
1438
1439 if (merges.contains("prx")) {
1440 if (salt.testTarget(pepperEnv, PRX_TARGET)) {
1441 mergeSnapshot(pepperEnv, PRX_TARGET, 'prx')
Jiri Broulik906e9972018-03-26 16:12:00 +02001442 verifyService(pepperEnv, PRX_TARGET, 'nginx')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001443 }
1444 }
1445
1446 if (merges.contains("msg")) {
1447 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1448 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001449 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001450 }
1451 }
1452
1453 if (merges.contains("dbs")) {
1454 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1455 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001456 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001457 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001458 }
1459 }
1460
1461 if (merges.contains("ntw")) {
1462 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1463 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001464 verifyContrail(pepperEnv, NTW_TARGET)
1465 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001466 }
1467 }
1468
1469 if (merges.contains("nal")) {
1470 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1471 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001472 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001473 }
1474 }
1475
1476 if (merges.contains("gtw-virtual")) {
1477 if (salt.testTarget(pepperEnv, GTW_TARGET)) {
1478 mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001479 verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001480 }
1481 }
1482
1483 if (merges.contains("cmn")) {
1484 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1485 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001486 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1487 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001488 }
1489 }
1490
1491 if (merges.contains("rgw")) {
1492 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1493 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001494 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001495 }
1496 }
1497
1498 if (merges.contains("log")) {
1499 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
1500 mergeSnapshot(pepperEnv, LOG_TARGET. 'log')
1501 }
1502 }
1503
1504 if (merges.contains("mon")) {
1505 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1506 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1507 }
1508 }
1509
1510 if (merges.contains("mtr")) {
1511 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1512 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1513 }
1514 }
1515
1516 if (merges.contains("cid")) {
1517 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1518 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001519 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001520 }
1521 }
1522
1523 if (RESTORE_GALERA.toBoolean()) {
1524 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001525 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001526 }
1527
1528 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1529 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001530 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001531 }
1532
1533 } catch (Throwable e) {
1534 // If there was an error or exception thrown, the build failed
1535 currentBuild.result = "FAILURE"
1536 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1537 throw e
1538 }
1539 }
1540}