blob: ca4145ff22c614ab98da6ed64cd4236fcc495dc8 [file] [log] [blame]
Pavel Cizinsky2051e982019-04-08 13:07:04 +02001def common = new com.mirantis.mk.Common()
2def salt = new com.mirantis.mk.Salt()
3def python = new com.mirantis.mk.Python()
4
5timeout(time: 12, unit: 'HOURS') {
6 node() {
7 stage('Setup virtualenv for Pepper') {
8 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
9 }
10 stage('Salt-Master restore') {
11 common.infoMsg('Verify pillar for salt-master backups')
12 try {
13 def masterPillar = salt.getPillar(pepperEnv, "I@salt:master", 'salt:minion:initial_data')
14 if(masterPillar['return'].isEmpty()) {
15 throw new Exception('Problem with salt-master pillar.')
16 }
17 def minionPillar = salt.getPillar(pepperEnv, "I@salt:master", 'salt:minion:initial_data')
18 if(minionPillar['return'].isEmpty()) {
19 throw new Exception('Problem with salt-minion pillar.')
20 }
21 }
22 catch (Exception e){
23 common.errorMsg(e.getMessage())
24 common.errorMsg('Please fix your pillar. For more information check docs: https://docs.mirantis.com/mcp/latest/mcp-operations-guide/backup-restore/salt-master/salt-master-restore.html')
25 return
26 }
27 common.infoMsg('Performing restore')
28 salt.enforceState(['saltId': pepperEnv, 'target': 'I@salt:master', 'state': 'salt.master.restore'])
29 salt.enforceState(['saltId': pepperEnv, 'target': 'I@salt:master', 'state': 'salt.minion.restore'])
30 salt.fullRefresh(pepperEnv, '*')
31
32 common.infoMsg('Validating output')
33 common.infoMsg('Salt-Keys')
34 salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key")
35 common.infoMsg('Salt-master CA')
36 salt.cmdRun(pepperEnv, 'I@salt:master', "ls -la /etc/pki/ca/salt_master_ca/")
37 }
38 stage('MAAS Restore') {
39 common.infoMsg('Verify pillar for MaaS backup')
40 try {
41 def maaSPillar = salt.getPillar(pepperEnv, "I@maas:server", 'maas:region:database:initial_data')
42 if(maaSPillar['return'].isEmpty()) {
43 throw new Exception('Problem with MaaS pillar.')
44 }
45 }
46 catch (Exception e){
47 common.errorMsg(e.getMessage())
48 common.errorMsg('Please fix your pillar. For more information check docs: https://docs.mirantis.com/mcp/latest/mcp-operations-guide/backup-restore/backupninja-postgresql/backupninja-postgresql-restore.html')
49 return
50 }
51 salt.enforceState(['saltId': pepperEnv, 'target': 'I@maas:region', 'state': 'maas.region'])
52 }
53 }
54}