blob: c9b0192ab71c84d017937250b73fef144a9649a2 [file] [log] [blame]
Roman Lubianyi26701f52021-11-09 17:32:34 +02001package com.mirantis.mcp
2
3/**
4 * Run check with parameters
5 *
6 * @param salt com.mirantis.mk.Salt object
7 * @param venvPepper venvPepper
8 * @param cluster_name MCP cluster name
9 * @param raise_exc Raise exception or return status of check
10**/
11
12def check_34406(salt, venvPepper, String cluster_name, Boolean raise_exc) {
13 def sphinxpasswordPillar = salt.getPillar(venvPepper, 'I@salt:master', '_param:sphinx_proxy_password_generated').get("return")[0].values()[0]
14 def waStatus = [prodId: "PROD-34406", isFixed: "", waInfo: ""]
15 if (sphinxpasswordPillar == '' || sphinxpasswordPillar == 'null' || sphinxpasswordPillar == null) {
16 waStatus.isFixed = "Work-around should be applied manually"
17 waStatus.waInfo = "See https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/mu/mu-9/mu-9-addressed/mu-9-dtrain/mu-9-dt-manual.html#i-34406 for more info"
18 if (raise_exc) {
19 error('Sphinx password is not defined.\n' +
20 waStatus.waInfo)
21 }
22 return waStatus
23 }
24 waStatus.isFixed = "Work-around for PROD-34406 already applied, nothing todo"
25 return waStatus
26}
27
28def check_34645(salt, venvPepper, String cluster_name, Boolean raise_exc) {
29 def updatecellsPillar = salt.getPillar(venvPepper, 'I@nova:controller', 'nova:controller:update_cells').get("return")[0].values()[0]
30 def waStatus = [prodId: "PROD-34645", isFixed: "", waInfo: ""]
31 if (updatecellsPillar.toString().toLowerCase() == 'false') {
32 waStatus.isFixed = "Work-around should be applied manually"
33 waStatus.waInfo = "See https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/openstack-operations/disable-nova-cell-mapping.html for more info"
34 if (raise_exc) {
35 error('Update cells disabled.\n' +
36 waStatus.waInfo)
37 }
38 return waStatus
39 }
40 waStatus.isFixed = "Work-around for PROD-34645 already applied, nothing todo"
41 return waStatus
42}
43
44def check_35705(salt, venvPepper, String cluster_name, Boolean raise_exc) {
45 def galeracheckpasswordPillar = salt.getPillar(venvPepper, 'I@salt:master', '_param:galera_clustercheck_password').get("return")[0].values()[0]
46 def waStatus = [prodId: "PROD-35705", isFixed: "", waInfo: ""]
47 if (galeracheckpasswordPillar == '' || galeracheckpasswordPillar == 'null' || galeracheckpasswordPillar == null) {
48 waStatus.isFixed = "Work-around should be applied manually"
49 waStatus.waInfo = "See https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/mu/mu-12/mu-12-addressed/mu-12-dtrain/mu-12-dt-manual.html#improper-operation-of-galera-ha for more info"
50 if (raise_exc) {
51 error('Galera clustercheck password is not defined.\n' +
52 waStatus.waInfo)
53 }
54 return waStatus
55 }
56 waStatus.isFixed = "Work-around for PROD-35705 already applied, nothing todo"
57 return waStatus
58}
59
60def check_35884(salt, venvPepper, String cluster_name, Boolean raise_exc) {
61 def waStatus = [prodId: "PROD-35884", isFixed: "", waInfo: ""]
62 if (salt.getMinions(venvPepper, 'I@prometheus:alerta or I@prometheus:alertmanager')) {
63 def alertaApiKeyGenPillar = salt.getPillar(venvPepper, 'I@salt:master', '_param:alerta_admin_api_key_generated').get("return")[0].values()[0]
64 def alertaApiKeyPillar = salt.getPillar(venvPepper, 'I@prometheus:alerta or I@prometheus:alertmanager', '_param:alerta_admin_key').get("return")[0].values()[0]
65 if (alertaApiKeyGenPillar == '' || alertaApiKeyGenPillar == 'null' || alertaApiKeyGenPillar == null || alertaApiKeyPillar == '' || alertaApiKeyPillar == 'null' || alertaApiKeyPillar == null) {
66 waStatus.isFixed = "Work-around should be applied manually"
67 waStatus.waInfo = "See https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/mu/mu-12/mu-12-addressed/mu-12-dtrain/mu-12-dt-manual.html#i-35884 for more info"
68 if (raise_exc) {
69 error('Alerta admin API key not defined.\n' +
70 waStatus.waInfo)
71 }
72 return waStatus
73 }
74 }
75 waStatus.isFixed = "Work-around for PROD-35884 already applied, nothing todo"
76 return waStatus
77}
78
79def check_36461(salt, venvPepper, String cluster_name, Boolean raise_exc){
80 def common = new com.mirantis.mk.Common()
81 def waStatus = [prodId: "PROD-36461", isFixed: "", waInfo: ""]
82 if (!salt.testTarget(venvPepper, 'I@ceph:radosgw')) {
83 return
84 }
85 def clusterModelPath = "/srv/salt/reclass/classes/cluster/${cluster_name}"
86 def checkFile = "${clusterModelPath}/ceph/rgw.yml"
87 def saltTarget = "I@salt:master"
88 try {
89 salt.cmdRun(venvPepper, saltTarget, "test -f ${checkFile}")
90 }
91 catch (Exception e) {
92 waStatus.isFixed = "Check skipped"
93 waStatus.waInfo = "Unable to check ordering of RadosGW imports, file ${checkFile} not found, skipping"
94 if (raise_exc) {
95 common.warningMsg(waStatus.waInfo)
96 return
97 }
98 return waStatus
99 }
100 def fileContent = salt.cmdRun(venvPepper, saltTarget, "cat ${checkFile}").get('return')[0].values()[0].replaceAll('Salt command execution success', '').trim()
101 def yamlData = readYaml text: fileContent
102 def infraClassImport = "cluster.${cluster_name}.infra"
103 def cephClassImport = "cluster.${cluster_name}.ceph"
104 def cephCommonClassImport = "cluster.${cluster_name}.ceph.common"
105 def infraClassFound = false
106 def importErrorDetected = false
107 def importErrorMessage = """Ceph classes in '${checkFile}' are used in wrong order! Please reorder it:
108'${infraClassImport}' should be placed before '${cephClassImport}' and '${cephCommonClassImport}'.
109For additional information please see https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/mu/mu-15/mu-15-addressed/mu-15-dtrain/mu-15-dtrain-manual.html"""
110 for (yamlClass in yamlData.classes) {
111 switch(yamlClass){
112 case infraClassImport:
113 infraClassFound = true;
114 break;
115 case cephClassImport:
116 if (!infraClassFound) {
117 importErrorDetected = true
118 };
119 break;
120 case cephCommonClassImport:
121 if (!infraClassFound) {
122 importErrorDetected = true
123 };
124 break;
125 }
126 }
127 if (importErrorDetected) {
128 waStatus.isFixed = "Work-around should be applied manually"
129 waStatus.waInfo = importErrorMessage
130 if (raise_exc) {
131 common.errorMsg(importErrorMessage)
132 error(importErrorMessage)
133 }
134 return waStatus
135 }
136 waStatus.isFixed = "Work-around for PROD-36461 already applied, nothing todo"
137 return waStatus
138}
139
140def check_36461_2 (salt, venvPepper, String cluster_name, Boolean raise_exc) {
141 def cephMonPillar = salt.getPillar(venvPepper, 'I@ceph:mon', 'ceph:common:config:mon:auth_allow_insecure_global_id_reclaim').get("return")[0].values()[0]
Roman Lubianyi36ef13b2021-11-26 15:56:44 +0200142 def cephVersion = salt.getPillar(venvPepper, 'I@ceph:mon', 'ceph:common:version').get("return")[0].values()[0]
Roman Lubianyi26701f52021-11-09 17:32:34 +0200143 def waStatus = [prodId: "PROD-36461_2", isFixed: "", waInfo: ""]
Roman Lubianyi36ef13b2021-11-26 15:56:44 +0200144 if (cephMonPillar.toString().toLowerCase() != 'false' && cephVersion.toString().toLowerCase() == 'nautilus') {
Roman Lubianyi26701f52021-11-09 17:32:34 +0200145 waStatus.isFixed = "Work-around should be applied manually"
146 waStatus.waInfo = "See https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/single/index.html#i-cve-2021-20288 for more info"
147 if (raise_exc) {
148 error('Needed option is not set.\n' +
149 waStatus.waInfo)
150 }
151 return waStatus
152 }
153 waStatus.isFixed = "Work-around for PROD-36461_2 already applied, nothing todo"
154 return waStatus
155}