blob: d58d1e04b50d7fcfc8ab0e972cb71475523dc870 [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)
Richard Felklaedc89b2018-06-26 23:50:49 +020040 * RUN_CVP_TESTS Run cloud validation pipelines before and after upgrade
Martin Polreich5ec90ee2018-08-21 16:27:40 +020041 * MINIONS_TEST_TIMEOUT Time in seconds for a Salt result to receive a response when calling a minionsReachable method.
Jiri Broulik60dcab32018-03-08 17:42:06 +010042 *
43**/
44def common = new com.mirantis.mk.Common()
45def salt = new com.mirantis.mk.Salt()
46def python = new com.mirantis.mk.Python()
47def virsh = new com.mirantis.mk.Virsh()
48
49def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
50def rollbacks = TARGET_ROLLBACKS.tokenize(",").collect{it -> it.trim()}
Jiri Broulik5dac8d82018-03-29 13:34:39 +020051def merges = TARGET_SNAPSHOT_MERGES.tokenize(",").collect{it -> it.trim()}
Jiri Broulik7ba05e42018-04-06 11:39:25 +020052def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
Jiri Broulik60dcab32018-03-08 17:42:06 +010053
54def pepperEnv = "pepperEnv"
55def minions
56def result
57def packages
58def command
59def commandKwargs
60
Martin Polreich5ec90ee2018-08-21 16:27:40 +020061def wait = 10
62if (common.validInputParam('MINIONS_TEST_TIMEOUT') && MINIONS_TEST_TIMEOUT.isInteger()) {
63 wait = "${MINIONS_TEST_TIMEOUT}".toInteger()
64}
65
Jiri Broulik60dcab32018-03-08 17:42:06 +010066def updatePkgs(pepperEnv, target, targetType="", targetPackages="") {
67 def salt = new com.mirantis.mk.Salt()
68 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +020069 def kernelUpdates = TARGET_KERNEL_UPDATES.tokenize(",").collect{it -> it.trim()}
70 def distUpgrade = false
Jiri Broulik60dcab32018-03-08 17:42:06 +010071 def commandKwargs
Jiri Broulik60dcab32018-03-08 17:42:06 +010072 def pkgs
73 def out
74
75 salt.enforceState(pepperEnv, target, 'linux.system.repo')
76
77 stage("List package upgrades") {
78 common.infoMsg("Listing all the packages that have a new update available on ${target}")
Jiri Broulikba6d85d2018-04-05 13:29:07 +020079 if (kernelUpdates.contains(targetType)) {
80 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
81 } else {
82 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', ['dist_upgrade=False'], null, true))
83 }
Jiri Broulik60dcab32018-03-08 17:42:06 +010084 if(targetPackages != "" && targetPackages != "*"){
85 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
86 }
87 }
88
89 if (INTERACTIVE.toBoolean()) {
90 stage("Confirm live package upgrades on ${target}") {
91 if (targetPackages=="") {
92 def userInput = input(
93 id: 'userInput', message: 'Insert package names for update', parameters: [
94 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
95 ])
96 if (userInput!= "" && userInput!= "*") {
97 targetPackages = userInput
98 }
99 } else {
100 input message: "Approve live package upgrades on ${target} nodes?"
101 }
102 }
103 } else {
104 targetPackages = pkgs.keySet().join(",").toString()
105 }
106
107 if (targetPackages != "") {
108 // list installed versions of pkgs that will be upgraded
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200109 if (targetType == 'kvm' || targetType == 'cmp' || targetType == 'osd' || targetType == 'gtw-physical') {
110 def installedPkgs = []
111 def newPkgs = []
112 def targetPkgList = targetPackages.tokenize(',')
113 for (pkg in targetPkgList) {
114 def version
115 try {
116 def pkgsDetails = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.info_installed', [pkg], null, true))
117 version = pkgsDetails.get(pkg).get('version')
118 } catch (Exception er) {
119 common.infoMsg("${pkg} not installed yet")
120 }
121 if (version?.trim()) {
122 installedPkgs.add(pkg + '=' + version)
123 } else {
124 newPkgs.add(pkg)
125 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100126 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200127 common.warningMsg("the following list of pkgs will be upgraded")
128 common.warningMsg(installedPkgs.join(" "))
129 common.warningMsg("the following list of pkgs will be newly installed")
130 common.warningMsg(newPkgs.join(" "))
Jiri Broulik60dcab32018-03-08 17:42:06 +0100131 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100132 // set variables
133 command = "pkg.install"
134 packages = targetPackages
135 commandKwargs = ['only_upgrade': 'true','force_yes': 'true']
136
137 }else {
138 command = "pkg.upgrade"
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200139 if (kernelUpdates.contains(targetType)) {
140 commandKwargs = ['dist_upgrade': 'true']
141 distUpgrade = true
142 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100143 packages = null
144 }
145
Jiri Broulik60dcab32018-03-08 17:42:06 +0100146 stage("stop services on ${target}") {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200147 if ((STOP_SERVICES.toBoolean()) && (targetType != 'cid')) {
148 if (targetType == 'ntw' || targetType == 'nal') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200149 contrailServices(pepperEnv, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100150 } else {
151 def probe = salt.getFirstMinion(pepperEnv, "${target}")
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200152 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100153 }
154 }
155 }
156
157 stage('Apply package upgrades') {
158 // salt master pkg
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200159 if (targetType == 'cfg') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100160 common.warningMsg('salt-master pkg upgrade, rerun the pipeline if disconnected')
161 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-master'], null, true, 5)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200162 salt.minionsReachable(pepperEnv, 'I@salt:master', '*', null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100163 }
164 // salt minion pkg
165 salt.runSaltProcessStep(pepperEnv, target, 'pkg.install', ['salt-minion'], null, true, 5)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200166 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100167 common.infoMsg('Performing pkg upgrades ... ')
168 common.retry(3){
169 out = salt.runSaltCommand(pepperEnv, 'local', ['expression': target, 'type': 'compound'], command, true, packages, commandKwargs)
170 salt.printSaltCommandResult(out)
171 }
172 def osRelease = salt.getGrain(pepperEnv, target, 'lsb_distrib_codename')
173 if (osRelease.toString().toLowerCase().contains('trusty')) {
174 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --force-yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
175 } else {
176 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q -f --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
177 }
178 if (out.toString().contains('errors:')) {
179 try {
180 if (packages?.trim()) {
181 packages = packages.replaceAll(',', ' ')
182 common.retry(3){
183 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
184 }
185 } else {
186 if (distUpgrade) {
187 common.retry(3){
188 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
189 }
190 } else {
191 common.retry(3){
192 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
193 }
194 } }
195 if (out.toString().contains('E: ')) {
196 common.errorMsg(out)
197 if (INTERACTIVE.toBoolean()) {
198 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
199 } else {
200 salt.printSaltCommandResult(out)
201 throw new Exception("Pkgs update failed")
202 }
203 }
204 } catch (Exception e) {
205 common.errorMsg(out)
206 common.errorMsg(e)
207 if (INTERACTIVE.toBoolean()) {
208 input message: "Pkgs update failed to be updated on ${target}. Please fix it manually."
209 } else {
210 throw new Exception("Pkgs update failed")
211 }
212 }
213 }
214 }
215}
216
217def rollbackPkgs(pepperEnv, target, targetType = "", targetPackages="") {
218 def salt = new com.mirantis.mk.Salt()
219 def common = new com.mirantis.mk.Common()
220 def probe = salt.getFirstMinion(pepperEnv, "${target}")
221 def distUpgrade
222 def pkgs
223 def out
224
225 salt.enforceState(pepperEnv, target, 'linux.system.repo')
226
227 if (ROLLBACK_PKG_VERSIONS == "") {
228 stage("List package upgrades") {
229 common.infoMsg("Listing all the packages that have a new update available on ${target}")
230 pkgs = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, target, 'pkg.list_upgrades', [], null, true))
231 if(targetPackages != "" && targetPackages != "*"){
232 common.infoMsg("Note that only the ${targetPackages} would be installed from the above list of available updates on the ${target}")
233 }
234 }
235
236 if (INTERACTIVE.toBoolean()) {
237 stage("Confirm live package upgrades on ${target}") {
238 if(targetPackages==""){
239 timeout(time: 2, unit: 'HOURS') {
240 def userInput = input(
241 id: 'userInput', message: 'Insert package names for update', parameters: [
242 [$class: 'TextParameterDefinition', defaultValue: pkgs.keySet().join(",").toString(), description: 'Package names (or *)', name: 'packages']
243 ])
244 if(userInput!= "" && userInput!= "*"){
245 targetPackages = userInput
246 }
247 }
248 }else{
249 timeout(time: 2, unit: 'HOURS') {
250 input message: "Approve live package upgrades on ${target} nodes?"
251 }
252 }
253 }
254 } else {
255 targetPackages = pkgs.keySet().join(",").toString()
256 }
257 } else {
258 targetPackages = ROLLBACK_PKG_VERSIONS
259 }
260
261 if (targetPackages != "") {
262 // set variables
263 packages = targetPackages
264 } else {
265 distUpgrade = true
266 packages = null
267 }
268
269 stage("stop services on ${target}") {
270 try {
271 if (INTERACTIVE.toBoolean()) {
272 input message: "Click PROCEED to interactively stop services on ${target}. Otherwise click ABORT to skip stopping them and continue."
273 }
274 } catch (Exception er) {
275 common.infoMsg('skipping stopping services')
276 return
277 }
278 if (STOP_SERVICES.toBoolean()) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200279 services(pepperEnv, probe, target, 'stop')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100280 }
281 }
282
283 stage('Apply package downgrades') {
284 args = 'export DEBIAN_FRONTEND=noninteractive; apt-get -y -q --allow-downgrades -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" '
285 common.infoMsg('Performing pkgs purge/remove ... ')
286 try {
287 if (PURGE_PKGS != "") {
288 def purgePackages = PURGE_PKGS.replaceAll(',', ' ')
289 common.retry(3){
290 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' purge ' + purgePackages])
291 }
292 }
293 if (REMOVE_PKGS != "") {
294 def removePackages = REMOVE_PKGS.replaceAll(',', ' ')
295 common.retry(3){
296 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' remove ' + removePackages])
297 }
298 }
299 if (out.toString().contains('E: ')) {
300 common.errorMsg(out)
301 if (INTERACTIVE.toBoolean()) {
302 input message: "Pkgs ${packages} purge failed on ${target}. Please fix it manually."
303 } else {
304 salt.printSaltCommandResult(out)
305 throw new Exception("Pkgs {packages} purge failed")
306 }
307 }
308 } catch (Exception e) {
309 common.errorMsg(out)
310 common.errorMsg(e)
311 if (INTERACTIVE.toBoolean()) {
312 input message: "Pkgs {packages} purge on ${target}. Please fix it manually."
313 } else {
314 throw new Exception("Pkgs {packages} purge failed")
315 }
316 }
317
318 common.infoMsg('Performing pkg downgrades ... ')
319 try {
320 packages = packages.replaceAll(',', ' ')
321 if (packages?.trim()) {
322 packages = packages.replaceAll(',', ' ')
323 common.retry(3){
324 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install salt-minion'], null, true, 5)
325 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200326 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100327 common.retry(3){
328 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' install ' + packages])
329 }
330 } else {
331 if (distUpgrade) {
332 common.retry(3){
333 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' dist-upgrade'])
334 }
335 } else {
336 common.retry(3){
337 out = salt.runSaltProcessStep(pepperEnv, target, 'cmd.run', [args + ' upgrade'])
338 }
339 }
340 }
341 if (out.toString().contains('E: ')) {
342 common.errorMsg(out)
343 if (INTERACTIVE.toBoolean()) {
344 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
345 } else {
346 salt.printSaltCommandResult(out)
347 throw new Exception("Pkgs rollback failed")
348 }
349 }
350 } catch (Exception e) {
351 common.errorMsg(out)
352 common.errorMsg(e)
353 if (INTERACTIVE.toBoolean()) {
354 input message: "Pkgs rollback failed on ${target}. Please fix it manually."
355 } else {
356 throw new Exception("Pkgs rollback failed")
357 }
358 }
359 }
360}
361
Jiri Broulik827d0112018-04-25 16:00:07 +0200362def getNodeProvider(pepperEnv, nodeName, type='') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100363 def salt = new com.mirantis.mk.Salt()
364 def common = new com.mirantis.mk.Common()
Jiri Broulik827d0112018-04-25 16:00:07 +0200365 def kvms = salt.getMinions(pepperEnv, 'I@salt:control')
366 for (kvm in kvms) {
367 try {
368 vms = salt.getReturnValues(salt.runSaltProcessStep(pepperEnv, kvm, 'virt.list_domains', [], null, true))
369 if (vms.toString().contains(nodeName)) {
370 if (type == 'master' && !CFG_NODE_PROVIDER?.trim()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100371 CFG_NODE_PROVIDER = kvm
Jiri Broulik827d0112018-04-25 16:00:07 +0200372 } else {
373 return kvm
Jiri Broulik60dcab32018-03-08 17:42:06 +0100374 //break
375 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100376 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100377 } catch (Exception er) {
Jiri Broulik827d0112018-04-25 16:00:07 +0200378 common.infoMsg("${nodeName} not present on ${kvm}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100379 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100380 }
381}
382
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200383def services(pepperEnv, probe, target, action='stop') {
384 def services = ["keepalived","haproxy","nginx","nova-api","cinder","glance","heat","neutron","apache2","rabbitmq-server"]
385 if (action == 'stop') {
386 def openstack = new com.mirantis.mk.Openstack()
387 openstack.stopServices(pepperEnv, probe, target, services, INTERACTIVE.toBoolean())
Jiri Broulik60dcab32018-03-08 17:42:06 +0100388 } else {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200389 def salt = new com.mirantis.mk.Salt()
390 for (s in services) {
Dmitry Ukovfbb18ee2018-09-04 17:57:03 +0400391 def outputServicesStr = salt.getReturnValues(salt.cmdRun(pepperEnv, probe, "service --status-all | grep ${s} | awk \'{print \$4}\'"))
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200392 def servicesList = outputServicesStr.tokenize("\n").init() //init() returns the items from the Iterable excluding the last item
393 if (servicesList) {
394 for (name in servicesList) {
395 if (!name.contains('Salt command')) {
396 salt.runSaltProcessStep(pepperEnv, "${target}*", 'service.start', ["${name}"])
397 }
398 }
399 }
400 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100401 }
402}
403
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200404// must be treated separately due to OC on Trusty
405def contrailServices(pepperEnv, target, action='stop') {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100406 def salt = new com.mirantis.mk.Salt()
407 def common = new com.mirantis.mk.Common()
408 def services = []
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200409 if (action == 'stop') {
410 services.add('supervisor-control')
411 services.add('supervisor-config')
412 services.add('supervisor-database')
413 services.add('zookeeper')
414 services.add('ifmap-server')
415 services.add('haproxy')
416 services.add('keepalived')
417 } else {
418 services.add('keepalived')
419 services.add('haproxy')
420 services.add('ifmap-server')
421 services.add('zookeeper')
422 services.add('supervisor-database')
423 services.add('supervisor-config')
424 services.add('supervisor-control')
425 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100426 for (s in services) {
427 try {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200428 salt.runSaltProcessStep(pepperEnv, target, "service.${action}", [s], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100429 } catch (Exception er) {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200430 common.warningMsg(er)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100431 }
432 }
433}
434
Jiri Broulik059d2df2018-06-15 14:03:34 +0200435def periodicCheck(pepperEnv, target, maxRetries=50) {
436 def salt = new com.mirantis.mk.Salt()
437 def common = new com.mirantis.mk.Common()
438 def count = 0
439 while(count < maxRetries) {
440 try {
441 sleep(10)
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200442 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200443 break
444 } catch (Exception e) {
445 common.warningMsg("${target} not ready yet. Waiting ...")
446 }
447 count++
448 }
449}
450
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200451def highstate(pepperEnv, target, type) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100452 def salt = new com.mirantis.mk.Salt()
453 def common = new com.mirantis.mk.Common()
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200454 def highstates = TARGET_HIGHSTATE.tokenize(",").collect{it -> it.trim()}
455 def reboots = TARGET_REBOOT.tokenize(",").collect{it -> it.trim()}
456 // optionally run highstate
457 if (highstates.contains(type)) {
458 stage("Apply highstate on ${target} nodes") {
459 try {
460 common.retry(3){
Martin Polreich372d9b92018-10-04 16:44:56 +0200461 out = salt.enforceHighstate(pepperEnv, target)
462 salt.printSaltCommandResult(out)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200463 }
464 } catch (Exception e) {
465 common.errorMsg(e)
466 if (INTERACTIVE.toBoolean()) {
467 input message: "Highstate failed on ${target}. Fix it manually or run rollback on ${target}."
468 } else {
469 throw new Exception("highstate failed")
470 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100471 }
472 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200473 } else if (!reboots.contains(type) && STOP_SERVICES.toBoolean() && type != 'cid') {
474 if (type == 'ntw' || type == 'nal') {
475 contrailServices(pepperEnv, target, 'start')
476 } else {
477 def probe = salt.getFirstMinion(pepperEnv, "${target}")
478 services(pepperEnv, probe, target, 'start')
479 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100480 }
481 // optionally reboot
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200482 if (reboots.contains(type)) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100483 stage("Reboot ${target} nodes") {
Jiri Broulik059d2df2018-06-15 14:03:34 +0200484 if (type == 'cfg') {
485 try {
486 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
487 } catch (Exception e) {
488 periodicCheck(pepperEnv, target)
489 }
490 } else {
491 salt.runSaltProcessStep(pepperEnv, target, 'system.reboot', null, null, true, 5)
492 sleep 10
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200493 salt.minionsReachable(pepperEnv, 'I@salt:master', target, null, wait)
Jiri Broulik059d2df2018-06-15 14:03:34 +0200494 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100495 }
496 }
497}
498
499def rollback(pepperEnv, tgt, generalTarget) {
500 def common = new com.mirantis.mk.Common()
501 try {
502 if (INTERACTIVE.toBoolean()) {
503 input message: "Are you sure to rollback ${generalTarget}? To rollback click on PROCEED. To skip rollback click on ABORT."
504 }
505 } catch (Exception er) {
506 common.infoMsg('skipping rollback')
507 return
508 }
509 try {
510 rollbackLiveSnapshot(pepperEnv, tgt, generalTarget)
511 } catch (Exception err) {
512 common.errorMsg(err)
513 if (INTERACTIVE.toBoolean()) {
514 input message: "Rollback for ${tgt} failed please fix it manually before clicking PROCEED."
515 } else {
516 throw new Exception("Rollback failed for ${tgt}")
517 }
518 }
519}
520
521def liveSnapshot(pepperEnv, tgt, generalTarget) {
522 def salt = new com.mirantis.mk.Salt()
523 def common = new com.mirantis.mk.Common()
524 def virsh = new com.mirantis.mk.Virsh()
525 def domain = salt.getDomainName(pepperEnv)
526 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
527 common.warningMsg(target_hosts)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100528 for (t in target_hosts) {
529 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200530 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100531 virsh.liveSnapshotPresent(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100532 }
533}
534
535def mergeSnapshot(pepperEnv, tgt, generalTarget='') {
536 def salt = new com.mirantis.mk.Salt()
537 def virsh = new com.mirantis.mk.Virsh()
538 def domain = salt.getDomainName(pepperEnv)
539 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
Jiri Broulik60dcab32018-03-08 17:42:06 +0100540 for (t in target_hosts) {
541 if (tgt == 'I@salt:master') {
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200542 def master = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200543 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100544 virsh.liveSnapshotMerge(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
545 } else {
546 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200547 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100548 virsh.liveSnapshotMerge(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
549 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100550 }
Martin Polreich5ec90ee2018-08-21 16:27:40 +0200551 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt, null, wait)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100552}
553
554
555
556def rollbackLiveSnapshot(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 Broulik60dcab32018-03-08 17:42:06 +0100567 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100568 // rollback vms
569 for (t in target_hosts) {
570 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200571 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100572 virsh.liveSnapshotRollback(pepperEnv, nodeProvider, target, SNAPSHOT_NAME)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100573 }
574 try {
575 salt.minionsReachable(pepperEnv, 'I@salt:master', tgt)
576 // purge and setup previous repos
577 salt.enforceState(pepperEnv, tgt, 'linux.system.repo')
578 } catch (Exception e) {
579 common.errorMsg(e)
580 if (INTERACTIVE.toBoolean()) {
581 input message: "Salt state linux.system.repo on ${tgt} failed. Do you want to PROCEED?."
582 } else {
583 throw new Exception("Salt state linux.system.repo on ${tgt} failed")
584 }
585 }
586}
587
588def removeNode(pepperEnv, tgt, generalTarget) {
589 def salt = new com.mirantis.mk.Salt()
590 def virsh = new com.mirantis.mk.Virsh()
591 def common = new com.mirantis.mk.Common()
592 def domain = salt.getDomainName(pepperEnv)
593 def target_hosts = salt.getMinionsSorted(pepperEnv, "${tgt}")
594 // first destroy all vms
Jiri Broulik60dcab32018-03-08 17:42:06 +0100595 for (t in target_hosts) {
596 def target = salt.stripDomainName(t)
Jiri Broulik827d0112018-04-25 16:00:07 +0200597 def nodeProvider = getNodeProvider(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100598 salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.destroy', ["${target}.${domain}"], null, true)
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200599 //salt.runSaltProcessStep(pepperEnv, "${nodeProvider}*", 'virt.undefine', ["${target}.${domain}"], null, true)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100600 try {
601 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key -d ${target}.${domain} -y")
602 } catch (Exception e) {
603 common.warningMsg('does not match any accepted, unaccepted or rejected keys. They were probably already removed. We should continue to run')
604 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100605 }
606}
607
Jiri Broulik906e9972018-03-26 16:12:00 +0200608def saltMasterBackup(pepperEnv) {
609 def salt = new com.mirantis.mk.Salt()
610 salt.enforceState(pepperEnv, 'I@salt:master', 'backupninja')
611 salt.cmdRun(pepperEnv, 'I@salt:master', "su root -c 'backupninja -n --run /etc/backup.d/200.backup.rsync'")
612}
613
Jiri Broulik60dcab32018-03-08 17:42:06 +0100614def backupCeph(pepperEnv, tgt) {
615 def salt = new com.mirantis.mk.Salt()
616 salt.enforceState(pepperEnv, 'I@ceph:backup:server', 'ceph.backup')
617 salt.enforceState(pepperEnv, "I@ceph:backup:client and ${tgt}", 'ceph.backup')
618 salt.cmdRun(pepperEnv, "I@ceph:backup:client and ${tgt}", "su root -c '/usr/local/bin/ceph-backup-runner-call.sh -s'")
619}
620
621def backupGalera(pepperEnv) {
622 def salt = new com.mirantis.mk.Salt()
623 salt.enforceState(pepperEnv, 'I@xtrabackup:server', ['linux.system.repo', 'xtrabackup'])
624 salt.enforceState(pepperEnv, 'I@xtrabackup:client', ['linux.system.repo', 'openssh.client'])
625 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c 'salt-call state.sls xtrabackup'")
626 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "su root -c '/usr/local/bin/innobackupex-runner.sh -s -f'")
627}
628
629// cluster galera - wsrep_cluster_size
630def clusterGalera(pepperEnv) {
631 def salt = new com.mirantis.mk.Salt()
632 def common = new com.mirantis.mk.Common()
633 try {
634 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.stop', ['mysql'])
635 } catch (Exception er) {
636 common.warningMsg('Mysql service already stopped')
637 }
638 try {
639 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.stop', ['mysql'])
640 } catch (Exception er) {
641 common.warningMsg('Mysql service already stopped')
642 }
643 try {
644 salt.cmdRun(pepperEnv, 'I@galera:slave', "rm /var/lib/mysql/ib_logfile*")
645 } catch (Exception er) {
646 common.warningMsg('Files are not present')
647 }
648 salt.cmdRun(pepperEnv, 'I@galera:master', "sed -i '/gcomm/c\\wsrep_cluster_address=\"gcomm://\"' /etc/mysql/my.cnf")
649 salt.runSaltProcessStep(pepperEnv, 'I@galera:master', 'service.start', ['mysql'])
650 // wait until mysql service on galera master is up
651 try {
652 salt.commandStatus(pepperEnv, 'I@galera:master', 'service mysql status', 'running')
653 } catch (Exception er) {
654 if (INTERACTIVE.toBoolean()) {
655 input message: "Database is not running please fix it first and only then click on PROCEED."
656 } else {
657 throw new Exception("Database is not running correctly")
658 }
659 }
660 salt.runSaltProcessStep(pepperEnv, 'I@galera:slave', 'service.start', ['mysql'])
661}
662
663def restoreGalera(pepperEnv) {
664 def salt = new com.mirantis.mk.Salt()
665 def common = new com.mirantis.mk.Common()
666 def openstack = new com.mirantis.mk.Openstack()
667 salt.cmdRun(pepperEnv, 'I@xtrabackup:client', "rm -rf /var/lib/mysql/*")
668 openstack.restoreGaleraDb(pepperEnv)
669}
670
671def backupZookeeper(pepperEnv) {
672 def salt = new com.mirantis.mk.Salt()
673 def common = new com.mirantis.mk.Common()
674 salt.enforceState(pepperEnv, 'I@zookeeper:backup:server', 'zookeeper.backup')
675 salt.enforceState(pepperEnv, 'I@zookeeper:backup:client', 'zookeeper.backup')
676 try {
677 salt.cmdRun(pepperEnv, 'I@opencontrail:control', "su root -c '/usr/local/bin/zookeeper-backup-runner.sh -s'")
678 } catch (Exception er) {
679 throw new Exception('Zookeeper failed to backup. Please fix it before continuing.')
680 }
681}
682
683def backupCassandra(pepperEnv) {
684 def salt = new com.mirantis.mk.Salt()
685 def common = new com.mirantis.mk.Common()
686
687 salt.enforceState(pepperEnv, 'I@cassandra:backup:server', 'cassandra.backup')
688 salt.enforceState(pepperEnv, 'I@cassandra:backup:client', 'cassandra.backup')
689 try {
690 salt.cmdRun(pepperEnv, 'I@cassandra:backup:client', "su root -c '/usr/local/bin/cassandra-backup-runner-call.sh -s'")
691 } catch (Exception er) {
692 throw new Exception('Cassandra failed to backup. Please fix it before continuing.')
693 }
694}
695
696def backupContrail(pepperEnv) {
697 backupZookeeper(pepperEnv)
698 backupCassandra(pepperEnv)
699}
700
701// cassandra and zookeeper
702def restoreContrailDb(pepperEnv) {
703 def salt = new com.mirantis.mk.Salt()
704 def common = new com.mirantis.mk.Common()
705 build job: "deploy-zookeeper-restore", parameters: [
706 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
707 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
708 ]
709 build job: "deploy-cassandra-db-restore", parameters: [
710 [$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: SALT_MASTER_CREDENTIALS],
711 [$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: SALT_MASTER_URL]
712 ]
713}
714
Jiri Broulikd2dd5632018-03-27 15:44:56 +0200715def verifyAPIs(pepperEnv, target) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100716 def salt = new com.mirantis.mk.Salt()
717 def common = new com.mirantis.mk.Common()
William Konitzerb147e842018-06-15 15:03:40 -0500718 def cmds = ["openstack service list",
719 "openstack image list",
720 "openstack flavor list",
721 "openstack compute service list",
722 "openstack server list",
723 "openstack network list",
724 "openstack volume list",
725 "openstack orchestration service list"]
726 def sourcerc = ". /root/keystonercv3;"
727 def cmdOut = ">/dev/null 2>&1;echo \$?"
728 for (c in cmds) {
729 def command = sourcerc + c + cmdOut
730 def out = salt.cmdRun(pepperEnv, target, "${command}")
731 if (!out.toString().toLowerCase().contains('0')) {
732 common.errorMsg(out)
733 if (INTERACTIVE.toBoolean()) {
734 input message: "APIs are not working as expected. Please fix it manually."
735 } else {
736 throw new Exception("APIs are not working as expected")
737 }
Jiri Broulikad606d02018-03-28 14:22:43 +0200738 }
739 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100740}
741
Jiri Broulikad606d02018-03-28 14:22:43 +0200742def verifyGalera(pepperEnv, target, count=0, maxRetries=200) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100743 def salt = new com.mirantis.mk.Salt()
744 def common = new com.mirantis.mk.Common()
Jiri Broulikad606d02018-03-28 14:22:43 +0200745 def out
746 while(count < maxRetries) {
747 try {
William Konitzer667143f2018-06-15 14:21:17 -0500748 out = salt.getReturnValues(salt.cmdRun(pepperEnv, target, 'salt-call -l quiet mysql.status | grep -A1 wsrep_cluster_size'))
Jiri Broulikad606d02018-03-28 14:22:43 +0200749 } catch (Exception er) {
750 common.infoMsg(er)
751 }
752 if ((!out.toString().contains('wsrep_cluster_size')) || (out.toString().contains('0'))) {
753 count++
754 if (count == maxRetries) {
755 if (INTERACTIVE.toBoolean()) {
756 input message: "Galera is not working as expected. Please check it and fix it first before clicking on PROCEED."
757 } else {
758 common.errorMsg(out)
759 throw new Exception("Galera is not working as expected")
760 }
761 }
762 sleep(time: 500, unit: 'MILLISECONDS')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100763 } else {
Jiri Broulikad606d02018-03-28 14:22:43 +0200764 break
Jiri Broulik60dcab32018-03-08 17:42:06 +0100765 }
766 }
767}
768
769def verifyContrail(pepperEnv, target) {
770 def salt = new com.mirantis.mk.Salt()
771 def common = new com.mirantis.mk.Common()
772 salt.commandStatus(pepperEnv, target, "contrail-status | grep -v == | grep -v \'disabled on boot\' | grep -v nodemgr | grep -v active | grep -v backup", null, false)
773}
774
775
776def verifyService(pepperEnv, target, service) {
777 def salt = new com.mirantis.mk.Salt()
778 def common = new com.mirantis.mk.Common()
779 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
780 for (t in targetHosts) {
781 try {
782 salt.commandStatus(pepperEnv, t, "service ${service} status", 'running')
783 } catch (Exception er) {
784 common.errorMsg(er)
785 if (INTERACTIVE.toBoolean()) {
786 input message: "${service} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
787 } else {
788 throw new Exception("${service} service is not running correctly on ${t}")
789 }
790 }
791 }
792}
793
794def verifyCeph(pepperEnv, target, type) {
795 def salt = new com.mirantis.mk.Salt()
796 def common = new com.mirantis.mk.Common()
797 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
798 for (t in targetHosts) {
799 def hostname = salt.getReturnValues(salt.getPillar(pepperEnv, t, 'linux:network:hostname'))
800 try {
801 salt.commandStatus(pepperEnv, t, "systemctl status ceph-${type}${hostname}", 'running')
802 } catch (Exception er) {
803 common.errorMsg(er)
804 if (INTERACTIVE.toBoolean()) {
805 input message: "Ceph-${type}${hostname} service is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
806 } else {
807 throw new Exception("Ceph-${type}${hostname} service is not running correctly on ${t}")
808 }
809 }
810 }
811}
812
813def verifyCephOsds(pepperEnv, target) {
814 def salt = new com.mirantis.mk.Salt()
815 def common = new com.mirantis.mk.Common()
816 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
817 for (t in targetHosts) {
818 def osd_ids = []
819 // get list of osd disks of the host
820 salt.runSaltProcessStep(pepperEnv, t, 'saltutil.sync_grains', [], null, true, 5)
821 def cephGrain = salt.getGrain(pepperEnv, t, 'ceph')
822 if(cephGrain['return'].isEmpty()){
823 throw new Exception("Ceph salt grain cannot be found!")
824 }
825 common.print(cephGrain)
826 def ceph_disks = cephGrain['return'][0].values()[0].values()[0]['ceph_disk']
827 for (i in ceph_disks) {
828 def osd_id = i.getKey().toString()
829 osd_ids.add('osd.' + osd_id)
830 print("Will check osd." + osd_id)
831 }
832 for (i in osd_ids) {
833 try {
834 salt.commandStatus(pepperEnv, t, "ceph osd tree | grep -w ${i}", 'up')
835 } catch (Exception er) {
836 common.errorMsg(er)
837 if (INTERACTIVE.toBoolean()) {
838 input message: "Ceph ${i} is not running correctly on ${t}. Please fix it first manually and only then click on PROCEED."
839 } else {
840 throw new Exception("Ceph ${i} is not running correctly on ${t}")
841 }
842 }
843 }
844 }
845}
846
847
848timeout(time: 12, unit: 'HOURS') {
849 node() {
850 try {
Richard Felklaedc89b2018-06-26 23:50:49 +0200851 if(RUN_CVP_TESTS.toBoolean() == True){
852 stage('Run CVP tests before upgrade.') {
853 build job: "cvp-sanity"
854 build job: "cvp-func"
855 build job: "cvp-ha"
856 build job: "cvp-perf"
857 }
858 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100859
860 stage('Setup virtualenv for Pepper') {
861 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
862 }
863
864 // TODO, add possibility to update just specific components like kernel, openstack, contrail, ovs, rabbitmq, galera, etc.
865
866 /*
867 * Update section
868 */
869 if (updates.contains("cfg")) {
870 def target = 'I@salt:master'
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200871 def type = 'cfg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100872 if (salt.testTarget(pepperEnv, target)) {
873 def master = salt.getReturnValues(salt.getPillar(pepperEnv, target, 'linux:network:hostname'))
Jiri Broulik827d0112018-04-25 16:00:07 +0200874 getNodeProvider(pepperEnv, master, 'master')
Jiri Broulik60dcab32018-03-08 17:42:06 +0100875 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
876 virsh.liveSnapshotPresent(pepperEnv, CFG_NODE_PROVIDER, master, SNAPSHOT_NAME)
Jiri Broulik906e9972018-03-26 16:12:00 +0200877 } else {
878 saltMasterBackup(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100879 }
880 if (PER_NODE.toBoolean()) {
881 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
882 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200883 updatePkgs(pepperEnv, t, type)
884 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100885 }
886 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200887 updatePkgs(pepperEnv, target, type)
888 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100889 }
890 }
891 }
892
893 if (updates.contains("ctl")) {
894 def target = CTL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200895 def type = 'ctl'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100896 if (salt.testTarget(pepperEnv, target)) {
897 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200898 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100899 }
900 if (PER_NODE.toBoolean()) {
901 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
902 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200903 updatePkgs(pepperEnv, t, type)
904 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100905 }
906 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200907 updatePkgs(pepperEnv, target, type)
908 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100909 }
910 verifyAPIs(pepperEnv, target)
911 }
912 }
913
914 if (updates.contains("prx")) {
915 def target = PRX_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200916 def type = 'prx'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100917 if (salt.testTarget(pepperEnv, target)) {
918 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200919 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100920 }
921 if (PER_NODE.toBoolean()) {
922 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
923 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200924 updatePkgs(pepperEnv, t, type)
925 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100926 }
927 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200928 updatePkgs(pepperEnv, target, type)
929 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100930 }
931 verifyService(pepperEnv, target, 'nginx')
932 }
933 }
934
935 if (updates.contains("msg")) {
936 def target = MSG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200937 def type = 'msg'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100938 if (salt.testTarget(pepperEnv, target)) {
939 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200940 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100941 }
942 if (PER_NODE.toBoolean()) {
943 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
944 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200945 updatePkgs(pepperEnv, t, type)
946 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100947 }
948 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200949 updatePkgs(pepperEnv, target, type)
950 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100951 }
952 verifyService(pepperEnv, target, 'rabbitmq-server')
953 }
954 }
955
956 if (updates.contains("dbs")) {
957 def target = DBS_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200958 def type = 'dbs'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100959 if (salt.testTarget(pepperEnv, target)) {
960 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100961 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200962 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100963 }
Jiri Broulik7ba05e42018-04-06 11:39:25 +0200964 if (reboots.contains(type) || PER_NODE.toBoolean()) {
Jiri Broulik60dcab32018-03-08 17:42:06 +0100965 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100966 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200967 updatePkgs(pepperEnv, t, type)
968 highstate(pepperEnv, t, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200969 verifyGalera(pepperEnv, t)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100970 }
971 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200972 updatePkgs(pepperEnv, target, type)
973 highstate(pepperEnv, target, type)
Jiri Broulikad606d02018-03-28 14:22:43 +0200974 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100975 }
Jiri Broulik60dcab32018-03-08 17:42:06 +0100976 }
977 }
978
979 if (updates.contains("ntw")) {
980 def target = NTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200981 def type = 'ntw'
Jiri Broulik60dcab32018-03-08 17:42:06 +0100982 if (salt.testTarget(pepperEnv, target)) {
983 backupContrail(pepperEnv)
984 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200985 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100986 }
987 if (PER_NODE.toBoolean()) {
988 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
989 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200990 updatePkgs(pepperEnv, t, type)
991 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100992 verifyContrail(pepperEnv, t)
993 }
994 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +0200995 updatePkgs(pepperEnv, target, type)
996 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +0100997 verifyContrail(pepperEnv, target)
998 }
999 }
1000 }
1001
1002 if (updates.contains("nal")) {
1003 def target = NAL_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001004 def type = 'nal'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001005 if (salt.testTarget(pepperEnv, target)) {
1006 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001007 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001008 }
1009 if (PER_NODE.toBoolean()) {
1010 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1011 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001012 updatePkgs(pepperEnv, t, type)
1013 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001014 }
1015 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001016 updatePkgs(pepperEnv, target, type)
1017 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001018 }
1019 verifyContrail(pepperEnv, target)
1020 }
1021 }
1022
1023 if (updates.contains("gtw-virtual")) {
1024 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001025 def type = 'gtw-virtual'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001026 if (salt.testTarget(pepperEnv, target)) {
1027 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001028 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001029 }
1030 if (PER_NODE.toBoolean()) {
1031 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1032 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001033 updatePkgs(pepperEnv, t, type)
1034 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001035 }
1036 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001037 updatePkgs(pepperEnv, target, type)
1038 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001039 }
1040 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1041 }
1042 }
1043
1044 if (updates.contains("cmn")) {
1045 def target = CMN_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001046 def type = 'cmn'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001047 if (salt.testTarget(pepperEnv, target)) {
1048 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001049 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001050 } else {
Jiri Broulik906e9972018-03-26 16:12:00 +02001051 backupCeph(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001052 }
1053 if (PER_NODE.toBoolean()) {
1054 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1055 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001056 updatePkgs(pepperEnv, t, type)
1057 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001058 }
1059 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001060 updatePkgs(pepperEnv, target, type)
1061 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001062 }
1063 verifyCeph(pepperEnv, target, 'mon@')
1064 }
1065 }
1066
1067 if (updates.contains("rgw")) {
1068 def target = RGW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001069 def type = 'rgw'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001070 if (salt.testTarget(pepperEnv, target)) {
1071 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001072 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001073 }
1074 if (PER_NODE.toBoolean()) {
1075 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1076 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001077 updatePkgs(pepperEnv, t, type)
1078 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001079 }
1080 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001081 updatePkgs(pepperEnv, target, type)
1082 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001083 }
1084 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1085 }
1086 }
1087
1088 if (updates.contains("log")) {
1089 def target = LOG_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001090 def type = 'log'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001091 if (salt.testTarget(pepperEnv, target)) {
1092 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001093 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001094 }
1095 if (PER_NODE.toBoolean()) {
1096 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1097 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001098 updatePkgs(pepperEnv, t, type)
1099 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001100 }
1101 } else {
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 }
1105 }
1106 }
1107
1108 if (updates.contains("mon")) {
1109 def target = MON_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001110 def type = 'mon'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001111 if (salt.testTarget(pepperEnv, target)) {
1112 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001113 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001114 }
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 }
1126 }
1127
1128 if (updates.contains("mtr")) {
1129 def target = MTR_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001130 def type = 'mtr'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001131 if (salt.testTarget(pepperEnv, target)) {
1132 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001133 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001134 }
1135 if (PER_NODE.toBoolean()) {
1136 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1137 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001138 updatePkgs(pepperEnv, t, type)
1139 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001140 }
1141 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001142 updatePkgs(pepperEnv, target, type)
1143 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001144 }
1145 }
1146 }
1147
1148 if (updates.contains("cid")) {
1149 def target = CID_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001150 def type = 'cid'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001151 if (salt.testTarget(pepperEnv, target)) {
1152 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001153 liveSnapshot(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001154 }
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001155 updatePkgs(pepperEnv, target, type)
1156 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001157 verifyService(pepperEnv, target, 'docker')
1158 }
1159 }
1160
1161 //
1162 //physical machines update CMP_TARGET
1163 //
1164 if (updates.contains("cmp")) {
1165 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001166 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001167 if (salt.testTarget(pepperEnv, target)) {
1168 if (PER_NODE.toBoolean()) {
1169 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1170 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001171 updatePkgs(pepperEnv, t, type)
1172 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001173 }
1174 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001175 updatePkgs(pepperEnv, target, type)
1176 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001177 }
1178 verifyService(pepperEnv, target, 'nova-compute')
1179 }
1180 }
1181
1182 if (updates.contains("kvm")) {
1183 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001184 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001185 if (salt.testTarget(pepperEnv, target)) {
1186 if (PER_NODE.toBoolean()) {
1187 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1188 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001189 updatePkgs(pepperEnv, t, type)
1190 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001191 }
1192 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001193 updatePkgs(pepperEnv, target, type)
1194 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001195 }
1196 verifyService(pepperEnv, target, 'libvirt-bin')
1197 }
1198 }
1199
1200 if (updates.contains("osd")) {
1201 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001202 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001203 if (salt.testTarget(pepperEnv, target)) {
1204 if (PER_NODE.toBoolean()) {
1205 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1206 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001207 updatePkgs(pepperEnv, t, type)
1208 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001209 }
1210 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001211 updatePkgs(pepperEnv, target, type)
1212 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001213 }
1214 verifyCephOsds(pepperEnv, target)
1215 }
1216 }
1217
1218 if (updates.contains("gtw-physical")) {
1219 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001220 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001221 if (salt.testTarget(pepperEnv, target)) {
1222 if (PER_NODE.toBoolean()) {
1223 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1224 for (t in targetHosts) {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001225 updatePkgs(pepperEnv, t, type)
1226 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001227 }
1228 } else {
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001229 updatePkgs(pepperEnv, target, type)
1230 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001231 }
1232 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1233 }
1234 }
1235
1236 /*
1237 * Rollback section
1238 */
Jiri Broulik906e9972018-03-26 16:12:00 +02001239 /* if (rollbacks.contains("cfg")) {
Jiri Broulik60dcab32018-03-08 17:42:06 +01001240 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1241 stage('ROLLBACK_CFG') {
1242 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."
1243 //rollbackSaltMaster(pepperEnv, 'I@salt:master')
1244 //finishSaltMasterRollback(pepperEnv, 'I@salt:master')
1245 }
1246 }
1247 } */
1248
1249 if (rollbacks.contains("ctl")) {
1250 def target = CTL_TARGET
1251 if (salt.testTarget(pepperEnv, target)) {
1252 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1253 rollback(pepperEnv, target, 'ctl')
1254 verifyAPIs(pepperEnv, target)
1255 } else {
1256 removeNode(pepperEnv, target, 'ctl')
1257 }
1258 }
1259 }
1260
1261 if (rollbacks.contains("prx")) {
1262 def target = PRX_TARGET
1263 if (salt.testTarget(pepperEnv, target)) {
1264 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1265 rollback(pepperEnv, target, 'prx')
1266 verifyService(pepperEnv, target, 'nginx')
1267 } else {
1268 removeNode(pepperEnv, target, 'prx')
1269 }
1270 }
1271 }
1272
1273 if (rollbacks.contains("msg")) {
1274 def target = MSG_TARGET
1275 if (salt.testTarget(pepperEnv, target)) {
1276 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1277 rollback(pepperEnv, target, 'msg')
1278 salt.enforceState(pepperEnv, target, 'rabbitmq')
1279 verifyService(pepperEnv, target, 'rabbitmq-server')
1280 } else {
1281 removeNode(pepperEnv, target, 'msg')
1282 }
1283 }
1284 }
1285
1286 if (rollbacks.contains("dbs")) {
1287 def target = DBS_TARGET
1288 if (salt.testTarget(pepperEnv, target)) {
1289 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1290 rollback(pepperEnv, target, 'dbs')
1291 clusterGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001292 verifyGalera(pepperEnv, target)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001293 } else {
1294 removeNode(pepperEnv, target, 'dbs')
1295 }
1296 }
1297 }
1298
1299 if (rollbacks.contains("ntw")) {
1300 def target = NTW_TARGET
1301 if (salt.testTarget(pepperEnv, target)) {
1302 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1303 rollback(pepperEnv, target, 'ntw')
1304 verifyContrail(pepperEnv, target)
1305 } else {
1306 removeNode(pepperEnv, target, 'ntw')
1307 }
1308 }
1309 }
1310
1311 if (rollbacks.contains("nal")) {
1312 def target = NAL_TARGET
1313 if (salt.testTarget(pepperEnv, target)) {
1314 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1315 rollback(pepperEnv, target, 'nal')
1316 verifyContrail(pepperEnv, target)
1317 } else {
1318 removeNode(pepperEnv, target, 'nal')
1319 }
1320 }
1321 }
1322
1323 if (rollbacks.contains("gtw-virtual")) {
1324 def target = GTW_TARGET
1325 if (salt.testTarget(pepperEnv, target)) {
1326 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1327 rollback(pepperEnv, target, 'gtw')
1328 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1329 } else {
1330 removeNode(pepperEnv, target, 'gtw')
1331 }
1332 }
1333 }
1334
1335 if (rollbacks.contains("cmn")) {
1336 def target = CMN_TARGET
1337 if (salt.testTarget(pepperEnv, target)) {
1338 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1339 rollback(pepperEnv, target, 'cmn')
1340 verifyCeph(pepperEnv, target, 'mon@')
1341 } else {
1342 removeNode(pepperEnv, target, 'cmn')
1343 }
1344 }
1345 }
1346
1347 if (rollbacks.contains("rgw")) {
1348 def target = RGW_TARGET
1349 if (salt.testTarget(pepperEnv, target)) {
1350 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1351 rollback(pepperEnv, target, 'rgw')
1352 verifyCeph(pepperEnv, target, 'radosgw@rgw.')
1353 } else {
1354 removeNode(pepperEnv, target, 'rgw')
1355 }
1356 }
1357 }
1358
1359 if (rollbacks.contains("log")) {
1360 def target = LOG_TARGET
1361 if (salt.testTarget(pepperEnv, target)) {
1362 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1363 rollback(pepperEnv, target, 'log')
1364 } else {
1365 removeNode(pepperEnv, target, 'log')
1366 }
1367 }
1368 }
1369
1370 if (rollbacks.contains("mon")) {
1371 def target = MON_TARGET
1372 if (salt.testTarget(pepperEnv, target)) {
1373 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1374 rollback(pepperEnv, target, 'mon')
1375 } else {
1376 removeNode(pepperEnv, target, 'mon')
1377 }
1378 }
1379 }
1380
1381 if (rollbacks.contains("mtr")) {
1382 def target = MTR_TARGET
1383 if (salt.testTarget(pepperEnv, target)) {
1384 if (!ROLLBACK_BY_REDEPLOY.toBoolean()) {
1385 rollback(pepperEnv, target, 'mtr')
1386 } else {
1387 removeNode(pepperEnv, target, 'mtr')
1388 }
1389 }
1390 }
1391 /*
1392 if (ROLLBACK_CID.toBoolean()) {
1393 def target = 'cid*'
1394 if (salt.testTarget(pepperEnv, target)) {
1395 stage('ROLLBACK_CID') {
1396 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."
1397 }
1398 }
1399 } */
1400
1401 //
1402 //physical machines rollback CMP_TARGET
1403 //
1404 if (rollbacks.contains("cmp")) {
1405 def target = CMP_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001406 def type = 'cmp'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001407 if (salt.testTarget(pepperEnv, target)) {
1408 if (PER_NODE.toBoolean()) {
1409 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1410 for (t in targetHosts) {
1411 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001412 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001413 }
1414 } else {
1415 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001416 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001417 }
1418 verifyService(pepperEnv, target, 'nova-compute')
1419 }
1420 }
1421
1422 if (rollbacks.contains("kvm")) {
1423 def target = KVM_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001424 def type = 'kvm'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001425 if (salt.testTarget(pepperEnv, target)) {
1426 if (PER_NODE.toBoolean()) {
1427 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1428 for (t in targetHosts) {
1429 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001430 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001431 }
1432 } else {
1433 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001434 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001435 }
1436 verifyService(pepperEnv, target, 'libvirt-bin')
1437 }
1438 }
1439
1440 if (rollbacks.contains("osd")) {
1441 def target = CEPH_OSD_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001442 def type = 'osd'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001443 if (salt.testTarget(pepperEnv, target)) {
1444 if (PER_NODE.toBoolean()) {
1445 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1446 for (t in targetHosts) {
1447 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001448 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001449 }
1450 } else {
1451 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001452 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001453 }
1454 verifyCephOsds(pepperEnv, target)
1455 }
1456 }
1457
1458 if (rollbacks.contains("gtw-physical")) {
1459 def target = GTW_TARGET
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001460 def type = 'gtw-physical'
Jiri Broulik60dcab32018-03-08 17:42:06 +01001461 if (salt.testTarget(pepperEnv, target)) {
1462 if (PER_NODE.toBoolean()) {
1463 def targetHosts = salt.getMinionsSorted(pepperEnv, target)
1464 for (t in targetHosts) {
1465 rollbackPkgs(pepperEnv, t)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001466 highstate(pepperEnv, t, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001467 }
1468 } else {
1469 rollbackPkgs(pepperEnv, target, target)
Jiri Broulikba6d85d2018-04-05 13:29:07 +02001470 highstate(pepperEnv, target, type)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001471 }
1472 verifyService(pepperEnv, target, 'neutron-dhcp-agent')
1473 }
1474 }
1475
1476 /*
1477 * Merge snapshots section
1478 */
1479 if (merges.contains("cfg")) {
1480 if (salt.testTarget(pepperEnv, 'I@salt:master')) {
1481 mergeSnapshot(pepperEnv, 'I@salt:master')
1482 }
1483 }
1484
1485 if (merges.contains("ctl")) {
1486 if (salt.testTarget(pepperEnv, CTL_TARGET)) {
1487 mergeSnapshot(pepperEnv, CTL_TARGET, 'ctl')
Jiri Broulik906e9972018-03-26 16:12:00 +02001488 verifyService(pepperEnv, CTL_TARGET, 'nova-api')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001489 }
1490 }
1491
1492 if (merges.contains("prx")) {
1493 if (salt.testTarget(pepperEnv, PRX_TARGET)) {
1494 mergeSnapshot(pepperEnv, PRX_TARGET, 'prx')
Jiri Broulik906e9972018-03-26 16:12:00 +02001495 verifyService(pepperEnv, PRX_TARGET, 'nginx')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001496 }
1497 }
1498
1499 if (merges.contains("msg")) {
1500 if (salt.testTarget(pepperEnv, MSG_TARGET)) {
1501 mergeSnapshot(pepperEnv, MSG_TARGET, 'msg')
Jiri Broulik906e9972018-03-26 16:12:00 +02001502 verifyService(pepperEnv, MSG_TARGET, 'rabbitmq-server')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001503 }
1504 }
1505
1506 if (merges.contains("dbs")) {
1507 if (salt.testTarget(pepperEnv, DBS_TARGET)) {
1508 mergeSnapshot(pepperEnv, DBS_TARGET, 'dbs')
Jiri Broulikad606d02018-03-28 14:22:43 +02001509 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik906e9972018-03-26 16:12:00 +02001510 backupGalera(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001511 }
1512 }
1513
1514 if (merges.contains("ntw")) {
1515 if (salt.testTarget(pepperEnv, NTW_TARGET)) {
1516 mergeSnapshot(pepperEnv, NTW_TARGET, 'ntw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001517 verifyContrail(pepperEnv, NTW_TARGET)
1518 backupContrail(pepperEnv)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001519 }
1520 }
1521
1522 if (merges.contains("nal")) {
1523 if (salt.testTarget(pepperEnv, NAL_TARGET)) {
1524 mergeSnapshot(pepperEnv, NAL_TARGET, 'nal')
Jiri Broulik906e9972018-03-26 16:12:00 +02001525 verifyContrail(pepperEnv, NAL_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001526 }
1527 }
1528
1529 if (merges.contains("gtw-virtual")) {
1530 if (salt.testTarget(pepperEnv, GTW_TARGET)) {
1531 mergeSnapshot(pepperEnv, GTW_TARGET, 'gtw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001532 verifyService(pepperEnv, GTW_TARGET, 'neutron-dhcp-agent')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001533 }
1534 }
1535
1536 if (merges.contains("cmn")) {
1537 if (salt.testTarget(pepperEnv, CMN_TARGET)) {
1538 mergeSnapshot(pepperEnv, CMN_TARGET, 'cmn')
Jiri Broulik906e9972018-03-26 16:12:00 +02001539 verifyCeph(pepperEnv, CMN_TARGET, 'mon@')
1540 backupCeph(pepperEnv, CMN_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001541 }
1542 }
1543
1544 if (merges.contains("rgw")) {
1545 if (salt.testTarget(pepperEnv, RGW_TARGET)) {
1546 mergeSnapshot(pepperEnv, RGW_TARGET, 'rgw')
Jiri Broulik906e9972018-03-26 16:12:00 +02001547 verifyCeph(pepperEnv, RGW_TARGET, 'radosgw@rgw.')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001548 }
1549 }
1550
1551 if (merges.contains("log")) {
1552 if (salt.testTarget(pepperEnv, LOG_TARGET)) {
Jiri Broulik3bd7adf2018-06-29 09:17:28 +02001553 mergeSnapshot(pepperEnv, LOG_TARGET, 'log')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001554 }
1555 }
1556
1557 if (merges.contains("mon")) {
1558 if (salt.testTarget(pepperEnv, MON_TARGET)) {
1559 mergeSnapshot(pepperEnv, MON_TARGET, 'mon')
1560 }
1561 }
1562
1563 if (merges.contains("mtr")) {
1564 if (salt.testTarget(pepperEnv, MTR_TARGET)) {
1565 mergeSnapshot(pepperEnv, MTR_TARGET, 'mtr')
1566 }
1567 }
1568
1569 if (merges.contains("cid")) {
1570 if (salt.testTarget(pepperEnv, CID_TARGET)) {
1571 mergeSnapshot(pepperEnv, CID_TARGET, 'cid')
Jiri Broulik906e9972018-03-26 16:12:00 +02001572 verifyService(pepperEnv, CID_TARGET, 'docker')
Jiri Broulik60dcab32018-03-08 17:42:06 +01001573 }
1574 }
1575
1576 if (RESTORE_GALERA.toBoolean()) {
1577 restoreGalera(pepperEnv)
Jiri Broulikad606d02018-03-28 14:22:43 +02001578 verifyGalera(pepperEnv, DBS_TARGET)
Jiri Broulik60dcab32018-03-08 17:42:06 +01001579 }
1580
1581 if (RESTORE_CONTRAIL_DB.toBoolean()) {
1582 restoreContrailDb(pepperEnv)
Jiri Broulik906e9972018-03-26 16:12:00 +02001583 // verification is already present in restore pipelines
Jiri Broulik60dcab32018-03-08 17:42:06 +01001584 }
1585
Richard Felklaedc89b2018-06-26 23:50:49 +02001586 if(RUN_CVP_TESTS.toBoolean() == True){
1587 stage('Run CVP tests after upgrade.') {
1588 build job: "cvp-sanity"
1589 build job: "cvp-func"
1590 build job: "cvp-ha"
1591 build job: "cvp-perf"
1592 }
1593 }
1594
Jiri Broulik60dcab32018-03-08 17:42:06 +01001595 } catch (Throwable e) {
1596 // If there was an error or exception thrown, the build failed
1597 currentBuild.result = "FAILURE"
1598 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
1599 throw e
1600 }
1601 }
1602}