blob: 879780b4c01d0416d01350a66307f2fa1a30253e [file] [log] [blame]
Dzmitry Stremkouskia9875d42020-07-06 16:45:36 +02001/**
2 *
3 * Cleanup OpenStack databases from stale records (archived records or records marked as deleted).
4 * Cleanup OpenStack service databases.
5 *
6 * Expected parameters:
7 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
8 * SALT_MASTER_URL Full Salt API address [http://10.10.10.15:6969].
9 *
10**/
11
12def common = new com.mirantis.mk.Common()
13def salt = new com.mirantis.mk.Salt()
14def python = new com.mirantis.mk.Python()
15
Oleksii Molchanov0cbc68d2021-09-07 14:43:03 +030016def os_services = [ 'nova:controller', 'heat:server', 'cinder:controller', 'glance:server' ]
Dzmitry Stremkouskia9875d42020-07-06 16:45:36 +020017
18def slave_node = 'python'
19
20if (common.validInputParam('SLAVE_NODE')) {
21 slave_node = SLAVE_NODE
22}
23
24def env = "pepperEnv"
25timeout(time: 12, unit: 'HOURS') {
26
27 node(slave_node) {
28
29 stage('Setup virtualenv for Pepper') {
30 python.setupPepperVirtualenv(env, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
31 }
32
33 stage('Databases cleanup') {
34
35 for (os_service in os_services) {
36
37 formula = os_service.split(":")[0]
38 os_state = "${formula}.db.db_cleanup"
39 os_file = "/usr/share/salt-formulas/env/${formula}/db/db_cleanup.sls"
40
41 if (salt.runSaltProcessStep(env, 'I@salt:master', 'file.file_exists', [os_file], null, true, 5)['return'][0].values()[0].toBoolean()) {
42 salt.enforceStateWithTest([saltId: env, target: "I@${os_service}:role:primary", state: [os_state]])
43 }
44
45 }
46 }
47 }
48}